问题描述
我目前正在学习 youtube api
的使用.我想从 channel id
中检索所有 playlists id
.我通读了文档,发现我可以使用 youtube.channels.list
来完成这样的任务.我对 api_page 进行了基本测试.尽管如此,我还是无法确定使用什么 params
来获取 playlist id
.如何从给定的 channel id
中检索所有 playlist ids
?
I am currently learning the use of the youtube api
. I want to retrieve all playlists id
from a channel id
. I read through the documentation and saw that I can use youtube.channels.list
for such task. I did basic testing on the api_page. Still, I am not able to figure what params
to use to get the playlist id
. How can I retrieve all playlist ids
from a given channel id
?
https://www.googleapis.com/youtube/v3/channels?part=id&id=UCF0pVplsI8R5kcAqgtoRqoA&key={YOUR_API_KEY}
推荐答案
一个简单的方法:
使用 YouTube API v3 和资源 playlists.list
使用此参数获取频道的播放列表 ID:
Use this parameters to get the playlists ID of a channel :
part: 'snippet'
channelId: 'UCBkNpeyvBO2TdPGVC_PsPUA'
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCBkNpeyvBO2TdPGVC_PsPUA&key={YOUR_API_KEY}
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCBkNpeyvBO2TdPGVC_PsPUA&key={YOUR_API_KEY}
输出:
"items": [
{
"kind": "youtube#playlist",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/K21sgPQuMRCjhSMBjm3v3n5tl1o\"",
"id": "PL2qcutlDmS0CnyV8Jcbl2d7yFxd2iGg67",
"snippet": {
"publishedAt": "2014-07-08T03:13:37.000Z",
"channelId": "UCBkNpeyvBO2TdPGVC_PsPUA",
"title": "These Things Happen Series",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "GEazyTV"
}
},
{
"kind": "youtube#playlist",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/5ifuvTYKbyV6DUPqbTa2bnO2jWY\"",
"id": "PL2qcutlDmS0B0jwHOQYzgRhJpnxDwPBHc",
"snippet": {
"publishedAt": "2014-06-05T07:36:58.000Z",
"channelId": "UCBkNpeyvBO2TdPGVC_PsPUA",
"title": "B-Sides",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "GEazyTV"
}
},
...
这是一个带有随机通道的示例.
This is a sample example with a random channel.
如果您不知道如何获取频道的 channelID,请使用 ressource channels.list:
If you don't know how to get the channelID of a channel use ressource channels.list:
使用此参数获取播放列表的视频 ID:
With this parameters to get the video ID of a playlist :
part: 'id'
forUsername: 'channel_name'
https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=GEazyTV&key={YOUR_API_KEY}
https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=GEazyTV&key={YOUR_API_KEY}
"items": [
{
"kind": "youtube#channel",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/vIwM6ev74Om0AOupX26jJoEDELU\"",
"id": "UCBkNpeyvBO2TdPGVC_PsPUA"
}
这篇关于从频道 ID 获取所有播放列表 ID - youtube api v3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!