Find non-english channels in YouTube API

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 12:10:43

问题


I'm trying to find Dutch YouTube channels using the YouTube api v3. I've found a Dutch guide category 'Aanbevolen' (recommended) with ID = 'GCRmVhdHVyZWQ'.

When I call the channels resource I get English result. I expected Dutch results because I've selected a Dutch guide category.

What am I missing?

YouTubeService service = new YouTubeService(new BaseClientService.Initializer() { ApplicationName = "MyApp", ApiKey = "[mykey]" });
ChannelsResource.ListRequest resource = new ChannelsResource.ListRequest(service, "id,snippet");
resource.CategoryId = "GCRmVhdHVyZWQ";
resource.MaxResults = 50;

ChannelListResponse result;
result = resource.Execute();

回答1:


Searching the YouTube guide categories (which are auto generated) lets you specify a language and a region code; however, that doesn't mean that the results have anything to do with the language of the channels. Rather, it is an indicator of whether or not particular categories are available in a particular country (and the category titles are just translated based on the language parameter). In other words, if you do a guideCategories search with the regionCode parameter set to NL, you'll get back all of the categories that are authorized to be shown in the Netherlands. You'll get back the same category ID regardless of the region code, since that category id is just the generic "Featured on YouTube" category.

So this basically a misunderstanding of how the guideCategories endpoint works.

There's not currently a way to get channels from a particular region or in a particular language, but there's a pretty good method for getting videos from a particular region (which may lead you to channels, obviously). The videos->list endpoint has the chart parameter that you can set to "mostPopular," which then also plays off the regionCode and videoCategory parameters, to return the most popular videos for a particular region in a particular category (note that video categories are different than guide categories, in that users can set their own video categories). For example, a URL like this:

https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&regionCode=NL&videoCategoryId=17&key={YOUR_API_KEY}

Will return the most popular sports videos (since category 17 is the category for "sports") in the Netherlands. I'll leave it to you to translate that endpoint into the right object methods for the c# client.

Also note that you can get all the video categories available to a region in a way similar to how one might get guide categories:

https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&hl=nl&regionCode=NL&key={YOUR_API_KEY}


来源:https://stackoverflow.com/questions/24432430/find-non-english-channels-in-youtube-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!