gpt4 book ai didi

youtube-api - 如何使用 YouTube V3 API 获取所有电影(不是视频)

转载 作者:行者123 更新时间:2023-12-05 01:48:22 26 4
gpt4 key购买 nike

我想列出 YouTube 上所有可用的电影(即通过//youtube.com/movies 可用的电影)。我可以看到如何使用 API V2 查询那些,但这有 1000 个响应的限制。

通过 V3 api,我可以看到电影类别的 ID 为 30,但我不知道如何获取该类别的所有电影。唯一的类别查询似乎是在不同的指南类别上搜索。

关于如何获得此列表的任何线索?如果可以,请帮忙!

最佳答案

我相信您可以获得与电影相关的自动生成的 channel ,并使用它们的 ID 来获取与该 channel 相关的播放列表,最后从该播放列表中获取项目(视频..),这必须是与所选 channel 的电影:

检索电影 channel :

请求

https://www.googleapis.com/youtube/v3/search?part=snippet&q=movies&type=channel&key={YOUR_API_KEY}

部分回应

"items": [
{
"id": {
"kind": "youtube#channel",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ"
},
"kind": "youtube#searchResult",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/sQpwXP-0MUEZzOQx4F0yKj0eUR4\"",
"snippet": {
"publishedAt": "2005-12-15T03:07:36.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "movies",
"description": "YouTube Movies (United States).",
"thumbnails": {
"default": {
"url": "http://i.ytimg.com/i/czhp4wznQWonO7Pb8HQ2MQ/1.jpg"
},
"medium": {
"url": "http://i.ytimg.com/i/czhp4wznQWonO7Pb8HQ2MQ/mq1.jpg"
},
"high": {
"url": "http://i.ytimg.com/i/czhp4wznQWonO7Pb8HQ2MQ/hq1.jpg"
}
}
}
},

例如获取 channel “YouTube 电影(美国)”中的电影列表

请求

https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCczhp4wznQWonO7Pb8HQ2MQ&key={YOUR_API_KEY}

部分响应:

{

"id": "PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C",
"kind": "youtube#playlist",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/TWrkoCkmJvq14neCcutnApHMMgU\"",
"snippet": {
"publishedAt": "2012-12-06T20:11:40.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "The Nicolas Cage Collection",
"description": "From panicked fathers to spirits of vengeance, Nicolas Cage has done it all.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/hqdefault.jpg"
}
}
}
},

从此播放列表中获取项目:

要求:

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C&key={YOUR_API_KEY}

部分响应:

{
"kind": "youtube#playlistItemListResponse",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/KSlqEnNGq36l47_k9W3fd79KfYQ\"",
"pageInfo": {
"totalResults": 15,
"resultsPerPage": 5
},
"nextPageToken": "CAUQAA",
"items": [
{

"id": "PLcBtbpFAOApiV34TU797yEFAUZuwhFrvJya3MqlZWkGM",
"kind": "youtube#playlistItem",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/C_xTa48Xof7giXobSula2vWX43A\"",
"snippet": {
"publishedAt": "2012-12-06T20:12:49.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "Stolen",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/hqdefault.jpg"
}
},
"playlistId": "PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "nHiy8SVZdpU"
}
}
},
{

"id": "PLcBtbpFAOApiV34TU797yED-1zeMCoMGVxtVgtX9ZdsQ",
"kind": "youtube#playlistItem",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/LgSyqtZkwJXv6-2ajW0g-FsgddQ\"",
"snippet": {
"publishedAt": "2012-12-06T20:19:26.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "Trespass",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/J_7Zug6ouy4/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/J_7Zug6ouy4/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/J_7Zug6ouy4/hqdefault.jpg"
}
},
"playlistId": "PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C",
"position": 1,
"resourceId": {
"kind": "youtube#video",
"videoId": "J_7Zug6ouy4"
}
}
},

通过这种方式,您可以根据需要创建视频列表

关于youtube-api - 如何使用 YouTube V3 API 获取所有电影(不是视频),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14075009/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com