Hi
In a youtube video i have below search items . I want to get displayed them in a column separated by comma.
#afgvpng
georgina rodriguez
Below is my code
C#
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("type", "video");
request.AddParameter("maxResults", 100);
request.AddParameter("sortOrder", "desc");
request.AddParameter("key", "AIzaSyCFG8");
var response = client.Execute(request);
htmlTable.Append("");
htmlTable.Append("SNChannel Id / TitleVideo TitleDescriptionCategoryView 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", "AIzaSG8");
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())Thanks

Uday DodiyaRank #239 · 10.3K reputationPosted Jun 15, 2024, 7:19 AM EDT
To modify your existing code to display the search items separated by commas in a column, you can add the code that concatenates these items into a single string and then inserts this string into your HTML table. Below is the updated version of your code:
List listVideo = new List(); var client = new RestClient("https://www.googleapis.com/youtube/v3"); var request = new RestRequest("search", Method.GET); request.AddParameter("part", "snippet"); request.AddParameter("type", "video"); request.AddParameter("maxResults", 100); request.AddParameter("q", "#afgvpng,georgina rodriguez"); // Adding search terms here request.AddParameter("key", "YOUR_API_KEY"); // Replace with your actual API key var response = client.Execute(request); StringBuilder htmlTable = new StringBuilder(); htmlTable.Append(""); htmlTable.Append("SNChannel Id / TitleVideo TitleDescriptionCategoryView CountPublishedSearch Terms"); htmlTable.Append(""); Int32 ViewCount = 0; int sn = 1; foreach (var data in response.Data.items) { var clientTag0 = new RestClient("https://www.googleapis.com/youtube/v3/"); var tagRequest0 = new RestRequest("videos", Method.GET); tagRequest0.AddParameter("key", "YOUR_API_KEY"); // Replace with your actual API key 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()) { foreach (var video in listVideo) { htmlTable.Append(""); htmlTable.Append($"{sn++}"); htmlTable.Append($"{video.snippet.channelId} / {video.snippet.channelTitle}"); htmlTable.Append($"{video.snippet.title}"); htmlTable.Append($"{video.snippet.description}"); htmlTable.Append($"{video.snippet.categoryId}"); htmlTable.Append($"{video.statistics.viewCount}"); htmlTable.Append($"{video.snippet.publishedAt}"); htmlTable.Append("#afgvpng, georgina rodriguez"); // Adding search terms in the new column htmlTable.Append(""); } } htmlTable.Append(""); // Output the HTML table string result = htmlTable.ToString(); Console.WriteLine(result);Key modifications:
qparameter of the initial request to the YouTube Data API.Search Terms in the HTML table.#afgvpng, georgina rodriguezas a static string in each row of the table.Ramco RamcoRank #462 · 5.4K reputationPosted Jun 15, 2024, 10:04 AM EDT
Hi Udhay
These 2 provided are for sample i want all Search Items of my video to be displayed in 1 text box
Thanks