你必须得到channel_id您要从中获取数据的视频。
要使用video_id 获取channel_id,您可以使用YouTube 数据API 的videos:list 端点-example。
结果:
{
"kind": "youtube#videoListResponse",
"etag": "y1Zw7S-E_fPwC_hzp3fsJ7l0OCw",
"items": [
{
"kind": "youtube#video",
"etag": "_1mzRopd5kh5bzsX66yES1K3i9g",
"id": "wauQivFuVhw",
"snippet": {
"publishedAt": "2018-07-26T02:10:16Z",
"channelId": "UCNpFcllBHQk9wepKzMtouSQ",
"title": "La bohème",
"description": "Provided to YouTube by Universal Music Group\n\nLa bohème · Kendji Girac\n\nAznavour, sa jeunesse\n\n℗ 2014 Island Def Jam\n\nReleased on: 2014-01-01\n\nAssociated Performer, Interprète Vocal, Guitar: Kendji Girac\nAssociated Performer, Programming, Keyboards: Christian Dessart\nAssociated Performer, Keyboards, Programming: Rachid Mir\nStudio Personnel, Recording Engineer: Nabil Essemlani\nStudio Personnel, Asst. Recording Engineer: Antonin Deniaud\nProducer, Studio Personnel, Mixer: The Bionix\nStudio Personnel, Mastering Engineer: Eric Chevet\nAuthor: Jacques Plante\nComposer: Charles Aznavour\n\nAuto-generated by YouTube.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/wauQivFuVhw/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/wauQivFuVhw/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/wauQivFuVhw/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/wauQivFuVhw/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/wauQivFuVhw/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Kendji Girac - Topic",
"tags": [
"Kendji Girac KendjiGirac Aznavour",
"sa jeunesse La bohème La Boheme La Boheme"
],
"categoryId": "10",
"liveBroadcastContent": "none",
"localized": {
"title": "La bohème",
"description": "Provided to YouTube by Universal Music Group\n\nLa bohème · Kendji Girac\n\nAznavour, sa jeunesse\n\n℗ 2014 Island Def Jam\n\nReleased on: 2014-01-01\n\nAssociated Performer, Interprète Vocal, Guitar: Kendji Girac\nAssociated Performer, Programming, Keyboards: Christian Dessart\nAssociated Performer, Keyboards, Programming: Rachid Mir\nStudio Personnel, Recording Engineer: Nabil Essemlani\nStudio Personnel, Asst. Recording Engineer: Antonin Deniaud\nProducer, Studio Personnel, Mixer: The Bionix\nStudio Personnel, Mastering Engineer: Eric Chevet\nAuthor: Jacques Plante\nComposer: Charles Aznavour\n\nAuto-generated by YouTube."
}
}
}
],
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
}
}
在这种情况下,channel_id视频wauQivFuVhw 是:UCNpFcllBHQk9wepKzMtouSQ.
那么,有了这个channel_id, 将第二个字符更改为U如下:
- 未修改:UCNpFcllBHQk9wepKzMtouSQ
- 修改:üüNpFcllBHQk9wepKzMtouSQ
这个修改后的 id 是上传该 YouTube 频道的播放列表。
有了这个上传 playlist_id,您可以使用 YouTube 数据 API 的 Playlistitem:list 端点从自动生成的频道中检索所有上传的视频。
这是the example,其中包含此答案中描述的上传 playlist_id。