Ramco Ramco

Ramco Ramco

  • 435
  • 3.4k
  • 554.7k

No of subscribes in a video

Jan 5 2025 4:41 AM

Hi

  I want no of subscribers also in the video

StringBuilder htmlTable = new StringBuilder();

var client = new RestClient("googleapis.com/youtube/v3");
var request = new RestRequest("search", Method.GET);
request.AddParameter("part", "snippet");

request.AddParameter("type", "video");
request.AddParameter("channelId", "UCg3Zm_nNoaVw");
request.AddParameter("key", "AIzaSyAu9f5blF7idzt6cGul59UQ9b5Ls8ECFG8");

List<YoutubeSearchItem> allItems = new List<YoutubeSearchItem>();

IRestResponse<YoutubeSearchListResponse> response = client.Execute<YoutubeSearchListResponse>(request);


htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>");
htmlTable.Append("<thead><tr><th>Video Id</th><th>Video Title</th><th>Description</th></tr></thead>");
htmlTable.Append("<tbody>");

foreach (var data in allItems.OrderBy(x => x.snippet.publishedAt))
{
    var clientTag = new RestClient("googleapis.com/youtube/v3/");
    var tagRequest = new RestRequest("videos", Method.GET);
    tagRequest.AddParameter("key", "AIzaSyAu9FG8");
    tagRequest.AddParameter("part", "snippet,statistics");
    tagRequest.AddParameter("id", data.id.videoId);
    var tagResponse = clientTag.Execute<VideoListResponse>(tagRequest);

    foreach (var item in tagResponse.Data.items)
    {
        htmlTable.Append("<td><a hef='youtube.com/watch?v=" + data.id.videoId + "'>" + data.snippet.title + "</a></td>");
        htmlTable.Append("<td >" + item.snippet.title + "</td>");
        htmlTable.Append("<td >" + item.snippet.description + "</td>");


        htmlTable.Append("</tr>");
    }
}
htmlTable.Append("</tbody>");
htmlTable.Append("</table>");
PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() });

Thanks


Answers (1)