YouTube API v3按频道Id搜索,不返回频道中的所有视频

YouTube API v3按频道Id搜索,不返回频道中的所有视频,youtube,youtube-api,Youtube,Youtube Api,请参见以下YouTube频道: 它包含8个视频。但是,下面的请求仅返回5个视频(即使maxResults设置为10) https://www.googleapis.com/youtube/v3/search?safeSearch=none&order=title&part=snippet&channelId=UCqiwZNUf9z9OrseJoVGWMMg&type=video&maxResults=10&key={YOUR_API_KEY}

请参见以下YouTube频道:

它包含8个视频。但是,下面的请求仅返回5个视频(即使maxResults设置为10)

https://www.googleapis.com/youtube/v3/search?safeSearch=none&order=title&part=snippet&channelId=UCqiwZNUf9z9OrseJoVGWMMg&type=video&maxResults=10&key={YOUR_API_KEY}
您可以在JSON响应的第一部分中看到,
totalResults
仅为5,而不是预期的8

{
 "kind": "youtube#searchListResponse",
 "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/MhPawf_XoAn1dq-tgkkE4aPpbD0\"",
 "pageInfo": {
  "totalResults": 5,
  "resultsPerPage": 10
 },
...
响应中的items数组仅包含5项。我尝试了多种查询(包括关闭safeSearch),但它不会返回频道中的所有视频。

以下请求:

https://www.googleapis.com/youtube/v3/search?order=title&part=snippet&channelId=UCqiwZNUf9z9OrseJoVGWMMg&type=video&maxResults=10&key={YOUR_API_KEY}
我得到了以下结果:

 {
 "kind": "youtube#searchListResponse",
 "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/8i-meJV39_yfRucbNqwGwygIReU\"",
 "pageInfo": {
  "totalResults": 8,
  "resultsPerPage": 10
 }
据我所知,这与您发布的内容相同唯一的区别是我尝试了它,没有指定safesearch参数,但正如您在返回的项目列表中所看到的,它为我返回了频道上的所有视频。我不确定API为什么会在您身上出现错误,但它应该会给出正确的结果。希望我能对您有所帮助h

注:我也尝试过使用safesearch参数。我得到了你的结果(5个视频)中的“严格”和“无”值,但它给了我所有你一直在寻找的8个视频中的“中等”值,我假设这是默认值,因为它与我没有指定参数时得到的结果相同

 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/DlNXovOlstICaTGq9kp43GR9eBU\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "pcorjQxfwoA"
   },
   "snippet": {
    "publishedAt": "2015-04-08T16:59:38.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "EBB Retrofit Animation",
    "description": "This animation shows what is involved in completing a seismic retrofit on a house with a raised foundation and a 4 foot cripple wall.",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/pcorjQxfwoA/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/pcorjQxfwoA/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/pcorjQxfwoA/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/0KLoeBTh2PYOW5CwXmq4Yzxhc-8\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "RV1IzHmSojI"
   },
   "snippet": {
    "publishedAt": "2015-04-08T17:00:17.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "EBB Retrofit HD",
    "description": "Watch Earthquake Brace + Bolt in action.",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/RV1IzHmSojI/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/RV1IzHmSojI/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/RV1IzHmSojI/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/x74SevHlVYKeMKmn3O9Toaa33Lg\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "stpSa2rIbS8"
   },
   "snippet": {
    "publishedAt": "2015-04-08T17:33:29.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "FEMA Training Part 2",
    "description": "This video introduces the effect of earthquakes on houses, discusses past performance of houses in earthquakes, and introduces partial seismic rehabilitation...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/stpSa2rIbS8/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/stpSa2rIbS8/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/stpSa2rIbS8/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/7sTYIalNOCQ6jn9X4VBCMphFzbk\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "jYll7dENSOo"
   },
   "snippet": {
    "publishedAt": "2015-04-08T17:23:02.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "FEMA Training Part 6",
    "description": "This video provides a brief overview of important concepts for identifying the load path in a structure, construction of shear walls, and correctly installin...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/jYll7dENSOo/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/jYll7dENSOo/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/jYll7dENSOo/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/GyHVsiWjC3smdvRyhqM7k9TSAL4\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "KHNx0SluNBA"
   },
   "snippet": {
    "publishedAt": "2015-04-08T17:16:18.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "FEMA Training Part 4",
    "description": "This video clarifies that seismic rehabilitation work falls under the purview of the building code and building department, and gives a brief overview of code ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/KHNx0SluNBA/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/KHNx0SluNBA/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/KHNx0SluNBA/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/qJoVONxqCG32ExIyXSOYwxgT4Q4\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "iaS1wIIrXbA"
   },
   "snippet": {
    "publishedAt": "2015-04-08T17:07:42.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "FEMA Training Part 1",
    "description": "This video introduces the training course, defines applicable terminology, and shows pictorially why seismic rehabilitation of houses is important.",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/iaS1wIIrXbA/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/iaS1wIIrXbA/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/iaS1wIIrXbA/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/Ps3HC7X95sTlZ-sR3ZP3lHYhQSM\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "0hQpBJJofcs"
   },
   "snippet": {
    "publishedAt": "2015-04-08T17:31:56.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "FEMA Training Part 5",
    "description": "This video addresses application of prescriptive provisions for anchorage to foundation and cripple wall bracing contained in the International Existing Building ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/0hQpBJJofcs/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/0hQpBJJofcs/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/0hQpBJJofcs/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/F1VbW4J8TYbRDZuDeotUfWoBi9M\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "OLclXnCQD2k"
   },
   "snippet": {
    "publishedAt": "2015-04-08T17:12:49.000Z",
    "channelId": "UCqiwZNUf9z9OrseJoVGWMMg",
    "title": "FEMA Training Part 3",
    "description": "This video is the heart of the training course, introducing seismic vulnerabilities 'A through K' discussing how to identify vulnerable conditions, likely ea...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/OLclXnCQD2k/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/OLclXnCQD2k/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/OLclXnCQD2k/hqdefault.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  }
 ]
}

奇怪。我使用了与您完全相同的查询,但仍然只有5个结果。我想说,可能他们已经缓存了我的API密钥或其他内容的结果。感谢您查看它!在按channelId搜索和按日期排序时,有时我也会有不同的结果。我知道,例如,对于某个频道,本周有视频,但确实如此一分钟后,同样的搜索只会给出至少一周前的结果。非常奇怪,也不容易复制。