Youtube api v3 无法从频道中检索所有视频
Posted
技术标签:
【中文标题】Youtube api v3 无法从频道中检索所有视频【英文标题】:Youtube api v3 cannot retrieve all videos from a channel 【发布时间】:2016-08-30 16:02:01 【问题描述】:我正在尝试使用 youtube 数据 api 从频道获取所有视频。但它不适用于特定频道。 (它适用于其他几个频道。)
从截图可以看出,这个频道有 135 个视频。
但是,我使用了播放列表项和搜索 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
【问题讨论】:
似乎 channel.list 返回了 channelId=UChTMiw43iw4w-ggOEXmPtfg。但是,当我使用 videos.list 检查未包含的视频时,相应的 channelId=UC8hnoz74NP5V5sxkuxXk2kA。真是一场灾难…… 检查这个 SO 问题YouTube API v3 - List uploaded videos 如果它可以帮助你;) 你可以在这里参考我的答案:***.com/questions/25607356/… 【参考方案1】:基本上,您正在处理具有相同title
的两个不同频道,但这是可以接受的,因为customUrl
s 不同,这里有详细信息:
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
GET 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 “总结果”:142,
"kind": "youtube#playlistItemListResponse",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/jm3DhRxnqdMzu1DGtIoiLbpEFY4\"",
"nextPageToken": "CDIQAA",
"pageInfo":
"totalResults": 142,
"resultsPerPage": 50
,...
【讨论】:
以上是关于Youtube api v3 无法从频道中检索所有视频的主要内容,如果未能解决你的问题,请参考以下文章
如何从 Youtube API V3 中检索经过验证的频道?
youtube api v3 从比视频更新的频道中获取所有视频
如何在 YouTube API v3 上检索“频道中的频道”