Click here to Skip to main content
15,888,195 members
Please Sign up or sign in to vote.
1.18/5 (3 votes)
See more:
I am writing a code to read all the comments on a youtube video. My code just read the first 25 comments. I need help to read all the comments from a youtube video!! (ASP .NET-C#)
Here is my code that read only first 25 comments:

MIDL
appName = "testApp";
       settings = new YouTubeRequestSettings(appName, devKey);
       request = new YouTubeRequest(settings);
       videoEntryUri = new Uri("http://gdata.youtube.com/feeds/api/videos?q=22O5QnSLdeE");

       vid= request.Retrieve<Video>(videoEntryUri);
       comments = request.GetComments(vid);


        Response.Write(vid.ResponseUri);
       Response.Write("Total Number of comment on the video:"+vid.CommmentCount);
       Response.Write("<br>Total number of comment getting throug feed: " + comments.TotalResults);
       int counter = 1;

        //<gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/8aYQ_wjmxiQ/comments' countHint='0'
        Response.Write("<table width='450' border='1'>");
        foreach ( Comment c in comments.Entries)
        {

            Response.Write("<tr><td>" + c.Author + "</td><td>" + c.Updated.Date + "</td></tr>");
            Response.Write("<tr><td colspan='2'>"+c.Content+"</td></tr>");
            counter++;
       }
      Response.Write("</table>");
      Response.Write("Total Number of Comment Display: "+counter);
    }
}
Posted

How about setting Settings.Maximum to a larger number!?
Try it.

Or iterate using start-index in i*25 + 1 from i=0 upto the countHint found in feed (here 361).
 
Share this answer
 
You can also use an alternative Youtube Data API:

Comments: list  |  YouTube Data API  |  Google Developers[^]
 
Share this answer
 
Comments
Richard Deeming 17-Jan-22 5:53am    
Chances are the API will have been completely rewritten in the 11 years since the question was posted!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900