A simple tool used to retrieve YouTube/Twitch chat from past broadcasts/VODs. No authentication needed!
- This tool was created in a Python 3 environment.
- Run
pip install -r requirements.txt
to ensure you have the necessary dependencies.
usage: chat_replay_downloader.py [-h] [-start_time START_TIME]
[-end_time END_TIME]
[-message_type {messages,superchat,all}]
[-output OUTPUT]
url
Retrieve YouTube/Twitch chat from past broadcasts/VODs.
positional arguments:
url YouTube/Twitch video URL
optional arguments:
-h, --help show this help message and exit
-start_time START_TIME, -from START_TIME
start time in seconds or hh:mm:ss
(default: 0)
-end_time END_TIME, -to END_TIME
end time in seconds or hh:mm:ss
(default: None = until the end)
-message_type {messages,superchat,all}
types of messages to include [YouTube only]
(default: messages)
-output OUTPUT, -o OUTPUT
name of output file
(default: None = print to standard output)
python chat_replay_downloader.py <video_url> -output <file_name>
If the file name ends in .json
, the array will be written to the file in JSON format. Similarly, if the file name ends in .csv
, the data will be written in CSV format.
Otherwise, the chat messages will be outputted to the file in the following format:
[<time>] <author>: <message>
python chat_replay_downloader.py <video_url> -start_time <time> -output <file_name>
3. Output file of chat messages, starting from the beginning and ending at a certain time (in seconds or hh:mm:ss)
python chat_replay_downloader.py <video_url> -end_time <time> -output <file_name>
python chat_replay_downloader.py <video_url> -start_time <time> -end_time <time> -output <file_name>
python chat_replay_downloader.py https://www.youtube.com/watch?v=pMsvr55cTZ0 -start_time 14400 -end_time 15000 -output example.json
python chat_replay_downloader.py https://www.youtube.com/watch?v=pMsvr55cTZ0 -start_time 14400 -end_time 15000 -output example.csv
python chat_replay_downloader.py https://www.youtube.com/watch?v=pMsvr55cTZ0 -start_time 14400 -end_time 15000 -output example.txt
import chat_replay_downloader
or
from chat_replay_downloader import get_chat_replay, get_youtube_messages, get_twitch_messages
The following examples will use the second form of importing.
youtube_messages = get_chat_replay('https://www.youtube.com/watch?v=xxxxxxxxxxx')
twitch_messages = get_chat_replay('https://www.twitch.tv/videos/xxxxxxxxx')
youtube_messages = get_youtube_messages('xxxxxxxxxxx')
twitch_messages = get_twitch_messages('xxxxxxxxx')
The following examples use parameters which all three methods (get_chat_replay
, get_youtube_messages
, get_twitch_messages
) have. Both of the following parameters are optional:
start_time
: start time in seconds or hh:mm:ss (Default is 0, which is the start of the video)end_time
: end time in seconds or hh:mm:ss (Default is None, which means it will continue until the video ends)
messages = get_chat_replay('video_url', start_time = 60) # Start at 60 seconds and continue until the end
messages = get_chat_replay('video_url', end_time = 60) # Start at 0 seconds (beginning) and end at 60 seconds
messages = get_chat_replay('video_url', start_time = 60, end_time = 120) # Start at 60 seconds and end at 120 seconds