给定一个 YouTube 视频,以编程方式获取其频道?
Given a YouTube video, programmatically get its channel?
我发现了至少五个 "here is a YouTube channel, how do I programmatically obtain the videos on this channel?"
形式的 Stack Overflow 问题
我想反其道而行之:给定一个视频,它来自哪个频道?
到目前为止,我已经在官方 YouTube API 上寻找解决方案。我也看过像 pafy 这样的图书馆。到目前为止没有运气。
https://developers.google.com/youtube/v3/docs/videos/list
看来可以发视频请求了,然后设置:
part=snippet
除其他外,这将 return channelId
。我做了这样的请求:
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=f8WsO__XcI0&key={YOUR_API_KEY}
我得到回复:
{
...
"items": [
{
"kind": "youtube#video",
"etag": "\"IHLB7Mi__JPvvG2zLQWAg8l36UU/Xn3r39kJJF0iqtZbqFIeFUTgC0Q\"",
"id": "f8WsO__XcI0",
"snippet": {
"publishedAt": "2015-04-13T21:20:53.000Z",
"channelId": "UC6nSFpj9HTCZ5t-N3Rm3-HA",
...
}
我发现了至少五个 "here is a YouTube channel, how do I programmatically obtain the videos on this channel?"
形式的 Stack Overflow 问题我想反其道而行之:给定一个视频,它来自哪个频道?
到目前为止,我已经在官方 YouTube API 上寻找解决方案。我也看过像 pafy 这样的图书馆。到目前为止没有运气。
https://developers.google.com/youtube/v3/docs/videos/list
看来可以发视频请求了,然后设置:
part=snippet
除其他外,这将 return channelId
。我做了这样的请求:
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=f8WsO__XcI0&key={YOUR_API_KEY}
我得到回复:
{
...
"items": [
{
"kind": "youtube#video",
"etag": "\"IHLB7Mi__JPvvG2zLQWAg8l36UU/Xn3r39kJJF0iqtZbqFIeFUTgC0Q\"",
"id": "f8WsO__XcI0",
"snippet": {
"publishedAt": "2015-04-13T21:20:53.000Z",
"channelId": "UC6nSFpj9HTCZ5t-N3Rm3-HA",
...
}