Youtube api v3无法从频道中检索所有视频

时间:2016-05-05 01:35:34

标签: video youtube youtube-api youtube-channels

我正在尝试使用youtube data api从频道获取所有视频。但它并不适用于特定频道。 (它适用于其他几个频道。)

从截图中可以看出,此频道有135个视频。

enter image description here

但是,我使用了播放列表并搜索api,如下所示。他们只返回9个视频。这里有什么问题?感谢。

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=UUhTMiw43iw4w-ggOEXmPtfg&key={YOUR_API_KEY} 

GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UChTMiw43iw4w-ggOEXmPtfg&maxResults=50&type=video&key={YOUR_API_KEY}

1 个答案:

答案 0 :(得分:0)

基本上,您正在使用相同的title处理两个不同的渠道,但这是可以接受的,因为customUrl有所不同,请在此处进行详细说明:

1。 DharmaYogaCenter:UChTMiw43iw4w-ggOEXmPtfg-标题:DharmaYogaCenter

GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UChTMiw43iw4w-ggOEXmPtfg&key={YOUR_API_KEY}

``` json 
{
    "title": "DharmaYogaCenter",
    "description": "We are a full yoga center located in Bremerton Washington.  We believe yoga and meditation is for everyone.  Stop by our Yoga Center and enjoy a blissful meditation, yoga class or just some good community.  We offer many free classes every month.  www.dharmayogacenter.net",
    "customUrl": "DharmaYogaCenter",
    "publishedAt": "2009-06-11T21:43:56.000Z",
    ...
    "relatedPlaylists": {
     "uploads": "UChTMiw43iw4w-ggOEXmPtfg",
    ...
    "videoCount": "9"
    ...
```

您可以在此处查看仅有几部视频:uploaded videos in channel UC8hnoz74NP5V5sxkuxXk2kA

“ youtube#channel” "id": UChTMiw43iw4w-ggOEXmPtfg

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UChTMiw43iw4w-ggOEXmPtfg&key={YOUR_API_KEY} 获取频道的"uploads": "UUhTMiw43iw4w-ggOEXmPtfg"

的播放列表ID

上传播放列表:UUhTMiw43iw4w-ggOEXmPtfg“ totalResults”:9

获取https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=UUhTMiw43iw4w-ggOEXmPtfg&key= {YOUR_API_KEY}

{
 "kind": "youtube#playlistItemListResponse",
 "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/yvjEzYc-CE8RBoXkFDTMPf_O1XM\"",
 "pageInfo": {
  "totalResults": 9,
  "resultsPerPage": 50
 },...

2。 TheDharmaTube:UC8hnoz74NP5V5sxkuxXk2kA-标题:DharmaYogaCenter

GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UC8hnoz74NP5V5sxkuxXk2kA&key={YOUR_API_KEY}

{ 
    "title": "DharmaYogaCenter",
    "description": "Be receptive",
    "customUrl": "TheDharmaTube",
    "publishedAt": "2011-02-24T22:54:31.000Z",
    ...
    "relatedPlaylists": {
     "uploads": "UU8hnoz74NP5V5sxkuxXk2kA",
    ...
    "videoCount": "142"

您可以在此处检查更多视频:uploaded videos in channel UC8hnoz74NP5V5sxkuxXk2kA ..打开后向下滚动以加载所有视频

“ youtube#channel” "id": UC8hnoz74NP5V5sxkuxXk2kA

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UC8hnoz74NP5V5sxkuxXk2kA&key={YOUR_API_KEY} 获取频道的"uploads": "UU8hnoz74NP5V5sxkuxXk2kA"

的播放列表ID

上传播放列表:UU8hnoz74NP5V5sxkuxXk2kA“ totalResults”:142

获取https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=UU8hnoz74NP5V5sxkuxXk2kA&key= {YOUR_API_KEY} “ totalResults”:142,

{
 "kind": "youtube#playlistItemListResponse",
 "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/jm3DhRxnqdMzu1DGtIoiLbpEFY4\"",
 "nextPageToken": "CDIQAA",
 "pageInfo": {
  "totalResults": 142,
  "resultsPerPage": 50
 },...