ohn0 / youtube-livechat-scraper

grab youtube live chat data from existing VODs
MIT License
9 stars 2 forks source link

SuperChat Messages missing authorName key #24

Open repollo opened 12 months ago

repollo commented 12 months ago

When parsing the data there are time where authorName doesnt exists in the payload, for those situations might be a good idea to try another key if not return a default value, consider changing superchat_message.py like so:

self.author = self.content_node[nc.AUTHOR_NODE][nc.SIMPLE_TEXT_NODE]

to

# Check if the author node exists, if not use authorExternalChannelId or a default value
self.author = self.content_node.get(nc.AUTHOR_NODE, {}).get(nc.SIMPLE_TEXT_NODE, self.content_node.get('authorExternalChannelId', 'Unknown Author'))
ohn0 commented 11 months ago

cool i'll take a look, thanks