How to Extract all YouTube Comments and Comment Replies from a Playlist

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ธ.ค. 2024

ความคิดเห็น • 68

  • @awokenspirit6338
    @awokenspirit6338 2 หลายเดือนก่อน +1

    OMG... This just saved me potentially hours, days, weeks, etc. Was literally like meh even if I spend the next couple of hours trying to figure out a way to copy the 17,000 comments ( not nested ) I need from this 1 video for my project & it doesn't work out, I will still be better off considering my pc can only load like 10 comments when scrolling per second & then it crashes after like max 1000. YOU ARE AN ABSOLUTE LIFESAVER & if I wasn't so goddamn broke I would genuinely tip you heavy for this. Thanks brother!

  • @DmitriZhilyaev-n2c
    @DmitriZhilyaev-n2c 10 หลายเดือนก่อน +3

    Man thank you very much! Your code really helps me with my bachelors degree! It is my second day with these codes and you really did a good job for a rookie me!

  • @tteemmzz
    @tteemmzz 7 หลายเดือนก่อน +2

    You're such a blessing.
    I spent ages trying to figure out how to extract comments on a topic on Twitter.
    I recently thought about extracting comments from a TH-cam video about that topic and came across your video.
    Thank you so so much.

    • @analyticswithadam
      @analyticswithadam  7 หลายเดือนก่อน +3

      Its one of the only free places left because everyone is cutting off access to their API due to LLM projects scraping the data. Glad you found it useful. 👍

  • @carlosrivas1104
    @carlosrivas1104 6 หลายเดือนก่อน

    Thank you a lot with this video, you saved me with a university project, after the page X blocked the API for all of us, thank you a lot

    • @analyticswithadam
      @analyticswithadam  6 หลายเดือนก่อน

      No worries , it’s hard to get api data these days

  • @firecloud77
    @firecloud77 4 หลายเดือนก่อน

    Wowsers. This went right over my head. It assumes lots of prerequisite knowledge.

    • @analyticswithadam
      @analyticswithadam  4 หลายเดือนก่อน

      There were a couple of video before this. Also I have provided the code so essentially all you need to do is change the playlist ID and it should work

  • @user-xnr
    @user-xnr 5 หลายเดือนก่อน +1

    Man thanks a ton for this bro. Great stuff. Didn't realize it was this easy

  • @thomashelm7307
    @thomashelm7307 8 หลายเดือนก่อน

    interesting. I think it would take me a bit to fully understand how to do this. Is there a program or something out there to scan all that data and find keywords, or most found phrases etc... or would you just filter in excel to find such data?

  • @JwalinBhatt
    @JwalinBhatt 10 หลายเดือนก่อน +1

    Do you know if it is possible that the number of replies shown in the browser doesnt match with the number of comments fetched using the API? I am trying to get comments to a specific video and the number of comments I receive are 5-6 more than what is shown in the browser. My theory is that since youtube hides certain comments (such as ones contains urls), so those are not shown in the browser but the API can still access it. I still need to test it.

    • @ecqmjr
      @ecqmjr 8 หลายเดือนก่อน

      did you ever try by yourself, like adding some spam things from your accounts and then see whether they seem in api but don't in browser ui?

    • @JwalinBhatt
      @JwalinBhatt 8 หลายเดือนก่อน

      @@ecqmjrNo I havent, but what even would be such things?

    • @ecqmjr
      @ecqmjr 8 หลายเดือนก่อน

      @@JwalinBhatt I don't know, I perceive some specific things when it comes to spams, like url sharing or comments indicating use this app and earn money fast etc. but if you were able to see the comments appearing in api but don't seem in ui, I think you should have experienced what is defined as spam by youtube.

    • @ecqmjr
      @ecqmjr 8 หลายเดือนก่อน

      I have a project in my mind to start, if I encounter the situation you mentioned and find out earlier what may be the reason, I'll keep you updated here

    • @JwalinBhatt
      @JwalinBhatt 8 หลายเดือนก่อน

      @@ecqmjr hmm yeah that could be the reason. That would be nice, I'll look forward to hearing back from you. Thanks Dan 👍🏼

  • @pablolastnameless6964
    @pablolastnameless6964 5 หลายเดือนก่อน

    Hey, do you know a way to find all the videos with the phrase written in the comments like "this is the best song ever"? thank you

    • @analyticswithadam
      @analyticswithadam  5 หลายเดือนก่อน +1

      You could if you limited it to specific channels but you can’t do a general search as you can only take down 10k comments at a time

  • @depffff3124
    @depffff3124 3 วันที่ผ่านมา

    thanks so much, let me try

  • @prachisharma444
    @prachisharma444 8 หลายเดือนก่อน +2

    You are truly amazing! Thankyou so much.

  • @Mk2SoLDiEr
    @Mk2SoLDiEr 5 หลายเดือนก่อน

    Thank you, it works well.
    It doesn't however handle the scenario of a playlist containing a video marked as "private".
    Can't post the error log here on YT :(

  • @selinoruc5642
    @selinoruc5642 2 หลายเดือนก่อน

    Hello, thank you for the great informative video. I will need to extract about 4 million comments from a video. Do you think it would be possible on my local computer with this code?
    I am currently trying but taking a lot of time for sure.

    • @analyticswithadam
      @analyticswithadam  2 หลายเดือนก่อน +1

      Should be throw me the link for the video I’d be interested in testing the limits

    • @selinoruc5642
      @selinoruc5642 หลายเดือนก่อน

      @@analyticswithadam th-cam.com/video/kJQP7kiw5Fk/w-d-xo.html
      th-cam.com/video/RgKAFK5djSk/w-d-xo.html

    • @selinoruc5642
      @selinoruc5642 หลายเดือนก่อน

      @@analyticswithadam or i could get partially but i dont know how to set a number or range

    • @selinoruc5642
      @selinoruc5642 หลายเดือนก่อน

      i guess i cannot share the link despacito and see you again official song videos

  • @hiduptenangdiriku
    @hiduptenangdiriku 6 หลายเดือนก่อน +1

    thanks man, it's really work, have a nice day :)

  • @RonalRomeroVergel
    @RonalRomeroVergel 7 หลายเดือนก่อน +1

    Man it works only for a video??

    • @analyticswithadam
      @analyticswithadam  7 หลายเดือนก่อน

      For a number of playlists

    • @RonalRomeroVergel
      @RonalRomeroVergel 7 หลายเดือนก่อน +1

      @@analyticswithadam no worries, in around 15 minutes chat gpt create me a code to get all the comments from a video, i used a youtube api and everything works correct thanks for the video and the idea

    • @emaa786
      @emaa786 6 หลายเดือนก่อน

      ​@@RonalRomeroVergelhellooooo listen

  • @jamasq
    @jamasq หลายเดือนก่อน

    مشكلة ملفات csv لا تعرض جميع التعليقات وايضا لا تعرضها اصلا لا يظهر سوى حروف مقطعة ورموز
    ولا يظهر سوى اخر ٢٠٠ خانة
    اتمنى لو يرجعون ملف html ، افضل من هذا

    • @analyticswithadam
      @analyticswithadam  หลายเดือนก่อน

      Try the method in this video
      Not the Gemini part just the retrieving comments part… This should come out correct in the Google sheet with all the symbols intact
      How to Extract TH-cam comments in sheets and analyse with AI with 1 click
      th-cam.com/video/1KwFFb_tofY/w-d-xo.html

  • @JwalinBhatt
    @JwalinBhatt 10 หลายเดือนก่อน

    Thanks a lot for the video, is there a way we can know how long it is going to take for the code to get all comments. Something like a tqdm? The infinite while loop makes things tricky but maybe you can find a way :)

    • @analyticswithadam
      @analyticswithadam  10 หลายเดือนก่อน +1

      Its not a infinite loop its executes while they is a next page of comments on the videos chosen from the playlist. Tricky to count how many that is from the outset.

    • @JwalinBhatt
      @JwalinBhatt 10 หลายเดือนก่อน

      @@analyticswithadam Of course yes that's what I meant, the terminating condition is within the inf loop coz we dont know when it will end. But thanks anyway :)

  • @ilianos
    @ilianos 6 หลายเดือนก่อน

    Great content! I have 2 questions:
    1. Will this work on YT shorts as well?
    2. What's the limit/quota for the free TH-cam API, something like 10,000 comments per day?

    • @analyticswithadam
      @analyticswithadam  6 หลายเดือนก่อน

      10000 requests I believe. 1 request per video covers. Should work for shorts too

    • @gabrielcroquer7399
      @gabrielcroquer7399 5 หลายเดือนก่อน

      @@analyticswithadam Hi! Thanks for the video. Does it have a 100 comment limit per request? I'm trying to get more than 100 comments and can't do it.

    • @Lyreck
      @Lyreck หลายเดือนก่อน

      @@gabrielcroquer7399 I'm having the same issue. Looks like it's capped at 100 comments... :-(

  • @Mrkux145
    @Mrkux145 7 หลายเดือนก่อน

    Can I also use this for single videos?

  • @julianebrito5788
    @julianebrito5788 3 หลายเดือนก่อน

    Hi from Brazil, I loved the video. I would really like to know how to extract it from the TH-cam chat

  • @triyanti6556
    @triyanti6556 5 หลายเดือนก่อน

    i dont have gogle cloud, dont ways again?

    • @analyticswithadam
      @analyticswithadam  5 หลายเดือนก่อน

      It’s free to use the api you just need to login to Google cloud w gmail

  • @Adrian-zo8uk
    @Adrian-zo8uk 6 หลายเดือนก่อน

    thanks it is really helpful 😘

  • @trilogen
    @trilogen 6 หลายเดือนก่อน

    How to do it for just a video and not a playlist?

    • @analyticswithadam
      @analyticswithadam  6 หลายเดือนก่อน +1

      Put the video in a playlist

    • @coscomosco4388
      @coscomosco4388 6 หลายเดือนก่อน

      @@analyticswithadam Even I did the same

    • @rrc012
      @rrc012 6 หลายเดือนก่อน

      I tweaked the code to retrieve comments and replies just from a single video. To keep things simple, I am just using the side effect aka print function to get the comments and replies and I am not writing them to a csv.
      All credit goes to @analyticswithadam.
      PS: The indentation might have got corrupted. Fix the indentation if you were to grab a copy of the modified code from below.
      from googleapiclient.discovery import build
      API_KEY = "Replace with your own API Key here"
      # Get the Video Id
      video_id = input("VideoId: ")
      # Build the TH-cam client
      youtube = build('youtube', 'v3', developerKey=API_KEY)
      # Function to get replies for a specific comment
      def get_replies(youtube, parent_id, video_id): # Added video_id as an argument
      replies = []
      next_page_token = None
      while True:
      reply_request = youtube.comments().list(
      part="snippet",
      parentId=parent_id,
      textFormat="plainText",
      maxResults=100,
      pageToken=next_page_token
      )
      reply_response = reply_request.execute()
      for item in reply_response['items']:
      comment = item['snippet']
      replies.append({
      'Timestamp': comment['publishedAt'],
      'Username': comment['authorDisplayName'],
      'VideoID': video_id,
      'Comment': comment['textDisplay'],
      'Date': comment['updatedAt'] if 'updatedAt' in comment else comment['publishedAt']
      })
      next_page_token = reply_response.get('nextPageToken')
      if not next_page_token:
      break
      return replies
      # Function to get all comments (including replies) for a single video
      def get_comments_for_video(youtube, video_id):
      all_comments = []
      next_page_token = None
      while True:
      comment_request = youtube.commentThreads().list(
      part="snippet",
      videoId=video_id,
      pageToken=next_page_token,
      textFormat="plainText",
      maxResults=100
      )
      comment_response = comment_request.execute()
      for item in comment_response['items']:
      top_comment = item['snippet']['topLevelComment']['snippet']
      all_comments.append({
      'Timestamp': top_comment['publishedAt'],
      'Username': top_comment['authorDisplayName'],
      'VideoID': video_id, # Directly using video_id from function parameter
      'Comment': top_comment['textDisplay'],
      'Date': top_comment['updatedAt'] if 'updatedAt' in top_comment else top_comment['publishedAt']
      })
      # Fetch replies if there are any
      if item['snippet']['totalReplyCount'] > 0:
      all_comments.extend(get_replies(youtube, item['snippet']['topLevelComment']['id'], video_id))
      next_page_token = comment_response.get('nextPageToken')
      if not next_page_token:
      break
      return all_comments
      # List to hold all comments from all videos
      all_comments = []
      video_comments = get_comments_for_video(youtube, video_id)
      all_comments.extend(video_comments)
      for _ in all_comments:
      print(_["Comment"])

    • @emaa786
      @emaa786 6 หลายเดือนก่อน

      Hello

    • @emaa786
      @emaa786 6 หลายเดือนก่อน

      ​@@rrc012I need your help can u help me

  • @artificialintelligence584
    @artificialintelligence584 6 หลายเดือนก่อน

    ✅ Perfect

  • @shaasar5818
    @shaasar5818 7 หลายเดือนก่อน

    u r amazing😍, but can u suggest me how to retrieve all comments just for one video

    • @analyticswithadam
      @analyticswithadam  7 หลายเดือนก่อน

      Make your own playlist with one video and you can follow the script here

    • @player-xm9qm
      @player-xm9qm 6 วันที่ผ่านมา

      @@analyticswithadam I can't create a playlist because I want to analyze the comments of a single video with millions of views from a third party. It doesn't have a playlist, it has 1 isolated video, I wanted to export the comments from these videos, I can't create a playlist.

    • @analyticswithadam
      @analyticswithadam  6 วันที่ผ่านมา

      @@player-xm9qm Try this method in Sheets.
      Leave you the gemini bit.
      th-cam.com/video/1KwFFb_tofY/w-d-xo.html