Search code examples
youtube-apichatlive-streaminglivechat

Is there any way to get the live chat replay log/history for YouTube streaming video?


I’ve been doing research on online chat message patterns recently. I’ve chosen YouTube and Twitch.tv for the chat message sources.

I’ve found chat loggers for real-time livestreams, but I also need acquire the chat log/history for already broadcasted livestreams which allow live chat replay (for example, https://www.youtube.com/watch?v=1JfohG5a8y8).

There is a tool for Twitch.tv (RechatTool from jdpurcell), but I couldn’t find any similar tool for YouTube.

I’ve checked YouTube API for livestream messages, but I couldn’t find any instructions or tips on how to access live chat replays. Is there any possible solutions for this?


Solution

  • Chat Downloader is a tool I developed to retrieve chat messages from livestreams, videos, clips and past broadcasts. No authentication needed!

    The recommended way to install is from PyPI using pip:

    pip install chat-downloader
    

    The program can then be accessed from the command line or using the Python module:

    Command line

    chat_downloader https://www.youtube.com/watch?v=5qap5aO4i9A
    

    For advanced command line use-cases and examples, consult the Command Line Wiki.

    Python

    from chat_downloader import ChatDownloader
    
    url = 'https://www.youtube.com/watch?v=5qap5aO4i9A'
    chat = ChatDownloader().get_chat(url)       # create a generator
    for message in chat:                        # iterate over messages
        print(chat.format(message))             # print the formatted message
    

    For advanced python use-cases and examples, consult the Python Wiki.


    Features include specifying start and/or end times and outputting to JSON, CSV and text files.

    The software is open-source (MIT license) and is actively under development. The source code can be found on GitHub: https://github.com/xenova/chat-downloader