Hi
I have below code and i want that it should display all Videos. It displays only 50 videos
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", "UCg3-m_nNoaVw");
request.AddParameter("key", " AIzaSs8ECFG8");
var response = client.Execute(request);
var orderByPublishAt = response.Data.items.OrderBy(x => x.snippet.publishedAt);
htmlTable.Append("");
htmlTable.Append("Video Id Video Title Description Views Like Comment Published ");
htmlTable.Append("");
foreach (var data in orderByPublishAt)
{
var clientTag = new RestClient("googleapis.com/youtube/v3/");
var tagRequest = new RestRequest("videos", Method.GET);
tagRequest.AddParameter("key", "AIzaSs8ECFG8");
tagRequest.AddParameter("part", "snippet,statistics");
tagRequest.AddParameter("id", data.id.videoId);
var tagResponse = clientTag.Execute(tagRequest);
foreach (var item in tagResponse.Data.items)
{
htmlTable.Append("" + item.snippet.title + " ");
htmlTable.Append("" + item.snippet.description + " ");
htmlTable.Append("");
}
}
htmlTable.Append(" ");
});
}
Thanks
7 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramco RamcoPosted Apr 30, 2024, 5:10 AM
Hi Jignesh
On below line it is giving error : Cannot convert from system.collection.generic.list to System.Collections.Generic.IEnumerable
allItems.AddRange(response.Data.items);
Thanks
Jignesh KumarPosted Apr 30, 2024, 4:54 AM
you need to create one class to hold all result.
Ramco RamcoPosted Apr 30, 2024, 4:25 AM
Hi Jignesh
I am getting this error - The type or namespace name YoutubeSearchItem could not be found.
List allItems = new List();
Thanks
Jignesh KumarPosted Apr 30, 2024, 3:50 AM
Hello Ramco,
Please use this one,
Ramco RamcoPosted Apr 29, 2024, 1:18 PM
Hi Jignesh
Can u pls help with my code where i should do the changes since i have 2 loops
Thanks
Jignesh KumarPosted Apr 29, 2024, 12:46 PM
Hello Ramco,
please use this one to get all videos bye removing defaul pagetoken.
Jithu ThomasPosted Apr 29, 2024, 12:36 PM
maxResultsparameter to your initial search request. This specifies the number of videos returned per page (default is 50). You can increase this value, but keep it within reasonable limits.nextPageTokenproperty. This token allows you to request the next page of results.nextPageTokenuntil you reach the desired number of videos or there are no more pages.Here follows a sample sinppet