Jump to content
JohnLM

Youtube comments - how are you retreaving them

Recommended Posts

I was wondering. . . 

 

Is there any apps (for Windows) that can retrieve all comments from a given Youtube video ?
And how quickly can it be received ?
And, has anyone used it or uses it currently ?

 

I've been wanting to download or extract Youtube comments for a number of purposes. 

 

What I'm looking for is how *fast* can comment's be retrieved, not how to do it myself.   I've written a few code snippets to pull it once I have a video in view and it can be very tedious, especially when there are replies and when the comments are in the thousands.  And sometimes I can't read them on screen because there are too many and/or I run out of memory or something.  I'm wondering how people are doing it without issues and how fast they can pull thousands. 

Share this post


Link to post

Use the Youtube API.

 

uses
  System.Net.HttpClient, System.JSON;

procedure GetYouTubeComments(const VideoID, APIKey: string);
var
  Client: TNetHTTPClient;
  Response: string;
  JSON: TJSONObject;
begin
  Client := TNetHTTPClient.Create(nil);
  try
    Response := Client.Get(
      Format('https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=%s&key=%s', [VideoID, APIKey])
    ).ContentAsString;
    
    JSON := TJSONObject.ParseJSONValue(Response) as TJSONObject;
    // Parse JSON to extract comments
  finally
    Client.Free;
  end;
end;

 

Share this post


Link to post

Thanks, but I am also already using the YT API.  I have been using it for years but thought there was an even faster way of obtaining the larger comments listing.  I guess what I am already using is the fastest then, only I am not using JSON.  I am just manually parsing the json response because I am accustom to doing that way and json is not easy for me. 

 

I was originally using a web scrapper method but it was tedious when there were hundreds or more of comments.   And when I learned about the YT API, I started using that but I couldn't figure out how to obtain more than the 100 item limit, so I went back to using the scrapper and made various updates to it whenever I had time to fine-tune it.   But years later I had figured it out how to use the YT API to go past the 100 item limit and started using it--see image below. 

 

1753199019_im-praxisforum-ytcommentretriever-xe7vclscreenshot.png.3356ed78d86e191354e20cb1aec7dfea.png

Share this post


Link to post
1 hour ago, JohnLM said:

I guess what I am already using is the fastest then, only I am not using JSON.  I am just manually parsing the json response

So, is your parsing "slow" or the fetching the API data from Youtube?

How did you do the parsing? By running through the Memo of your screenshot?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×