Last active
September 6, 2021 04:38
-
-
Save chand1012/625c5a57821cac721ee2a42f1133a47e to your computer and use it in GitHub Desktop.
Get all of the twitch chat from a twitch VOD. See license here: https://chand1012.mit-license.org/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
from twitch import Helix | |
from twitch.v5.models.comment import Comment | |
def comment_to_dict(comment: Comment): | |
return { | |
'id': comment.id, | |
'created_at': comment.created_at, | |
'updated_at': comment.updated_at, | |
'channel_id': comment.channel_id, | |
'content_type': comment.content_type, | |
'content_id': comment.content_id, | |
'content_offset_seconds': comment.content_offset_seconds, | |
'commenter': comment.commenter.display_name, | |
'source': comment.source, | |
'state': comment.state, | |
'message': comment.message.body, | |
'more_replies': comment.more_replies | |
} | |
twitch = Helix(os.environ.get('TWITCH_ID'), os.environ.get('TWITCH_SECRET')) | |
vod = twitch.video(870225647) # put the VOD id here | |
comments = [] | |
for comment in vod.comments: | |
comments += [comment_to_dict(comment)] | |
print(len(comments)) | |
with open('test.json', 'w') as f: | |
f.write(json.dumps(comments)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment