Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script error for message types presenting that a user purchased a product linked to the YouTube channel merchandising #17

Closed
jasonkhanlar opened this issue Oct 20, 2020 · 2 comments

Comments

@jasonkhanlar
Copy link

python chat_replay_downloader.py https://youtu.be/y5ih7nqEoc4 -message_type all -output y5ih7nqEoc4

Just after reachin 1:52:29 into parsing I see:

Traceback (most recent call last):
  File "chat_replay_downloader.py", line 455, in <module>
    chat_messages = chat_downloader.get_chat_replay(
  File "chat_replay_downloader.py", line 409, in get_chat_replay
    return self.get_youtube_messages(match.group(1), start_time, end_time, message_type)
  File "chat_replay_downloader.py", line 333, in get_youtube_messages
    data = self.__parse_item(item)
  File "chat_replay_downloader.py", line 235, in __parse_item
    self.__time_to_seconds(data['time_text']))
KeyError: 'time_text'

I think this is because the last data variable values are:

{'message': 'NEVER EVER GIVE IN', 'author': 'Stephen Kelly', 'timestamp': 1603158759859453, 'time_text': '1:52:29'}

{'timestamp': 1603158761042020, 'message': None}

Watching the video and chat replay on YouTube during that time I see...aha! I see now!

Someone just bought
The Death of Censorship
https://teespring.com/en/silence-victory-accelerates

Therefore, it seems like event handling for this other message type is what the problem is

Specifically liveChatPurchasedProductMessageRenderer

Adding it as line 45 fixes it:

        'ignore': [
            # message saying Live Chat replay is on
            'liveChatViewerEngagementMessageRenderer',
            'liveChatPurchasedProductMessageRenderer',
            'liveChatPlaceholderItemRenderer',  # placeholder
            'liveChatModeChangeMessageRenderer'  # e.g. slow mode enabled
        ],

I'm surprised that I can't find any API documentation info about it at https://developers.google.com/youtube/v3/live/docs/liveChatMessages

I thought Google used to be a company that excelled at being on top of its game providing #1 best excellent resource of information and documentation and analysis, but I think that is no longer the case. Bummer!

@xenova
Copy link
Owner

xenova commented Oct 20, 2020

Oh wow great spot! I will add that into the code, thank you!

@xenova xenova closed this as completed in 2abb963 Oct 20, 2020
@xenova
Copy link
Owner

xenova commented Jan 15, 2021

@jasonkhanlar Hi again Jason. To add debugging features to the software, I have tried to find an example of every "message type". One of which is the liveChatPurchasedProductMessageRenderer as you've discovered above. However, it would seem as though the video above has removed the item from the stream - for some reason?

Do you perhaps know of another video/stream which has it? I actually tried every single live stream from the above channel, but to no avail. I've also googled it, but nothing comes up. It would seem as though you were the first one to discover it.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants