尝试通过 v3/videos 检查它们 - https://developers.google.com/youtube/v3/docs/videos/list
如果你使用“part=sn-p”
您将在 items->sn-p->channelId 和 items->sn-p->channelTitle 中看到频道信息
例如https://www.youtube.com/watch?v=YVe2THgSDxc加载
https://www.googleapis.com/youtube/v3/videos?id=YVe2THgSDxc&part=snippet&key=[YOUR_API_KEY]
你会得到
{
"kind": "youtube#videoListResponse",
"etag": "*******",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "*******",
"id": "YVe2THgSDxc",
"snippet": {
"publishedAt": "2018-01-22T15:47:46.000Z",
"channelId": "UCiP6wD_tYlYLYh3agzbByWQ",
"title": "30 Minute HIIT Cardio*******",
"description": "Full info for thi*******.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/YVe2THgSDxc/default.jpg",
"width": 120,
"height": 90
},
*******
},
"channelTitle": "FitnessBlender",
"tags": [
"fitness blender",
"fitness",
"blender",
"workout",
"workout videos",
"hiit workout",
"cardio workout",
"hiit cardio",
"cardio at home",
"hiit at home",
"at home hiit",
"at home workouts",
"free workout videos",
"hiit cardio workout",
"strength",
"strength training",
"strength training workout",
"dumbbell workout",
"at home strength training",
"strength and hiit",
"hiit and strength",
"lower body workout",
"butt workout",
"thigh workout",
"butt and thigh workout",
"fat burning workout",
"muscle building workout"
],
"categoryId": "26",
"liveBroadcastContent": "none",
"localized": {
"title": "30 Minute HIIT Ca*******",
"description": "Full info for this *******"
}
}
}
]
}
因此,如果您有用户的频道 ID 或频道名称,您可以将其与视频的频道 ID 或频道名称进行比较。
如果你有用户名但没有他的频道列表你可以通过 v3/channels 获得它
例如,这会获取用户“popsugartvfit”的频道列表
https://www.googleapis.com/youtube/v3/channels?&part=contentDetails&forUsername=popsugartvfit&key=[YOUR_API_KEY]
你会得到
{
"kind": "youtube#channelListResponse",
"etag": "*****",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "*******",
"id": "UCBINFWq52ShSgUFEoynfSwg",
"contentDetails": {
"relatedPlaylists": {
"uploads": "UUBINFWq52ShSgUFEoynfSwg",
"watchHistory": "HL",
"watchLater": "WL"
}
}
}
]
}
并使用 if 进行验证