Simple script for downloading Youtube comments without using the Youtube API
Project description
yt-comment-dl
Simple script for downloading YouTube comments without using the YouTube API. The output is in JSON format.
This is a maintained fork of egbertbouman/youtube-comment-downloader.
Installation
Preferably inside a python virtual environment install this package via:
pip install yt-comment-dl
Or directly from the GitHub repository:
pip install git+https://github.com/youssefadly237/yt-comment-dl.git
Usage as command-line interface
$ yt-comment-dl --help
usage: yt-comment-dl [-h] [--output OUTPUT] [--pretty] [--limit LIMIT] [--language LANGUAGE] [--sort {0,1}] url
Download YouTube comments without using the YouTube API
positional arguments:
url YouTube video URL or video ID
options:
-h, --help Show this help message and exit
--output OUTPUT, -o OUTPUT Output filename (default: comments_<video_id>.json)
--pretty, -p Pretty-print JSON output
--limit LIMIT, -l LIMIT Maximum number of comments to download
--language LANGUAGE, -a LANGUAGE Language for YouTube generated text (e.g. en)
--sort {0,1}, -s {0,1} Sort by: 0=popular, 1=recent (default: 1)
Examples
Download comments using a YouTube URL:
yt-comment-dl "https://www.youtube.com/watch?v=ScMzIvxBSi4" --output ScMzIvxBSi4.json
Download comments using just the video ID:
yt-comment-dl ScMzIvxBSi4 --output ScMzIvxBSi4.json
Download the 50 most popular comments with pretty formatting:
yt-comment-dl ScMzIvxBSi4 --sort 0 --limit 50 --pretty
For YouTube IDs starting with - (dash), you may need to use quotes:
yt-comment-dl "-idwithdash"
Usage as library
You can also use this script as a library. For instance, if you want to print out the 10 most popular comments for a particular YouTube video you can do the following:
from itertools import islice
from yt_comment_dl import YoutubeCommentDownloader
downloader = YoutubeCommentDownloader()
comments = downloader.get_comments('ScMzIvxBSi4', sort_by=0) # 0 = popular
for comment in islice(comments, 10):
print(comment.to_dict())
Output format
The output is a JSON array containing comment objects. Each comment has the following structure:
[
{
"cid": "comment_id",
"text": "Comment text",
"time": "2 hours ago",
"author": "Author Name",
"channel": "author_channel_id",
"votes": 42,
"photo": "author_profile_photo_url",
"heart": false,
"reply": false,
"time_parsed": 1234567890
}
]
License
MIT License - see LICENSE file for details
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_comment_dl-0.1.0.tar.gz.
File metadata
- Download URL: yt_comment_dl-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b33352b0d0414df22e067ed1b56557b61968eed199d69e878644d8d1a2f7ff6b
|
|
| MD5 |
c32a17a843c6115856d55d4f2ab3b842
|
|
| BLAKE2b-256 |
216a754a185800e0b5dff0e6871f718162081ce994c9070eca8fd4328da66c13
|
Provenance
The following attestation bundles were made for yt_comment_dl-0.1.0.tar.gz:
Publisher:
publish.yml on youssefadly237/yt-comment-dl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yt_comment_dl-0.1.0.tar.gz -
Subject digest:
b33352b0d0414df22e067ed1b56557b61968eed199d69e878644d8d1a2f7ff6b - Sigstore transparency entry: 445143436
- Sigstore integration time:
-
Permalink:
youssefadly237/yt-comment-dl@52877c9f051006efe3b14136ba22a8ca771419a6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/youssefadly237
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52877c9f051006efe3b14136ba22a8ca771419a6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file yt_comment_dl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: yt_comment_dl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4383cabfee9bef04c7708b4e91bc239e1f09cc6ca10774eac5c04d4704cf08b6
|
|
| MD5 |
45104af764a6a2d243a8a621587ace71
|
|
| BLAKE2b-256 |
79760c1751d624459a1a1023817d5fd9b226a55a80232464c39b3de9cf2e61bc
|
Provenance
The following attestation bundles were made for yt_comment_dl-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on youssefadly237/yt-comment-dl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yt_comment_dl-0.1.0-py3-none-any.whl -
Subject digest:
4383cabfee9bef04c7708b4e91bc239e1f09cc6ca10774eac5c04d4704cf08b6 - Sigstore transparency entry: 445143446
- Sigstore integration time:
-
Permalink:
youssefadly237/yt-comment-dl@52877c9f051006efe3b14136ba22a8ca771419a6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/youssefadly237
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52877c9f051006efe3b14136ba22a8ca771419a6 -
Trigger Event:
release
-
Statement type: