Search API调用返回指定ChannelID之外的结果

时间:2019-02-06 15:22:12

标签: youtube-data-api

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

仔细研究了此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

  • 显示标题-

    { "kind": "youtube#searchListResponse", "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/hJ1ihb5XsXgS7tq9QigswU-SsUg\"", "regionCode": "US", "pageInfo": { "totalResults": 4, "resultsPerPage": 5 }, "items": [ { "kind": "youtube#searchResult", "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/9R-AWbPk35j_zGJcL7wemicat9g\"", "id": { "kind": "youtube#video", "videoId": "GfNUaVFmxaY" }, "snippet": { "publishedAt": "2014-05-26T11:16:17.000Z", "channelId": "UCoMurV7497Rj7kk5i-UXUhg", "title": "Introduction to Plumbing Tools (Part-1) (Hindi) (हिन्दी)", "description": "This video will help you understand plumbing tools. इस पाठ में आप नल साजी (प्ल्म्बींग) में इस्तेमाल होनेवाल...", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/GfNUaVFmxaY/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/GfNUaVFmxaY/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/GfNUaVFmxaY/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "SkillTrain", "liveBroadcastContent": "none" } }, { "kind": "youtube#searchResult", "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/kcnTk-acx88HM9_HoWokq8FRONI\"", "id": { "kind": "youtube#video", "videoId": "swmvPyzi_3c" }, "snippet": { "publishedAt": "2017-12-23T15:00:06.000Z", "channelId": "UCH4Bz5Swatl5iHSuCT_Hlxg", "title": "पैन: जंगली के महान भगवान - (ग्रीक पौराणिक कथाओं में बताया)", "description": "आज हम कम देवताओं में से एक है और मेरे पसंदीदा में से एक पर एक नज़र डालें, जंगली के परमेश्वर पैन। आप पौराणिक कथाओं और लोक-साहित्य का आनंद लें और अधिक जानने के लिए चाहते हैं।", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/swmvPyzi_3c/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/swmvPyzi_3c/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/swmvPyzi_3c/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "Mythology & Fiction Explained", "liveBroadcastContent": "none" } }, { "kind": "youtube#searchResult", "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/qE49UjY2s7xfzQc3lgM2V2089Cs\"", "id": { "kind": "youtube#video", "videoId": "tjW1mKwNUSo" }, "snippet": { "publishedAt": "2014-11-25T17:00:03.000Z", "channelId": "UCjmJDM5pRKbUlVIzDYYWb6g", "title": "पान - आधिकारिक टीज़र ट्रेलर [HD]", "description": "ह्यूग जैकमैन, गैरेट Hedlund, रूनी मारा और पैन में लेवी मिलर स्टार, थिएटर में 9 वीं अक्टूबर! http://www.pan-movie.com/ ...", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/tjW1mKwNUSo/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/tjW1mKwNUSo/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/tjW1mKwNUSo/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "Warner Bros. Pictures", "liveBroadcastContent": "none" } }, { "kind": "youtube#searchResult", "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/-zDpouVDxXZOX5hD6tlEcP9BeEM\"", "id": { "kind": "youtube#video", "videoId": "vjGM6eLR5ZE" }, "snippet": { "publishedAt": "2017-12-10T05:52:59.000Z", "channelId": "UCOvw0-6WFFEMr__v4mFonxQ", "title": "गोकू खो पान | अंग्रेजी डब", "description": "जबकि गोकू, पिकोलो, और Chichi उसे खोजने की कोशिश पान पुलाव के साथ एक साहसिक है। #ड्रेगन बॉल सुपर।", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/vjGM6eLR5ZE/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/vjGM6eLR5ZE/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/vjGM6eLR5ZE/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "GOT-two", "liveBroadcastContent": "none" } } ] }

1 个答案:

答案 0 :(得分:0)

我无法确定它是否是错误,但是由于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中测试此请求。