【问题标题】:Youtube api not found videoYoutube api 未找到视频
【发布时间】:2020-07-24 20:49:48
【问题描述】:

我正在尝试使用 API 在 yuotube 上查找视频“Desposito”。 2017年1月13日发布,查询字符串如下:

https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&order=viewCount&publishedAfter=2017-01-13T00%3A00%3A00.000Z&publishedBefore=2017-01-13T23%3A59%3A00.000Z&key=[YOUR_API_KEY]

但回复中不包含我需要的视频。我做错了什么?

【问题讨论】:

  • q=desposito 添加到您的搜索参数中可能会有所帮助。您可能还需要调整时间参数以考虑时区差异;例如,墨西哥城 1 月 13 日晚上 10 点在您的搜索窗口之外。 (而且,为了挑剔,您当前的参数不包括一天中的最后 59 秒。)
  • 即使我把 - 2 天和 + 2 天,结果是一样的。我的意思是 API 无法正常工作。

标签: youtube-api youtube-data-api google-apis-explorer


【解决方案1】:

您想要的视频不在搜索结果的第一页。使用搜索参数对其进行限制。

这很好用:

https://www.googleapis.com/youtube/v3/search?q=desposito&part=snippet&maxResults=1&order=viewCount&publishedAfter=2017-01-13T00%3A00%3A00.000Z&publishedBefore=2017-01-13T23%3A59%3A00.000Z&key=[API_KEY]

回复:

{
 "kind": "youtube#searchListResponse",
 "etag": "\"tnVOtk4NeGU6nDncDTE5m9SmuHc/RpayhI7uhEMSDFk9CHdtyV62vi0\"",
 "nextPageToken": "CAEQAA",
 "regionCode": "US",
 "pageInfo": {
  "totalResults": 356,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"tnVOtk4NeGU6nDncDTE5m9SmuHc/3g-rbj2UgHGdPTC1Nk7zLAWtTHU\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "kJQP7kiw5Fk"
   },
   "snippet": {
    "publishedAt": "2017-01-13T05:00:02.000Z",
    "channelId": "UCLp8RBhQHu9wSsq62j_Md6A",
    "title": "Luis Fonsi - Despacito ft. Daddy Yankee",
    "description": "Despacito” disponible ya en todas las plataformas digitales: https://UMLE.lnk.to/DOoUzFp “Imposible” disponible ya en todas las plataformas digitales: ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/kJQP7kiw5Fk/default.jpg",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/kJQP7kiw5Fk/mqdefault.jpg",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "https://i.ytimg.com/vi/kJQP7kiw5Fk/hqdefault.jpg",
      "width": 480,
      "height": 360
     }
    },
    "channelTitle": "LuisFonsiVEVO",
    "liveBroadcastContent": "none"
   }
  }
 ]
}

【讨论】:

  • 我不是想找到这个特定的视频。我想获得当天观看次数最多的视频。这个视频是“Desposito”。但是 API 没有为任何搜索参数找到它。我不需要使用“q=desposito”参数。逻辑上认为,如果我们使用“order=viewCount”参数,我们将在响应中将其排在第一位。但这不会发生。
猜你喜欢
  • 2017-09-13
  • 1970-01-01
  • 2017-04-26
  • 2014-07-06
  • 1970-01-01
  • 2015-07-22
  • 2012-07-02
  • 2012-05-06
  • 1970-01-01
相关资源
最近更新 更多