Hi
In below code i want to display Tags also. Secondly in Shorts i want to display which are shown like this -
public void ShortVideos() { Int32 Count = 1; StringBuilder htmlTable = new StringBuilder(); List<VideoListResponse.Item> listVideo = new List<VideoListResponse.Item>(); 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<YoutubeSearchListResponse>(request); htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>"); htmlTable.Append("<thead><tr><th>SN</th><th>Channel Id / Title</th><th>Video Title</th><th>Description</th><th>View Count</th><th>Published</th></tr></thead>"); htmlTable.Append("<tbody>"); 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<VideoListResponse>(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("<td>" + Count.ToString() + "</td>"); htmlTable.Append("<td >" + item.snippet.channelId + " - " + item.snippet.channelTitle + "</td>"); htmlTable.Append("<td><a hef='youtube.com/watch?v=" + item.id + "'>" + item.snippet.title + "</a></td>"); htmlTable.Append("<td >" + item.snippet.description + "</td>"); htmlTable.Append("<td >" + item.statistics.viewCount + "</td>"); htmlTable.Append("<td >" + item.snippet.publishedAt + "</td>"); htmlTable.Append("</tr>"); Count++; } } htmlTable.Append("</tbody>"); htmlTable.Append("</table>"); PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() }); //} }
Thanks