Advertisement
Jexal

Download the Comments of a YouTube Video with yt-dlp

Nov 5th, 2024 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. """Use this to grab the comments with a video:
  2. yt-dlp --write-comments <Insert Video's URL>"""
  3. ---------------------------------------------------------------------------------------------------------------------------------------
  4. """The comments.json file created by yt-dlp contains comments in JSON format, which is a structured way to store data. You can read and process this file using Python. Here’s a simple script to read and display the comments:
  5.  
  6. Install the json library if you haven't already (it's included in the Python standard library, so you don't need to install anything extra).
  7.  
  8. Read and display the comments using this script:
  9. import json"""
  10.  
  11. # Open and read the comments file
  12. with open('comments.json', 'r', encoding='utf-8') as file:
  13.     comments_data = json.load(file)
  14.  
  15. # Extract and display the comments
  16. for comment in comments_data['comments']:
  17.     print(f"Author: {comment['author']}")
  18.     print(f"Comment: {comment['text']}\n")
  19.  
  20. """See the following for more information:
  21. https://www.reddit.com/r/youtubedl/comments/rom9q4/is_there_a_way_to_download_the_youtube_comments/
  22. https://www.reddit.com/r/youtubedl/comments/1966cnt/asking_how_to_download_comments_youtube_in_the/"""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement