Skip to main content

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 message
  • super_chat: Super Chat (paid message)
  • membership: Membership milestone/welcome message
  • comment: Regular video comment

Live Stream Mode

For active live streams, the downloader enters continuous polling mode:

  1. Automatically detects live streams
  2. Polls for new messages continuously
  3. Saves progress incrementally
  4. Handles API rate limiting
  5. Retries on temporary failures
  6. 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 interface
  • requests - HTTP requests
  • yt-dlp - YouTube metadata extraction
  • python-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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yt_chat_downloader-0.0.3.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yt_chat_downloader-0.0.3-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

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

Hashes for yt_chat_downloader-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b27ce3bdc6d1c1180eae078aa82e783c30d8b532c68968a59c10da0ac5602278
MD5 70c211eada751d3776e06c7aa9508ed6
BLAKE2b-256 22a77d2c7d522035ead288d6918f44b9268660e0d5bda0c030be05430493538a

See more details on using hashes here.

File details

Details for the file yt_chat_downloader-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for yt_chat_downloader-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af3f8656d9ceaaa38435f9616807a15aaec0f2973efbfcb58a0f762ed46f833b
MD5 9cf0bcfb3f0e277217bf380415518460
BLAKE2b-256 1b145f362a8aea6a5d9cdbdd340d2d71525bea00340ed179418020c299b0ea83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page