A lightweight, multi-threaded script that downloads (and continues) YouTube video comments for one or more channels using yt-dlp as the backend.
This repository provides a small command-line tool that:
- Lists videos for given channel IDs (in the order provided),
- Spawns multiple workers to download comments in parallel,
- Supports continuing partial downloads (useful for long-running collection jobs),
- Accepts a cookies file when needed to access age-gated or region-restricted content.
- Parallel comment collection (configurable worker count).
- Works with multiple YouTube channels in a single run.
- Uses
yt-dlpfor robust video listing and comment extraction. - Simple filesystem-based output (one folder per channel/video).
- Optional cookies support for authenticated or region-restricted access.
- NEW: Accepts channel IDs directly from a file (one ID per line).
- Python 3.8+
yt-dlpin yourPATH(install with pip or follow official instructions):
pip install yt-dlptqdmfor progress bars:
pip install tqdmClone this repo (or copy the script) and install the Python dependency:
git clone <repo-url>
cd get_youtube_comments
pip install -r requirements.txt # if you prefer a requirements file
# or
pip install yt-dlp tqdmIf you plan to access content behind login/age gate, export cookies using your browser (cookies.txt) and pass it with --cookies.
python get_comments.py --channel_ids <CHANNEL_ID_1> <CHANNEL_ID_2> ... --output <path/to/output> [--num_threads N] [--cookies cookies.txt]Create a text file with one channel ID per line (ignore empty lines and # comments). Example channels.txt:
UC_x5XG1OV2P6uZZ5FSM9Ttw
# This is a comment line
UCYO_jab_esuFRV4b17AJtAw
Run with:
python get_comments.py --channels_file channels.txt --output <path/to/output>You can provide both inline IDs and a file. Duplicates are automatically removed:
python get_comments.py --channels_file channels.txt --channel_ids UC123... UC456... --output <path/to/output>| Option | Required | Description |
|---|---|---|
--channel_ids |
No | One or more YouTube channel IDs to collect from. |
--channels_file |
No | Path to a text file containing one channel ID per line. |
--output |
Yes | Root output folder where results will be written. |
--num_threads |
No | Number of worker threads (default: 4). |
--cookies |
No | Path to a cookies file (e.g., cookies.txt) for authenticated access. |
-h, --help |
No | Show usage and exit. |
- For each channel ID from CLI or file, the script asks
yt-dlpto list the channel's videos. - The videos are queued (preserving channel order).
- The script spawns
Nworker threads (--num_threads) that pull the next video from the queue and runyt-dlp --write-commentsto fetch comments. - Each worker writes a file (or files) under the provided
--outputdirectory. Partially downloaded channels are preserved so the process can be continued later without re-downloading everything.
Contributions, bug reports and improvements are welcome.