gpt4 book ai didi

youtube - Youtube API v3 data.search返回相同的值

转载 作者:行者123 更新时间:2023-12-03 05:57:42 25 4
gpt4 key购买 nike

我试图根据regionCode获取不同的YouTube channel 。

尝试获取印度YouTube channel :

https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&regionCode=IN&maxResults=5&key={API_KEY}

尝试获取马来西亚YouTube channel :
https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&regionCode=MY&maxResults=5&key={API_KEY}

对于这两个请求,我都得到相同的结果。为什么会这样呢?
{
"kind": "youtube#searchListResponse",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/EiqwT6pG1EkwVEl17s1_qudvkmk\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/smpwgLdS9Og11NhpzRYcy37a9V8\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCrFiA0hztL9e8zTi_qBuW4w"
},
"snippet": {
"publishedAt": "2013-03-19T20:35:41.000Z",
"channelId": "UCrFiA0hztL9e8zTi_qBuW4w",
"title": "EeOneGuy",
"description": "Просто делаю ролики =)",
"thumbnails": {
"default": {
"url": "https://lh6.googleusercontent.com/-ZPtgaY_lFDY/AAAAAAAAAAI/AAAAAAAAAAA/U_8gJcnIMiE/photo.jpg"
},
"medium": {
"url": "https://lh6.googleusercontent.com/-ZPtgaY_lFDY/AAAAAAAAAAI/AAAAAAAAAAA/U_8gJcnIMiE/photo.jpg"
},
"high": {
"url": "https://lh6.googleusercontent.com/-ZPtgaY_lFDY/AAAAAAAAAAI/AAAAAAAAAAA/U_8gJcnIMiE/photo.jpg"
}
},
"channelTitle": "EeOneGuy",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/g4m9Kno2zbU7BMIEUbffxDlyvZI\"",
"id": {
"kind": "youtube#channel",
"channelId": "UC7MO7ngSqsBcvQvxNf-kpWg"
},
"snippet": {
"publishedAt": "2013-06-04T17:39:49.000Z",
"channelId": "UC7MO7ngSqsBcvQvxNf-kpWg",
"title": "The Right to Research Coalition",
"description": "The Right to Research Coalition is a coalition of 80 undergraduate and graduate student organisations from across the world. Together we educate and ...",
"thumbnails": {
"default": {
"url": "https://lh5.googleusercontent.com/-p0RT2XiO3_0/AAAAAAAAAAI/AAAAAAAAAAA/tdAJTswPnB0/photo.jpg"
},
"medium": {
"url": "https://lh5.googleusercontent.com/-p0RT2XiO3_0/AAAAAAAAAAI/AAAAAAAAAAA/tdAJTswPnB0/photo.jpg"
},
"high": {
"url": "https://lh5.googleusercontent.com/-p0RT2XiO3_0/AAAAAAAAAAI/AAAAAAAAAAA/tdAJTswPnB0/photo.jpg"
}
},
"channelTitle": "R2RCvideo",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/nWC7qhbPZRH0qyEBOcWdFR8TI5k\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCmSSq5573Ru9asXsXykgqTw"
},
"snippet": {
"publishedAt": "2014-10-12T02:26:56.000Z",
"channelId": "UCmSSq5573Ru9asXsXykgqTw",
"title": "Toys Games TV",
"description": "Welcome to Toys Games TV Channel! Looking for a safe channel for your kids? Look no further, on TGTV we review primarily Disney, PBS & Sprout character ...",
"thumbnails": {
"default": {
"url": "https://lh3.googleusercontent.com/-5qqjMUWhRow/AAAAAAAAAAI/AAAAAAAAAAA/2la9IA5DNhU/photo.jpg"
},
"medium": {
"url": "https://lh3.googleusercontent.com/-5qqjMUWhRow/AAAAAAAAAAI/AAAAAAAAAAA/2la9IA5DNhU/photo.jpg"
},
"high": {
"url": "https://lh3.googleusercontent.com/-5qqjMUWhRow/AAAAAAAAAAI/AAAAAAAAAAA/2la9IA5DNhU/photo.jpg"
}
},
"channelTitle": "ToysGamesTV",
"liveBroadcastContent": "upcoming"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/enqEI6qDr8UfYcjixI9Cjpd6SU0\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCtjLPHCyI5V-xuumAXzAizA"
},
"snippet": {
"publishedAt": "2008-06-05T04:13:13.000Z",
"channelId": "UCtjLPHCyI5V-xuumAXzAizA",
"title": "UNUChannel",
"description": "Channel produced by the United Nations University (UNU). The overarching goal of the United Nations University is to contribute to global sustainable ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/i/tjLPHCyI5V-xuumAXzAizA/1.jpg"
},
"medium": {
"url": "https://i.ytimg.com/i/tjLPHCyI5V-xuumAXzAizA/mq1.jpg"
},
"high": {
"url": "https://i.ytimg.com/i/tjLPHCyI5V-xuumAXzAizA/hq1.jpg"
}
},
"channelTitle": "UNUChannel",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/44t2atyjsxpSOVj7OfeK9GTfy0M\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCJ7-0_cR9HiA9iX8n3kugcg"
},
"snippet": {
"publishedAt": "2010-06-29T15:08:02.000Z",
"channelId": "UCJ7-0_cR9HiA9iX8n3kugcg",
"title": "Naturhistoriska riksmuseet",
"description": "Naturhistoriska riksmuseets och Cosmonovas YouTube-kanal.",
"thumbnails": {
"default": {
"url": "https://lh5.googleusercontent.com/-OItSjQXSj_c/AAAAAAAAAAI/AAAAAAAAAAA/ybdmiik-0eA/photo.jpg"
},
"medium": {
"url": "https://lh5.googleusercontent.com/-OItSjQXSj_c/AAAAAAAAAAI/AAAAAAAAAAA/ybdmiik-0eA/photo.jpg"
},
"high": {
"url": "https://lh5.googleusercontent.com/-OItSjQXSj_c/AAAAAAAAAAI/AAAAAAAAAAA/ybdmiik-0eA/photo.jpg"
}
},
"channelTitle": "SthlmNaturhistoriska",
"liveBroadcastContent": "none"
}
}
]
}

提前致谢。任何帮助将非常感激。

最佳答案

documentation:

regionCode - (string) The regionCode parameter instructs the API to return search results for the specified country. The parameter value is an ISO 3166-1 alpha-2 country code.



好像指定regionCode一样,返回的搜索结果就像您在该国家/地区一样,而不是与该国家/地区相关的视频/ channel 。例如,如果您将CN(中国)指定为区域代码,则不会获得在中国被屏蔽的视频的结果。

似乎没有一种好的方法来获取属于特定国家/地区的所有 channel 。您可以根据指定的搜索条件执行search.list()并设置 type=Channel。然后,根据响应,对channels.list()发出请求以获取国家/地区,并进行比较以查看该国家/地区是否来自该特定国家/地区。这效率很低,在尝试测试类似的方式时,我发现可以在 channel 的“关于”部分中设置国家/地区。但是,由于该字段是可选的,因此不能保证用户实际上是为其 channel 设置的,因此最终您很难获得所需的信息。

关于youtube - Youtube API v3 data.search返回相同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31643030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com