在指定 ChannelID 之外搜索 API 调用 Returns 结果

Search API Call Returns Results Outside The Specified ChannelID

我有一个仅限于特定频道的 YT API 搜索查询,但 returns 结果在该频道之外,这是一个问题。

对此进行全面搜索https://developers.google.com/youtube/v3/docs/search/list 已完成以下请求。

https://content.googleapis.com/youtube/v3/search?part=snippet&channelId=UCoMurV7497Rj7kk5i-UXUhg&q=%E0%A4%A4%E0%A4%B5%E0%A4%BE&key={你的密钥}

需要说明的是,'q' 参数是印地语,翻译为“तवा”

结果中有些项目不是来自请求中 channelId 指定的频道。这似乎是 YT API.

中的错误

200

我不能确定它是否是错误,但是,由于 q 参数及其值,您从不同的渠道获得结果 - 这就是预期的功能。

q参数搜索也在description of the video.

因此,如果您想在请求中排除来自其他渠道的结果,您可以这样做:

  • 如果您确实需要添加搜索词,请添加它并添加您的频道名称。

示例:

q=तवा + SkillTrain

您可以在此 demo at Google API Explorer.

中测试此请求

结果如下:

{
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "id": {
    "kind": "youtube#video",
    "videoId": "GfNUaVFmxaY"
   },
   "snippet": {
    "channelId": "UCoMurV7497Rj7kk5i-UXUhg",
    "title": "Introduction to Plumbing Tools (Part-1) (Hindi) (हिन्दी)"
   }
  }
 ]
}

在这种情况下,有一个结果与您的 channel_id 和提供的印地语字符都匹配。

  • 如果您不需要添加搜索参数,请在请求中省略它,(因为您添加了 channel_id 值),一旦发出请求,您将得到以下结果:

{
 "nextPageToken": "CAUQAA",
 "pageInfo": {
  "totalResults": 666,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "id": {
    "kind": "youtube#video",
    "videoId": "td3GPjcXPb4"
   },
   "snippet": {
    "channelId": "UCoMurV7497Rj7kk5i-UXUhg",
    "title": "Basic components of a window AC (Hindi) (हिन्दी)"
   }
  },
  {
   "kind": "youtube#searchResult",
   "id": {
    "kind": "youtube#video",
    "videoId": "e611N5gR1z4"
   },
   "snippet": {
    "channelId": "UCoMurV7497Rj7kk5i-UXUhg",
    "title": "Wheel balancing (Hindi) (हिन्दी)"
   }
  },
  {
   "kind": "youtube#searchResult",
   "id": {
    "kind": "youtube#video",
    "videoId": "XCitxJ-jvgQ"
   },
   "snippet": {
    "channelId": "UCoMurV7497Rj7kk5i-UXUhg",
    "title": "Auto Clave (Hindi) (हिन्दी)"
   }
  },
  {
   "kind": "youtube#searchResult",
   "id": {
    "kind": "youtube#video",
    "videoId": "8zHSEv_tziQ"
   },
   "snippet": {
    "channelId": "UCoMurV7497Rj7kk5i-UXUhg",
    "title": "Understanding the components of a split AC (Hindi) (हिन्दी)"
   }
  },
  {
   "kind": "youtube#searchResult",
   "id": {
    "kind": "youtube#video",
    "videoId": "WQ8X3hDIwJM"
   },
   "snippet": {
    "channelId": "UCoMurV7497Rj7kk5i-UXUhg",
    "title": "Brake pad replacement (Hindi)(हिन्दी)"
   }
  }
 ]
}

所有这些结果均来自提供的channel_id

您可以在此 demo at Google API Explorer.

中测试此请求