Youtube API channel search skipping videos in list - youtube-api

I've got an app that's making an API call to YouTube that grabs the most recent videos by a certain channel. Suddenly, the list it is producing is incomplete.
I've manually searched the specific video it does grab, and one that it skips to compare the JSON result to see if there was something that made the videos differ, but as far as I can tell, aside from the obvious logical differences (title, id, etc;) there are none.
The original channel search call looks like this:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCi8e0iOVk1fEOogdfu4YgfA&maxResults=10&order=date&type=video&key={API_KEY}
The response is a list that consistently skips around 4 videos for seemingly no reason.
Here is an example of a video it skips when I make a call to the specific ID:
"kind": "youtube#videoListResponse",
"etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/DoiqTSh7UcwtVvH87b5HIMkDSAA\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/psJBlwJjAqrqgzcYJJIcvpK4mrI\"",
"id": "txDYwh46tew",
"snippet": {
"publishedAt": "2019-09-17T18:00:40.000Z",
"channelId": "UCi8e0iOVk1fEOogdfu4YgfA",
"title": "The Secret Garden International Trailer #1 (2020) | Movieclips Trailers",
"description": [removed for stackoverflow formatting],
"thumbnails": {
"default": {
"url": [removed for stackoverflow formatting],
"width": 120,
"height": 90
},
"medium": {
"url": [removed for stackoverflow formatting],
"width": 320,
"height": 180
},
"high": {
"url": [removed for stackoverflow formatting],
"width": 480,
"height": 360
},
"standard": {
"url": [removed for stackoverflow formatting],
"width": 640,
"height": 480
},
"maxres": {
"url": [removed for stackoverflow formatting],
"width": 1280,
"height": 720
}
},
"channelTitle": "Movieclips Trailers",
"tags": [
"The Secret Garden",
"The Secret Garden Trailer",
"The Secret Garden Movie Trailer",
"The Secret Garden Trailer 2019",
"The Secret Garden Official Trailer",
"Trailer",
"Trailers",
"Movie Trailers",
"2019 Trailers",
"The Secret Garden Trailer 1",
"Movieclips Trailers",
"Movieclips",
"Fandango",
"Entertainment",
"Movies",
"Drama",
"Family",
"Fantasy",
"Marc Munden",
"Colin Firth",
"Maeve Dermody",
"Julie Walters"
],
"categoryId": "1",
"liveBroadcastContent": "none",
"localized": {
"title": "The Secret Garden International Trailer #1 (2020) | Movieclips Trailers",
"description": [removed for stackoverflow formatting]
},
"defaultAudioLanguage": "en"
}
}
]
}
And here is a similar example in a video that it successfully returns in the original broader search:
{
"kind": "youtube#videoListResponse",
"etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/kvDQkVJCJaguSZLpfF9hJWR7sVw\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/WYxiNVjYVTjfwUuXqUpGeoV4KDA\"",
"id": "C8HrLHSBVJo",
"snippet": {
"publishedAt": "2019-09-16T22:22:16.000Z",
"channelId": "UCi8e0iOVk1fEOogdfu4YgfA",
"title": "Know Before You Go: Rambo: Last Blood | Movieclips Trailers",
"description": [removed for stackoverflow formatting],
"thumbnails": {
"default": {
"url": [removed for stackoverflow formatting],
"width": 120,
"height": 90
},
"medium": {
"url": [removed for stackoverflow formatting],
"width": 320,
"height": 180
},
"high": {
"url": [removed for stackoverflow formatting],
"width": 480,
"height": 360
},
"standard": {
"url": [removed for stackoverflow formatting],
"width": 640,
"height": 480
},
"maxres": {
"url": [removed for stackoverflow formatting],
"width": 1280,
"height": 720
}
},
"channelTitle": "Movieclips Trailers",
"tags": [
"rambo last blood know before you go",
"know before you go",
"fandango",
"movieclips",
"trailers",
"rambo",
"last blood",
"rambo last blood",
"Sylvester Stallone",
"Paz Vega",
"Yvette Monreal",
"Adrian Grunberg",
"action",
"adventure",
"thriller",
"first blood",
"all rambo movies",
"rambo movies",
"rambo movies explained",
"rambo franchise explained",
"slyvester stallone",
"rambo explained",
"new rambo movie",
"new rambo trailer",
"sylvester stallone rambo"
],
"categoryId": "1",
"liveBroadcastContent": "none",
"defaultLanguage": "en",
"localized": {
"title": "Know Before You Go: Rambo: Last Blood | Movieclips Trailers",
"description": [removed for stackoverflow formatting]
},
"defaultAudioLanguage": "en"
}
}
]
}
The Channel IDs both match, and the publish date shows that the skipped video is more recently published than the video it successfully finds. Considering the original call is set to order the by date, there should be no reason the skipped video would be left out of the results. Of the found videos, they are correctly ordered in chronological order, so it doesn't seem to be the order parameter either.
I would expect the API search result to respond with an unfiltered list of the 10 newest videos published on the channels. Up until a couple days ago, it was performing that with no issue. With no changes to the call, it has suddenly started missing videos in a consistent behaviour. I'm at a loss for why that behaviour would suddenly change.

Related

Youtube API Playlists not returning the Playlist

I am using the Playlists endpoint of Youtube's API to get the playlists from a specific channel but it doesn't work for the following channels:
https://www.youtube.com/channel/UCX5fyLRcU05DMa2OVu-qFEQ
https://www.youtube.com/channel/UCwm2mdiUXApmL5bCxHtgJIA
The query I am using:
https://www.googleapis.com/youtube/v3/playlists?channelId=UCwm2mdiUXApmL5bCxHtgJIA&part=snippet&order=date&maxResults=50&key=YOUR_API_KEY
https://www.googleapis.com/youtube/v3/playlists?channelId=UCX5fyLRcU05DMa2OVu-qFEQ&part=snippet&order=date&maxResults=50&key=YOUR_API_KEY
It doesn't return the videos when I try to target the playlists in these channels using the specif Playlist ID as well. I can see that these channels, playlists and videos are public and searchable.
Is there any reason why the API shouldn't return this playlist that I am missing?
Thank you for your help.
Bartu
If you check the playlist page of the channel you provided, you'll see that all playlists posted there are not really from the channel - those were added/generated by YouTube itself.
Example:
https://www.youtube.com/playlist?list=OLAK5uy_nvZSUlZB8qwifPgIVCoEulF4VyErdBX48
A normal playlist (that belongs to the channel) should have its ID as follows:
PL3tRBEVW0hiB5KKP9gs_AkW8J4dOvbdPN
By using YouTube Data API, you can test the results:
URL: https://youtube.googleapis.com/youtube/v3/playlists?part=id%2Csnippet%2Cstatus&id=OLAK5uy_nvZSUlZB8qwifPgIVCoEulF4VyErdBX48&key=[YOUR_API_KEY]
Results:
{
"kind": "youtube#channelListResponse",
"etag": "Yw1yJOOwI7LJ8LeYmvQ8wpyHWbU",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "wDhMSGEntArTZuX56hjNjytDUlU",
"id": "UCFtEEv80fQVKkD4h1PF-Xqw",
"snippet": {
"title": "Microsoft",
"description": "Innovation is a key ingredient in Microsoft’s mission: to empower every person and organization on the planet to achieve more. \n\nSubscribe to Microsoft's official YouTube channel to explore technology’s role in making the world more sustainable, inclusive, and innovative for all.\n\n",
"customUrl": "microsoft",
"publishedAt": "2006-02-13T05:21:44Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AKedOLRZENZBPyEEG2cd0PZXemKKyG1GMGVJXmzHhrs4=s88-c-k-c0x00ffffff-no-rj",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AKedOLRZENZBPyEEG2cd0PZXemKKyG1GMGVJXmzHhrs4=s240-c-k-c0x00ffffff-no-rj",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AKedOLRZENZBPyEEG2cd0PZXemKKyG1GMGVJXmzHhrs4=s800-c-k-c0x00ffffff-no-rj",
"width": 800,
"height": 800
}
},
"localized": {
"title": "Microsoft",
"description": "Innovation is a key ingredient in Microsoft’s mission: to empower every person and organization on the planet to achieve more. \n\nSubscribe to Microsoft's official YouTube channel to explore technology’s role in making the world more sustainable, inclusive, and innovative for all.\n\n"
},
"country": "US"
},
"contentDetails": {
"relatedPlaylists": {
"likes": "",
"uploads": "UUFtEEv80fQVKkD4h1PF-Xqw"
}
},
"status": {
"privacyStatus": "public",
"isLinked": true,
"longUploadsStatus": "longUploadsUnspecified"
}
}
]
}
When you query a normal playlist (that belongs to the channel), you will get these results:
URL: https://youtube.googleapis.com/youtube/v3/playlists?part=id%2Csnippet%2Cstatus&id=PL3tRBEVW0hiB5KKP9gs_AkW8J4dOvbdPN&key=[YOUR_API_KEY]
Results:
{
"kind": "youtube#playlistListResponse",
"etag": "OV6gnfMDH09mU3YBdHPuf5uz1Jg",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#playlist",
"etag": "X8YVDKLXZZfHlVTh_ud0LD-IMMQ",
"id": "PL3tRBEVW0hiB5KKP9gs_AkW8J4dOvbdPN",
"snippet": {
"publishedAt": "2016-05-15T15:29:30Z",
"channelId": "UC7_YxT-KID8kRbqZo7MyscQ",
"title": "DOOM",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/pCygvprsgIk/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Markiplier",
"localized": {
"title": "DOOM",
"description": ""
}
},
"status": {
"privacyStatus": "public"
}
}
]
}
Check this answer for more details.

How to retrieve game title bound to video [duplicate]

This question already has answers here:
Youtube API Retrieve Live Stream Game Title
(2 answers)
Closed 1 year ago.
Does anyone know how to get the game title assigned to video via the Youtube API?
Game title screenshot from YT web. Here I need to get the Call of Duty game from this video:
Documentation doesn't have any information regarding game title in the video resource: https://developers.google.com/youtube/v3/docs/videos
API query with the broadest content settings returns this:
{
"kind": "youtube#videoListResponse",
"etag": "0KGf7UH0NGSsvuQJqAEX4e1mE00",
"items": [
{
"kind": "youtube#video",
"etag": "atR4AXswOz04SvjBEFuPTUpgEKo",
"id": "Tn2TgqkrCng",
"snippet": {
"publishedAt": "2016-09-23T16:31:31Z",
"channelId": "UCv2IxyoJetx3b3nPbHJbx3g",
"title": "Batman: The Telltale Games Series [#7][Epizod 2 FINAŁ]",
"description": "Wrzućcie like'a na facebooku: ",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/Tn2TgqkrCng/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/Tn2TgqkrCng/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/Tn2TgqkrCng/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/Tn2TgqkrCng/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/Tn2TgqkrCng/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Tivolt",
"tags": [
"tivolt",
"let's play",
"zagrajmy w",
"gameplay",
"gry",
"zagrajmy",
"vlog",
"fajne",
"gta",
"batman",
"telltale"
],
"categoryId": "20",
"liveBroadcastContent": "none",
"localized": {
"title": "Batman: The Telltale Games Series [#7][Epizod 2 FINAŁ]",
"description": "Wrzućcie like'a na facebooku: "
},
"defaultAudioLanguage": "pl"
},
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true,
"madeForKids": false
},
"statistics": {
"viewCount": "33035",
"likeCount": "1681",
"dislikeCount": "23",
"favoriteCount": "0",
"commentCount": "131"
},
"player": {
"embedHtml": "<iframe width=\"480\" height=\"270\" src=\"//www.youtube.com/embed/Tn2TgqkrCng\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>"
},
"topicDetails": {
"relevantTopicIds": [
"/m/02vxn",
"/m/025zzc",
"/m/0403l3g"
],
"topicCategories": [
"https://en.wikipedia.org/wiki/Action_game",
"https://en.wikipedia.org/wiki/Film",
"https://en.wikipedia.org/wiki/Role-playing_video_game"
]
},
"recordingDetails": {}
}
],
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
}
}
As you can see, there is no info about game title. Has anyone struggled with this and knows the way how to do it?
Someone has already posted the same question here, but it looks like everyone misunderstood him, there is no correct answer and I have no rep to comment in this thread.
As people noticed, there isn't any YouTube Data API v3 endpoint providing you the game associated with the YouTube video.
However by downloading the video webpage and looking for in the source code of the webpage we can find it. Here is a Python 3 script retrieving the game title associated with the YouTube video if there is any:
import urllib.request
def getURL(url):
return urllib.request.urlopen(url).read().decode('utf-8')
videoId = 'oua2xCWTK48'
url = 'https://www.youtube.com/watch?v=' + videoId
content = getURL(url)
prefix = '}]},"title":{"simpleText":"'
if prefix in content:
gameName = content.split(prefix)[1].split('"')[0]
print(gameName)

TotalResults count doesn't match with the actual results returned in YouTube v3 search API

We are using youtube v3 search API. We are getting mismatch in the "totalResults" count and the list of items returned in the response.items field. I am requesting 50 videos in the request. Response returned shows totalResults count as 65 but the response payload has only 3 videos.
API : www.googleapis.com/youtube/v3/search/list
Request Payload
{key=API_KEY, maxResults=50, order=date, part=snippet, publishedAfter=2017-03-20T23:59:59.999-04:00, publishedBefore=2017-04-19T23:59:59.001-04:00, q=( ( "Wood Mackenzie" OR "Wood Mac" OR Woodmac OR #woodmackenzie ) AND NOT (fleetwood OR "fleet wood" OR 9WoodMac ) ) , type=video}
Response Payload
{
"kind": "youtube#searchListResponse",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/HTW4WQODZeERIv51VrRfOhir8dg\"",
"nextPageToken": "CDIQAA",
"regionCode": "US",
"pageInfo": {
"totalResults": 65,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/lnNNrToZHGTehIEJ6bvEx5RZMo4\"",
"id": {
"kind": "youtube#video",
"videoId": "obzlB21t904"
},
"snippet": {
"publishedAt": "2017-04-14T11:38:08.000Z",
"channelId": "UC60Sa1LQjgy_a-K8ThN4eQw",
"title": "Fleet wood mac Live at Leeds",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/obzlB21t904/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/obzlB21t904/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/obzlB21t904/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "KEVIN MARSHALL",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/uYuuTAL3vtnFI1WOYjth0cso2Xo\"",
"id": {
"kind": "youtube#video",
"videoId": "gHAn0SbwKMg"
},
"snippet": {
"publishedAt": "2017-04-06T22:17:31.000Z",
"channelId": "UC3_MxBSSbmGznoSTgoBQ7_w",
"title": "Beat Club: British Invasion 60's, Pt-2; Animals-Move-Fleet Wood Mac-J.Mayall-Who-Pacemakers-Kinks",
"description": "Eric Burdon & Animals: C.C. Rider 0:01 The Move: Wild Tiger Woman 3:55 Fleet Wood Mac: Dragonfly 6:26 John Mayall: My Pretty Girl 9:47 Thunderclap ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/gHAn0SbwKMg/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/gHAn0SbwKMg/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/gHAn0SbwKMg/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "ROCK&POPS1_koba",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/tapelxOG4Q3gZRJCR2qaVdt-ZO8\"",
"id": {
"kind": "youtube#video",
"videoId": "5GvLbFBdcF4"
},
"snippet": {
"publishedAt": "2017-04-02T04:48:47.000Z",
"channelId": "UC6fn383TI1HVDYW4dSEIogQ",
"title": "\"Dreams\" by fleet wood mac (vocal cover)",
"description": "I do not own this song. I do not make a profit off of this song. It belongs to the person(s) who wrote it. Please subscribe and comment below any suggestions?!",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/5GvLbFBdcF4/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/5GvLbFBdcF4/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/5GvLbFBdcF4/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Musikallitee",
"liveBroadcastContent": "none"
}
}
]
}
As described in the documentation itself, the totalResults is:
integer
The total number of results in the result set.Please note that the value is an approximation and may not represent an exact value. In addition, the maximum value is 1,000,000.
You should not use this value to create pagination links. Instead, use the nextPageToken and prevPageToken property values to determine whether to show pagination links.
The value is only an approximation/estimate, but not the exact value for the total number of items returned. I've tested the API with the same details as yours and the value tends to change from 63, to 64, and 65.
With all that said, there is nothing wrong in your code. It's just the expected behavior. Unfortunately, it is not stated anywhere as to where the value of totalResults is based on or where it is best used. It's best to proceed with an implementation that doesn't rely on this parameter.

Why do new videos get posted in categories that are not "assignable"?

According to the docs at https://developers.google.com/youtube/v3/docs/videoCategories, a videoCategory having assignable set to false means that videos cannot "be associated with the category." However, in reality, I frequently see newly-posted videos in non-assignable categories. For instance, category 44, Trailers, is not assignable:
{
"kind": "youtube#videoCategoryListResponse",
"etag": "\"sZ5p5Mo8dPpfIzLYQBF8QIQJym0/eD61zd9m0XnQ2ZM5b9n0Q8fREKY\"",
"items": [
{
"kind": "youtube#videoCategory",
"etag": "\"sZ5p5Mo8dPpfIzLYQBF8QIQJym0/x5NxSf5fz8hn4loSN4rvhwzD_pY\"",
"id": "44",
"snippet": {
"channelId": "UCBR8-60-B28hp2BmDPdntcQ",
"title": "Trailers",
"assignable": false
}
}
]
}
But https://www.youtube.com/watch?v=fV4CL3ec-C0, published under half an hour ago, is in that category, as can be seen by querying the videos list API:
{
"kind": "youtube#videoListResponse",
"etag": "\"sZ5p5Mo8dPpfIzLYQBF8QIQJym0/NWLSF1NxIRL6hEGPkRpbFpl6ShA\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"sZ5p5Mo8dPpfIzLYQBF8QIQJym0/TMALCjmdQYcndOpePwtvPYbaBBI\"",
"id": "fV4CL3ec-C0",
"snippet": {
"publishedAt": "2016-11-07T11:00:03.000Z",
"channelId": "UCxk91kWNnZEIyE-1HgqzvHw",
"title": "USS Indianapolis: The Legacy - Trailer",
"description": "Based on the largest collection of original source material available on the subject, The Legacy Project is a complete re-telling of the story of the USS Indianapolis, told first hand, by those who lived through the experience.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/fV4CL3ec-C0/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/fV4CL3ec-C0/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/fV4CL3ec-C0/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/fV4CL3ec-C0/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/fV4CL3ec-C0/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "GravitasVODGlobal",
"tags": [
"Military",
"WWII",
"Indianapolis",
"McVay",
"Navy",
"Atomic Bomb",
"Sharks",
"Cruiser",
"Hunter Scott",
"Pacific War"
],
"categoryId": "44",
"liveBroadcastContent": "none",
"localized": {
"title": "USS Indianapolis: The Legacy - Trailer",
"description": "Based on the largest collection of original source material available on the subject, The Legacy Project is a complete re-telling of the story of the USS Indianapolis, told first hand, by those who lived through the experience."
}
}
}
]
}
By what mechanism do new videos get added to non-assignable categories? Are there some secret APIs available only to certain clients that YouTube has special deals with, or is there a publicly-documented mechanism for adding videos to non-assignable categories? Either way, is there any way for developers to distinguish these categories that are only nominally non-assignable from those that will truly not accept new videos via any means?

With the YouTube API v3 how can I get access to content duration, and genres? By search or get details

I tried to use this:
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,contentDetails&{playlist_id}&key={key}&maxResults=50
and
https://www.googleapis.com/youtube/v3/search?part=snippet&q=YouTube+Data+API&type=video&videoCaption=closedCaption&key={key}&maxResults=50
It says in the documentation it is contentDetails.duration but this doesn't seem to be present in the data I receive.
In order to get the detailed information about a video in a playlist, you will need to hit the Videos.list method for every video in that playlist with the snippet and contentDetails values for part:
Request:
HTTP GET https://www.googleapis.com/youtube/v3/videos?part=snippet%2C+contentDetails&id=AKiiekaEHhI&key={YOUR_API_KEY}
Response (for id=AKiiekaEHhI):
{
"kind": "youtube#videoListResponse",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/Qz22l3E04nR4kuY2SGE5M_d1BMM\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/8X_byN22HJTh5FJyoMH9bFGR_Og\"",
"id": "AKiiekaEHhI",
"snippet": {
"publishedAt": "2015-05-04T10:01:43.000Z",
"channelId": "UCkvdZX3SVgfDW8ghtP1L2Ug",
"title": "The Legend of Zelda: Majora's Mask With Glitches - Part 17: Going Against the Flow",
"description": "Follow me on Twitter! http://twitter.com/swordlesslink\n\nFollow me on TwitchTV for live video game streaming! http://twitch.tv/swordlesslink",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/AKiiekaEHhI/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/AKiiekaEHhI/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/AKiiekaEHhI/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/AKiiekaEHhI/sddefault.jpg",
"width": 640,
"height": 480
}
},
"channelTitle": "Swordless Link",
"categoryId": "20",
"liveBroadcastContent": "none",
"localized": {
"title": "The Legend of Zelda: Majora's Mask With Glitches - Part 17: Going Against the Flow",
"description": "Follow me on Twitter! http://twitter.com/swordlesslink\n\nFollow me on TwitchTV for live video game streaming! http://twitch.tv/swordlesslink"
}
},
"contentDetails": {
"duration": "PT17M30S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": true
}
}
]
}
The duration of the content can be found as the object for the duration key in the contentDetails dictionary.
The categoryId maps to your video category, which you will have to look up using the VideoCategories.list method.
Request:
HTTP GET https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&id={CATEGORY_ID}&key={YOUR_API_KEY}
Response (for id=20:
{
"kind": "youtube#videoCategoryListResponse",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/cVclmqPmb6Xbwij8SctXRUrSVhw\"",
"items": [
{
"kind": "youtube#videoCategory",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/WmA0qYEfjWsAoyJFSw2zinhn2wM\"",
"id": "20",
"snippet": {
"channelId": "UCBR8-60-B28hp2BmDPdntcQ",
"title": "Gaming",
"assignable": true
}
}
]
}
The object for the title key in the snippet dictionary returns the String value of the video category that you want.
If you check search resource, you'll see its not in that response.
This was actually a feature request in: https://code.google.com/p/gdata-issues/issues/detail?id=4294
You can follow up that issue.

Resources