gpt4 book ai didi

json - 如何从YouTube V3 API检索URL值?

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

我正在尝试使用V3搜索API(https://www.googleapis.com/youtube/v3/search)检索有关YouTube视频的详细信息。我在JSON响应中获取了视频的所有详细信息,但没有视频的URL。有人可以帮我找回网址吗?提前致谢。

最佳答案

JSON中没有视频网址,您需要使用videoId。

例如,您得到这样的结果:

{
"kind": "youtube#searchListResponse",
"etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/KciEh2k6bPhgTexCFr55nrDyEuo\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1031,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/1Y85a6l1YSEQprOw66ptMsh0Bzw\"",
"id": {
"kind": "youtube#video",
"videoId": "KG0vtEsiPgs"
},
"snippet": {
"publishedAt": "2015-01-04T20:06:53.000Z",
"channelId": "UC5nc_ZtjKW1htCVZVRxlQAQ",
"title": "Real Slow - You Flow",
"description": "That little vocal snippet has got me hooked :) Download... http://bit.ly/1xHDPlX Real Slow https://soundcloud.com/realslowbeats ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/KG0vtEsiPgs/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/KG0vtEsiPgs/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/KG0vtEsiPgs/hqdefault.jpg"
}
},
"channelTitle": "MrSuicideSheep",
"liveBroadcastContent": "none"
}
},
{

然后,您可以提取videoId以创建用于链接YouTube视频的网址。

例如 items[0].id.videoId,请给我 KG0vtEsiPgs

然后,您需要使用以下URL videoId连接 https://www.youtube.com/watch?v=:

https://www.youtube.com/watch?v='videoId'

然后您有了视频链接。

关于json - 如何从YouTube V3 API检索URL值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28156527/

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