Youtube API v3数据.搜索返回相同的值



我试图在regionCode的基础上获取不同的youtube频道。

试图获取印度youtube频道:

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

试图获取马来西亚youtube频道:

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"
   }
  }
 ]
}

提前感谢。

来自文档:

regionCode - (string) regionCode参数指示API返回指定国家/地区的搜索结果。参数值为anISO 3166-1 alpha-2国家代码

看起来,指定regionCode返回的搜索结果就好像你在那个国家一样,而不是与那个国家相关的视频/频道。例如,如果您指定CN (China)作为区域代码,您将无法获得在中国被阻止的视频的结果。

似乎没有好的方法来获取属于某个特定国家的所有频道。您可以做的是使用指定的搜索条件执行search.list()并设置type=Channel。然后,根据响应向channels.list()发出请求以获取国家,并比较它是否来自该特定国家。这是相当低效的,当我试着测试一种类似的方法时,我发现我可以在频道的"关于"部分设置我的国家。但是,由于该字段是可选的,因此不能保证用户确实为他们的频道设置了该字段,因此最终很难获得您要查找的信息。

相关内容

  • 没有找到相关文章

最新更新