进行搜索调用后,您必须调用Youtube Data API的视频资源。您可以在搜索中放置最多50个视频ID,因此您无需为每个元素调用它。
https://developers.google.com/youtube/v3/docs/videos/list
你需要设置part = contentDetails,因为持续时间在那里。
例如以下电话:
https://www.googleapis.com/youtube/v3/videos?id=9bZkp7q19f0&part=contentDetails&key= {} YOUR_API_KEY 给出这个结果:
{ "kind": "youtube#videoListResponse", "etag": "\"XlbeM5oNbUofJuiuGi6IkumnZR8/ny1S4th-ku477VARrY_U4tIqcTw\"", "items": [ { "id": "9bZkp7q19f0", "kind": "youtube#video", "etag": "\"XlbeM5oNbUofJuiuGi6IkumnZR8/HN8ILnw-DBXyCcTsc7JG0z51BGg\"", "contentDetails": { "duration": "PT4M13S", "dimension": "2d", "definition": "hd", "caption": "false", "licensedContent": true, "regionRestriction": { "blocked": [ "DE" ] } } } ] }