Ingest messages from YouTube live chat to MongoDB.
This is related to the projects ytchat-backend and ytchat-frontend.
Currently, this program is designed to ingest from only one chat at a time.
Additionally, there is no good way to find pending YouTube live streams, so it checks for a redirect
from https://youtube.com/CHANNEL_ID/live
. This means that it only supports one live stream per channel at a time,
depending on which the URL redirects to.
Install dependencies with:
pip install -r requirements.txt
Before launching, set any necessary environment variables.
# bash
YTCHAT_CHANNELID=...
# powershell
$env:YTCHAT_CHANNELID = "..."
Variable | Purpose | Default |
---|---|---|
YTCHAT_CHANNELID | Which MongoDB collection messages should be inserted into. | UCrPseYLGpNygVi34QpGNqpA (Ludwig) |
YTCHAT_INGEST_MONGO_URL | Host URL for MongoDB instance that should store messages. | localhost |
YTCHAT_INGEST_MONGO_PORT | Port for the MongoDB instance that should store messages. | 27017 |
Note: you will need to set an index that enforces uniqueness of messages based on the id
field (not _id
). Otherwise,
you will occasionally get duplicate messages inserted into the DB.
python3 main.py CHANNEL_ID
This program is released under the MIT License