YouTube API V3 recordingDetails object missing in

2019-08-13 13:59发布

问题:

I have tried this YouTube API v3 call from curl today:

http://www.googleapis.com/youtube/v3/videos?id=ZCJgvabihQ8&key=apiKey&part=snippet,recordingDetails

Everything else is fine, but I didn't find the recordingDetails object in the response json:

{
"kind":"youtube#videoListResponse",
"etag":"\"oLweQuB9Vh7wAB9a0AIHg_K-wsM/EuRsJ-sxI3qstP1T58S5Qnb_NIg\"",
"items":[
{
    "id":"ZCJgvabihQ8",
    "kind":"youtube#video",
    "etag":"\"oLweQuB9Vh7wAB9a0AIHg_K-wsM/CYNTRL05S4okPzkUfE5LbrRKt9g\"",
    "snippet":{
    "publishedAt":"2013-01-25T13:36:19.000Z",
    "channelId":"UCpVm7bg6pXKo1Pr6k5kxG9A",
    "title":"Weird Nature: Pink Dolphins?",
    "description":"Up to 9 feet long and weighing up to 300 pounds, pink river dolphins           are the largest freshwater dolphins in the world.",
    "thumbnails":{
        "default":{
           "url":"https://i.ytimg.com/vi/ZCJgvabihQ8/default.jpg"
        },
        "medium":{
           "url":"https://i.ytimg.com/vi/ZCJgvabihQ8/mqdefault.jpg"
        },
        "high":{
           "url":"https://i.ytimg.com/vi/ZCJgvabihQ8/hqdefault.jpg"
        }
    },
    "categoryId":"24"
    }
}
]
}

Is there anything I missed? Many thanks.

回答1:

recordingDetails is not public for all videos, so if a video doesn't have these attributes available, nothing will be returned. By not returning anything, YouTube saves bandwidth and the response time can be faster.


Original reponse:

This looks like a legitimate bug...

recordingDetails is listed as an option on the videos resource overview page, but not listed as a valid part in the video list method here: https://developers.google.com/youtube/v3/docs/videos/list

Normally when you try using an invalid part you get a "400 Bad Request" error, but recordingDetails still returns a 200 response, so it looks like it really is supposed to be returned...

You should submit a bug report here: https://code.google.com/p/gdata-issues/issues/entry?template=YouTube%20(Defect%20Report)



回答2:

recordingDetails will only be returned for videos that explicitly have either the geolocation or the recording time set. (Not all videos set recording time; it's a distinct piece of metadata from publication time.)



回答3:

You can do a list call to retrieve a list of videos based on a location and locationRadius.

Then, with the returned list you can do a videos call including all video IDs in the id parameter of the query. You can then specify recordingDetails as "part" and it will work.

This is how Youtube does it here:

https://github.com/youtube/geo-search-tool



标签: youtube-api