gpt4 book ai didi

youtube - 如何查询YouTube API,以从自动生成的 'Topic' channel 获取视频?

转载 作者:行者123 更新时间:2023-12-03 05:31:21 24 4
gpt4 key购买 nike

如何使用YouTube API输入搜索参数,以便仅从主题 channel 获取视频ID?例如,如果我转到youtube.com并手动搜索“Hello Adele-Topic”,则可以正确地从“Adele-Topic” channel 获得歌曲“Hello”作为我的第一个搜索结果https://www.youtube.com/watch?v=_WS9w10ygpU
但是,如果我使用YouTube数据API并使用以下参数执行相同的查询:

part='snippet'
q='Hello Adele - Topic'

我不会找回正确视频的ID。有什么办法以编程方式获取此信息吗?

最佳答案

thread所述,自动生成的 channel 没有视频。他们只有带有其他 channel 视频的播放列表。因此,您必须寻找播放列表。您可以在link中检查样本请求。

Here's the URL sample of auto-generated Topic-based Id which grabs its playlist id:

GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=HC9m3exs6zk1U&fields=items%2Fid&key={YOUR_API_KEY}
//Outputs sample playlist Id: LP9m3exs6zk1U

Now here's the URL sample using that playlist Id to get the videos from the auto-generated Topic-based channel Id:

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=5&playlistId=LP9m3exs6zk1U&key={YOUR_API_KEY} 
//Outputs video data you want.


希望这可以帮助。

关于youtube - 如何查询YouTube API,以从自动生成的 'Topic' channel 获取视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44424444/

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