31

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?

ib.
  • 27,830
  • 11
  • 80
  • 100
kkorona
  • 425
  • 1
  • 4
  • 8

1 Answers1

25

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

Xenova
  • 330
  • 5
  • 10
  • This fails when there are emojis in the chat. Any suggestions? – Harini P Sep 21 '20 at 00:12
  • 1
    @HariniP are you sure? I specifically ensure that emojis are read. If you have an issue, you can raise it on the github page and I will take a look at it as soon as possible. Please provide an example of when it fails (e.g. a video and the timestamp) if you create an issue. – Xenova Sep 21 '20 at 00:44
  • Thank you for your script! Do you know if there is any way to recover the pre-chat and post-chat from an archived YT stream? The default options only seem to download the chat from the time the actual stream or premiere started until it ended, missing all the waiting time and the few minutes after the end, while chat is still running. – Tobia Aug 13 '21 at 13:51
  • I like your tool, but ... need to rewrite it as JavaScript, because I had problems to use cookies with sponsored streams. With JavaScript I could log on to YouTube, load the JS file and make it download all the pieces of a chat. – Paul Aug 01 '22 at 18:38
  • Is there any way to retrieve the chat history for a video that has live chat replay disabled? It has 1.4M views and is from a major media company, so maybe there's some site that saved it while the stream was going on? https://www.youtube.com/watch?v=pscny8yL_ww – flarn2006 Sep 20 '22 at 15:25