Hi
In below code i want to display Tags also. Secondly in Shorts i want to display which are shown like this - 
C#
public void ShortVideos()
{
Int32 Count = 1;
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("videoDuration", "short");
var today = DateTime.Now.Date;
var sevenDaysAgo = today.AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ssZ");
request.AddParameter("publishedAfter", sevenDaysAgo);
request.AddParameter("type", "video");
request.AddParameter("maxResults", 50);
request.AddParameter("order", "viewCount");
request.AddParameter("sortOrder", "desc");
request.AddParameter("key", "ApiKey");
var response = client.Execute(request);
htmlTable.Append("");
htmlTable.Append("SNChannel Id / TitleVideo TitleDescriptionView CountPublished");
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)
{
htmlTable.Append("" + Count.ToString() + "");
htmlTable.Append("" + item.snippet.channelId + " - " + item.snippet.channelTitle + "");
htmlTable.Append("" + item.snippet.title + "");
htmlTable.Append("" + item.snippet.description + "");
htmlTable.Append("" + item.statistics.viewCount + "");
htmlTable.Append("" + item.snippet.publishedAt + "");
htmlTable.Append("");
Count++;
}
}
htmlTable.Append("");
htmlTable.Append("");
PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() });
//}
}Thanks

Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 20, 2023, 7:22 AM EST
Hello Ramco,
To add tags use below code.
if (listVideo.Any()) { var orderByVideosCount = listVideo.OrderByDescending(x => x.statistics.viewCount); foreach (var item in orderByVideosCount) { htmlTable.Append("" + Count.ToString() + ""); htmlTable.Append("" + item.snippet.channelId + " - " + item.snippet.channelTitle + ""); htmlTable.Append("" + item.snippet.title + ""); htmlTable.Append("" + item.snippet.description + ""); if (item.snippet.tags != null && item.snippet.tags.Any()) { //Format with HTML code Console.WriteLine("Tags ==>" + String.Join(",", item.snippet.tags)); } htmlTable.Append("" + item.statistics.viewCount + ""); htmlTable.Append("" + item.snippet.publishedAt + ""); htmlTable.Append(""); Count++; } }Thanks
Naimish Makwana
Ramco RamcoRank #462 · 5.4K reputationPosted Feb 20, 2023, 7:25 AM EST
Hi Naimish
Secondly i want to display only those shorts which i have mentioned. Is there any change in code to be done
Thanks
Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 20, 2023, 7:24 AM EST
For shorts video
Replace
request.AddParameter("q", "short video");To
request.AddParameter("q", "shorts");Ramco RamcoRank #462 · 5.4K reputationPosted Feb 20, 2023, 7:33 AM EST
Hi Naimish
It displays such videos - https://www.youtube.com/watch?v=NJaXTvPRAtw . I want
Thanks
Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 20, 2023, 7:48 AM EST
Can you give the url of that kind of videos?
Ramco RamcoRank #462 · 5.4K reputationPosted Feb 20, 2023, 8:12 AM EST
Hi Naimish
I have done that but it displays video like below though it is also short - https://www.youtube.com/watch?v=NJaXTvPRAtw
I want to display only those which have Shorts sign like above
Thanks
Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 20, 2023, 10:22 AM EST
Hello Ramco,
I think based on Shorts sign we might not get the videos.
Thanks
Naimish