Download YouTube live chat replays and comments (Beta)
Project description
YouTube Chat Downloader
This tool provides a simple method for retrieving chat logs from both past (VOD) and ongoing YouTube live streams for data analysis. Live stream chats contain valuable data for understanding audience sentiment, identifying trends, and measuring engagement. This downloader makes that data accessible for your research.
A Python package to download YouTube live chat replays and regular comments from any YouTube video. Perfect for archiving live streams, analyzing chat interactions, or collecting comment data.
Features
- 🔴 Live Stream Support: Continuous polling mode for active live streams
- 💬 Chat Replay: Download complete chat history from finished live streams
- 📝 Regular Comments: Fetch standard video comments
- 🎯 Multiple Formats: Support for text messages, super chats, and membership messages
- 📊 Rich Metadata: Includes user info, timestamps, badges, and more
- 💾 Auto-saving: Incremental JSON output (survives interruptions)
- ⌨️ Graceful Interruption: Press Ctrl+C to stop and save progress
Installation
From PyPI (when published)
pip install yt-chat-downloader
From Source
git clone https://github.com/yourusername/yt-chat-downloader.git
cd yt-chat-downloader
pip install -e .
Quick Start
Command Line
Download both chat replay and comments:
yt-chat-downloader "https://www.youtube.com/watch?v=VIDEO_ID"
Download only live chat replay:
yt-chat-downloader VIDEO_ID --chat-type live
Download only regular comments:
yt-chat-downloader VIDEO_ID --chat-type comments
Specify output file:
yt-chat-downloader VIDEO_ID -o my_chat.json
Quiet mode (minimal output):
yt-chat-downloader VIDEO_ID --quiet
Python API
from yt_chat_downloader import YouTubeChatDownloader
# Initialize downloader
downloader = YouTubeChatDownloader()
# Download chat and comments
messages = downloader.download_chat(
video_url="https://www.youtube.com/watch?v=VIDEO_ID",
chat_type="both", # Options: "live", "comments", "both"
output_file="chat_data.json",
quiet=False
)
# Process messages
for msg in messages:
print(f"{msg['user_display_name']}: {msg['comment']}")
Output Format
The downloader saves messages in JSON format with the following structure:
[
{
"user_id": "UC...",
"user_display_name": "Dev maker",
"user_handle": "@devmaker",
"datetime": "2024-01-15T10:30:00",
"timestamp": "1:23:45",
"comment": "Great stream!",
"message_type": "text",
"badges": ["Verified", "Member (6 months)"],
"message_id": "...",
"purchase_amount": "",
"video_offset_ms": "5025000"
}
]
Message Types
text: Regular chat messagesuper_chat: Super Chat (paid message)membership: Membership milestone/welcome messagecomment: Regular video comment
Live Stream Mode
For active live streams, the downloader enters continuous polling mode:
- Automatically detects live streams
- Polls for new messages continuously
- Saves progress incrementally
- Handles API rate limiting
- Retries on temporary failures
- Runs until you press Ctrl+C
Example:
yt-chat-downloader "https://www.youtube.com/watch?v=LIVE_VIDEO_ID"
# 🔴 LIVE STREAM DETECTED - Continuous polling mode enabled
# ⌨️ Press Ctrl+C to stop downloading
# [downloading messages...]
# ^C
# ⚠️ Download interrupted by user
# 💾 Messages saved to: youtube_chat_LIVE_VIDEO_ID_1234567890.json
Dependencies
- Python 3.7+
click- Command-line interfacerequests- HTTP requestsyt-dlp- YouTube metadata extractionpython-dateutil- Date parsing
Use Cases
- Archive live streams: Save chat before it's deleted
- Research & Analysis: Analyze viewer engagement and sentiment
- Content Creation: Create highlight reels with chat context
- Moderation: Review chat history for moderation purposes
- Bot Development: Collect training data for chatbots
Limitations
- Requires video to have live chat enabled
- Some videos may have chat disabled or deleted
- Rate limiting applies (handled automatically)
- Very old videos may have incomplete chat data
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This tool is for educational and archival purposes. Please respect YouTube's Terms of Service and the privacy of content creators and chat participants. Use responsibly.
Acknowledgments
- Built with yt-dlp for video metadata
- Uses YouTube's internal InnerTube API for chat data
Support
If you encounter any issues or have questions:
- Open an issue on GitHub
- Check existing issues for solutions
- Provide video ID and error messages when reporting bugs
Made with ❤️ for the YouTube archiving community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yt_chat_downloader-0.0.3.tar.gz.
File metadata
- Download URL: yt_chat_downloader-0.0.3.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b27ce3bdc6d1c1180eae078aa82e783c30d8b532c68968a59c10da0ac5602278
|
|
| MD5 |
70c211eada751d3776e06c7aa9508ed6
|
|
| BLAKE2b-256 |
22a77d2c7d522035ead288d6918f44b9268660e0d5bda0c030be05430493538a
|
File details
Details for the file yt_chat_downloader-0.0.3-py3-none-any.whl.
File metadata
- Download URL: yt_chat_downloader-0.0.3-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af3f8656d9ceaaa38435f9616807a15aaec0f2973efbfcb58a0f762ed46f833b
|
|
| MD5 |
9cf0bcfb3f0e277217bf380415518460
|
|
| BLAKE2b-256 |
1b145f362a8aea6a5d9cdbdd340d2d71525bea00340ed179418020c299b0ea83
|