Ramco Ramco

Ramco Ramco

  • 437
  • 3.4k
  • 542.1k

How to get Category Name

Feb 18 2023 8:01 AM

Hi

  I want to display Categort Name also

            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("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<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</th><th>Channel Title</th><th>Video Title</th><th>Description</th><th>Tags</th><th>Views</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)
                    {

Thanks


Answers (4)