gdata api v3 youtube, can not retrieve contentDetails

痞子三分冷 提交于 2020-01-05 08:51:24

问题


I am trying to get the duration of a youtube video via search

var request = gapi.client.youtube.search.list({
    q: q,
    type : "video",
    maxResults : 10,
    part: 'snippet,contentDetails'
});

as an additional part parameter I added contentDetails in order to get the duration as you can see in their doc. https://developers.google.com/youtube/v3/getting-started

Now comes the silly part. The response I get is the following:

[
{
"error": {
   "code": -32602,
   "message": "contentDetails",
   "data": [
     {
     "domain": "youtube.part",
     "reason": "unknownPart",
     "message": "contentDetails",
     "locationType": "parameter",
     "location": "part"
    }
   ]
  },
  "id": "gapiRpc"
 }
]

"As such, the part parameter requires you to select the resource components that your application actually uses" Thats what I did and now they dont know their own parameter anylonger?

So I was wondering how can I retrieve the duration order contentDetails in general? best phil


回答1:


As written in the document, for search->list call, part can only take value "snippet".

Depending on the kind of the response, as a secondary call, you can do one of videos->list, playlists->list, channels->list with the id and part=snippet,contentDetails to get more details of each result item.



来源:https://stackoverflow.com/questions/18137227/gdata-api-v3-youtube-can-not-retrieve-contentdetails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!