Hi
I have below code and i want to get list of Long Videos only.
C#
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", 400);
request.AddParameter("channelId", "UCg3ZpKSJDTGSgG-m_nNoDVw");
request.AddParameter("key", "AIzaSyAu9fJSRSKSGRYS5Ls8ECFG8");Thanks

Jignesh KumarRank #91 · 22.9K reputationPosted Apr 29, 2024, 7:21 AM EDT
You can add "videoDuration" parameter to filter only long vedios from search,
long– Only include videos longer than 20 minutes.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("videoDuration", "long"); request.AddParameter("maxResults", 400); request.AddParameter("channelId", "UCg3ZpKSJDTGSgG-m_nNoDVw"); request.AddParameter("key", "AIzaSyAu9fJSRSKSGRYS5Ls8ECFG8");Ramco RamcoRank #462 · 5.4K reputationPosted Apr 29, 2024, 7:33 AM EDT
Hi Jignesh
I have written the above code but it is not working still displaying all records
Thanks
Jignesh KumarRank #91 · 22.9K reputationPosted Apr 29, 2024, 7:53 AM EDT
Could you please share your resposne data sample here?
The above code should work as expected and it will return videos time duration more than 20 minutes
Ramco RamcoRank #462 · 5.4K reputationPosted Apr 29, 2024, 7:59 AM EDT
Hi Jignesh
Below is the data returned
{ "kind": "youtube#searchListResponse", "etag": "O4a77wwBkkshjshdsKHSFPoFqE0", "nextPageToken": "CDIQAA", "regionCode": "IN", "pageInfo": { "totalResults": 358, "resultsPerPage": 50 }, "items": [ { "kind": "youtube#searchResult", "etag": "O4a77wwBkkshjshdsKHSFPoFqE0", "id": { "kind": "youtube#video", "videoId": "4fmU78KCc" }, "snippet": { "publishedAt": "2023-11-25T01:15:00Z", "channelId": "UCg3ZpkQBQ3GngG-m_nNoaVw", "title": " with his Fam!??\u200d??\u200d??\u200d?? #georginagio #futbol #ronaldo #messi", "description": "Georgina Rodriguez en familia #Messi #football #ronaldotiktok #mbappe ...", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/4fmh78KCc/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/4fmh78KCc/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/4fmh78KCc/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "#Tech", "liveBroadcastContent": "none", "publishTime": "2023-11-25T01:15:00Z" } },Thanks
Jignesh KumarRank #91 · 22.9K reputationPosted Apr 29, 2024, 8:19 AM EDT
Have you checked return list vedios are less than 2o mins. ?
Ramco RamcoRank #462 · 5.4K reputationPosted Apr 29, 2024, 8:35 AM EDT
Hi Jignesh
When i add this line it returns no record
request.AddParameter("videoDuration", "long");
Thanks
Jignesh KumarRank #91 · 22.9K reputationPosted Apr 29, 2024, 8:40 AM EDT
Hello Ramco,
There is no video on that channel that has a duration of more than 20 minutes. Please check with other channel IDs.
Ramco RamcoRank #462 · 5.4K reputationPosted Apr 29, 2024, 9:02 AM EDT
Hi Jignesh
Can't we get on basis of size whether it is 9X16 or 16X9
Thanks
Jignesh KumarRank #91 · 22.9K reputationPosted Apr 29, 2024, 11:54 PM EDT
@ramco, no we can not get by size, you need to check the YouTube API document for that if it is possible or not.
you can refer developer document for Parmeter to filter your response.
https://developers.google.com/youtube/v3/docs/search/list