I got live comments of all videos of Hinano Tachibana (vtuber). See ./Thinano/data/0IFEp1Bt3qw.json. The data is all https://github.com/1k-ct/Thinano here.
The name is the name of the person who commented, and the message is the comment. : _naa :: _noo: ← This is a stamp that can only be used by members.
--See comments on other videos -Click here. --Click comment. --Select the file you want to see https://www.youtube.com/watch?v=oQmgxXbT8OE is like this oQmgxXbT8OE.json --Press View raw to see the file.
Here is the amount of each video of Spacha. The video with the most spachas is [Celebration] Monetization! !! Thank you to 6000 people ♡ [IBG / Hinano Tachibana] Is this video about 400,000 yen?
Maximum total amount
{
"oQmgxXbT8OE": {
"¥": 371203.0,
"PHP ": 500.0,
"₩": 2000.0,
"CA$": 55.0,
"A$": 10.0
}
}
From here, we will introduce the survey method. From now on, I will introduce some of the two URLs below. https://github.com/taizan-hokuto/pytchat https://github.com/taizan-hokuto/pytchat/wiki/Home_jp
Python 3.8.5
pytchat 0.4.2
Installation
$ pip install pytchat
Please see officially. https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore_
main.py
import pytchat
import time
#Get PytchatCore object
livechat = pytchat.create(video_id = "Zvp1pJpie4I")# video_id is https://....watch?v=Behind
while livechat.is_alive():
#Get chat data
chatdata = livechat.get()
for c in chatdata.items:
print(f"{c.datetime} {c.author.name} {c.message} {c.amountString}")
'''
Get as JSON string:
print(c.json())
'''
time.sleep(5)
See also officially. https://github.com/taizan-hokuto/pytchat/wiki/SuperchatCalculator_
--Install progress bar
It's good to know the progress
$ pip install tqdm
main.py
from tqdm import tqdm
from pytchat import Extractor, VideoInfo, SuperchatCalculator
import signal
'''
Progress bar showing progress
'''
class ProgressBar:
def __init__(self,total):
self.total = total*1000
self.pbar = tqdm(total = self.total, ncols = 80, unit_scale = 1,
bar_format='{desc}{percentage:3.1f}%|{bar}|'
'[{n_fmt:>7}/{total_fmt}]{elapsed}<{remaining}')
def callback(self, actions, fetched):
if self.total - fetched < 0:
fetched = self.total
self.total -= fetched
self.pbar.update(fetched)
def close(self):
self.pbar.update(self.total)
self.pbar.close()
def cancel(self):
self.pbar.close()
if __name__ == '__main__':
video_id = "GY-LSsYVpJ4"
info = VideoInfo(video_id)
print('Calculate Superchat: [title] ', info.get_title())
#Prepare a progress bar.
pbar = ProgressBar(info.get_duration())
#Extractor generation
ex = Extractor(
video_id,
callback = pbar.callback,
div = 10,
processor = SuperchatCalculator()
)
#Ctrl+Cancel with C
signal.signal(signal.SIGINT,
(lambda a, b: ex.cancel()))
#Perform extraction
result = ex.extract()
#Display of aggregation results
pbar.close()
print(result)
All explanations can be found at the URL above. I was wondering if I could write an article just by introducing it. Also, it's hard to see json in super chat. I'll fix it. Please contact me if you have any questions. Thank you very much.
Recommended Posts