Computing

Download a YouTube video comments with yt-dlp

Another seemingly hidden feature with yt-dlp is the ability to save the YouTube video comments into a JSON file.

With yt-dlp downloading the video comments into a JSON file is done with the --write-comments flag.

yt-dlp --write-comments VIDEO_URL

For popular videos with a lot of comments, this can take several minutes.

An example of a comment in the JSON file:

{
   "id": "UgzewWuFZvI0FsncvKR4AaABAg",
   "text": "These double ads are really getting on my nerves",
   "timestamp": 1614816000,
   "time_text": "1 year ago",
   "like_count": 1,
   "is_favorited": false,
   "author": "Michael M",
   "author_id": "UCKYW7m35n1kBassjpjakd7g",
   "author_thumbnail": "https://yt3.ggpht.com/ytc/AKedOLRr_ZwtCbdnb_qiqsKkwnTT4Y0eSW9SpgklicNt=s176-c-k-c0x00ffffff-no-rj",
   "author_is_uploader": false,
   "parent": "root"
 }

This flag is a part of the --write-info-json section where video metadata gets saved to the JSON file too. If you only want the video comments add --no-write-info-json.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago