Youtube 列出播放列表项时返回持续时间?
我正在使用此url:Youtube 列出播放列表项时返回持续时间?,youtube,youtube-api,youtube-data-api,Youtube,Youtube Api,Youtube Data Api,我正在使用此url: https://www.googleapis.com/youtube/v3/playlistItems? playlistId=FLFe0SGNFqZ9E2owO5ZDZpeg& part=snippet,contentDetails,status 获取YouTube播放列表项 我包括了我感兴趣的所有部分,但是我发现没有办法返回项目的持续时间 这可能吗 目前,我只取回如下物品: { "status": { "privacyStatus
https://www.googleapis.com/youtube/v3/playlistItems?
playlistId=FLFe0SGNFqZ9E2owO5ZDZpeg&
part=snippet,contentDetails,status
获取YouTube播放列表项
我包括了我感兴趣的所有部分
,但是我发现没有办法返回项目的持续时间
这可能吗
目前,我只取回如下物品:
{
"status": {
"privacyStatus": "public"
},
"kind": "youtube#playlistItem",
"contentDetails": {
"videoId": "tL-Ba86UhoE"
},
"snippet": {
"playlistId": "FLFe0SGeFqZ9E2owO5ZDZpwg",
"thumbnails": {
"default": {
"url": "https://i1.ytimg.com/vi/tL-BA86Uhoh/default.jpg",
"width": 120,
"height": 90
},
"high": {
"url": "https://i1.ytimg.com/vi/tL-BA86Uhoh/hqdefault.jpg",
"width": 480,
"height": 360
},
"medium": {
"url": "https://i1.ytimg.com/vi/tL-BA86Uhoh/mqdefault.jpg",
"width": 320,
"height": 180
}
},
"title": "Music Video",
"resourceId": {
"kind": "youtube#video",
"videoId": "tL-BA86Uhoh"
},
"channelId": "UCFe0SGNFqZ9E2owO5ZDZpwg",
"publishedAt": "2013-07-06T18:41:43.000Z",
"channelTitle": "channeltitle",
"position": 0,
"description": "Video for"
},
"etag": "\"ePFRUfYBkeQ2ncpP9OLHvB0fDw4/CJiCG6tvFw4quQlzJq3gTrhvCNo\"",
"id": "FL-fX6VqgtTfCJWKNE4aVRODKSrRgEdGvw"
},
根本没有时间指示。
我宁愿避免在YouTube上充斥返回单个视频持续时间的请求。使用此函数:[仅与YouTube Api v3一起使用] 浏览器: 您必须发出另一个http请求 使用: {video id}&part=contentDetails&key={api key} 等等 内容详细信息 您将找到持续时间 Php:
function getDuration($apiKey,$video_id){
$link='https://www.googleapis.com/youtube/v3/videos?id='.$video_id.'&part=contentDetails&key='.$apiKey;
$data = json_decode(file_get_contents($link),true);
$duration = $data['items'][0]['contentDetails']['duration'];
return $duration;
}
使用以下链接获取许多视频的持续时间:
https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=idFirst,idSecond&key=YOUR_API_KEY
该问题是针对播放列表项api提出的。如果必须从youtube播放列表创建列表,我们可以传递多个id。