Hi
I want to display Categort Name also
StringBuilder htmlTable = new StringBuilder();
List listVideo = new List();
var client = new RestClient("googleapis.com/youtube/v3");
var request = new RestRequest("search", Method.GET);
request.AddParameter("part", "snippet");
request.AddParameter("q", "short video");
request.AddParameter("type", "video");
request.AddParameter("videoDefinition", "standard");
request.AddParameter("videoDuration", "short");
request.AddParameter("type", "video");
request.AddParameter("order", "viewCount");
request.AddParameter("sortOrder", "desc");
request.AddParameter("key", "ApiKey");
var response = client.Execute(request);
htmlTable.Append("");
htmlTable.Append("SN Channel Id Channel Title Video Title Description Tags Views Published ");
htmlTable.Append("");
Int32 ViewCount = 0;
foreach (var data in response.Data.items)
{
var clientTag0 = new RestClient("googleapis.com/youtube/v3/");
var tagRequest0 = new RestRequest("videos", Method.GET);
tagRequest0.AddParameter("key", "ApiKey");
tagRequest0.AddParameter("part", "snippet,statistics");
tagRequest0.AddParameter("id", data.id.videoId);
var tagResponse0 = clientTag0.Execute(tagRequest0);
foreach (var searchResult in tagResponse0.Data.items)
{
listVideo.Add(searchResult);
}
}
if (listVideo.Any())
{
var orderByVideosCount = listVideo.OrderByDescending(x => x.statistics.viewCount);
foreach (var item in orderByVideosCount)
{
Thanks
4 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.
Naimish MakwanaPosted Feb 18, 2023, 2:58 PM
Hello Ramco,
Please correct API URL
Thanks
Naimish Makwana
Jignesh KumarPosted Feb 19, 2023, 5:07 AM
Hello Ramco,
Please refer this one, Once you get tag response you can follow below link,
https://stackoverflow.com/questions/11238183/how-to-get-category-name-in-youtube-api-in-asp-net4-0-application
Ramco RamcoPosted Feb 18, 2023, 1:43 PM
Hi Naimish
I have below code but it is not going in If condition
Thanks
Naimish MakwanaPosted Feb 18, 2023, 8:28 AM
Hello Ramco,
To display category name you want to use videoCategories api as below
VideoCategoryListResponse class
Then you can get like this:
Thanks
Naimish Makwana