Certain videos not showing up in the api results - youtube

I have noticed that all videos from the account, Kanye West - Topic, don't show up in the api results. Does anyone have a reason why or a solution to fix this? For example, when I use the api search GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCRY5dYsbIN5TylSbd7gVnZg&type=video&key={YOUR_API_KEY}, it says there are 961 total results but the items section is empty.

Your GET request is correct but it's missing additional field resources parameters, so it doesn't know what you want to retrieve. I've added the fields to your GET REQUEST using the Google API Explorer and here's what it looks like:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCRY5dYsbIN5TylSbd7gVnZg&maxResults=50&q=%22Kanye+West%22&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CprevPageToken%2CregionCode%2CtokenPagination%2CvisitorId&key={API_KEY_HERE}
And the response was:
{
"kind": "youtube#searchListResponse",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/6VdmXA4FhXjg08y58iRnmXZY7wQ\"",
"nextPageToken": "CDIQAA",
"regionCode": "PH",
"pageInfo": {
"totalResults": 841,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/VSzDMW_CqJw-OMjo_vzPR2P40eI\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCRY5dYsbIN5TylSbd7gVnZg"
},
"snippet": {
"publishedAt": "2013-07-02T20:09:18.000Z",
"channelId": "UCRY5dYsbIN5TylSbd7gVnZg",
"title": "Kanye West - Topic",
"description": "Kanye Omari West is an American rapper, songwriter, record producer, fashion designer, and entrepreneur. Born in Atlanta and raised in Chicago, West first ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/i/RY5dYsbIN5TylSbd7gVnZg/1.jpg"
},
"medium": {
"url": "https://i.ytimg.com/i/RY5dYsbIN5TylSbd7gVnZg/mq1.jpg"
},
"high": {
"url": "https://i.ytimg.com/i/RY5dYsbIN5TylSbd7gVnZg/hq1.jpg"
}
},
"channelTitle": "Kanye West - Topic",
"liveBroadcastContent": "none"
}
.. (long list below)
If you want to conduct additonal test, use the Youtube API Explorer.

Related

Youtube API v3 data.search returning same value

I was trying to fetch different youtube channels on the basis of the regionCode.
Trying to fetch indian youtube channels:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&regionCode=IN&maxResults=5&key={API_KEY}
Trying to fetch Malaysian youtube channels:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&regionCode=MY&maxResults=5&key={API_KEY}
I am getting same result for both of this requests. Why this is happening?
{
"kind": "youtube#searchListResponse",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/EiqwT6pG1EkwVEl17s1_qudvkmk\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/smpwgLdS9Og11NhpzRYcy37a9V8\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCrFiA0hztL9e8zTi_qBuW4w"
},
"snippet": {
"publishedAt": "2013-03-19T20:35:41.000Z",
"channelId": "UCrFiA0hztL9e8zTi_qBuW4w",
"title": "EeOneGuy",
"description": "Просто делаю ролики =)",
"thumbnails": {
"default": {
"url": "https://lh6.googleusercontent.com/-ZPtgaY_lFDY/AAAAAAAAAAI/AAAAAAAAAAA/U_8gJcnIMiE/photo.jpg"
},
"medium": {
"url": "https://lh6.googleusercontent.com/-ZPtgaY_lFDY/AAAAAAAAAAI/AAAAAAAAAAA/U_8gJcnIMiE/photo.jpg"
},
"high": {
"url": "https://lh6.googleusercontent.com/-ZPtgaY_lFDY/AAAAAAAAAAI/AAAAAAAAAAA/U_8gJcnIMiE/photo.jpg"
}
},
"channelTitle": "EeOneGuy",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/g4m9Kno2zbU7BMIEUbffxDlyvZI\"",
"id": {
"kind": "youtube#channel",
"channelId": "UC7MO7ngSqsBcvQvxNf-kpWg"
},
"snippet": {
"publishedAt": "2013-06-04T17:39:49.000Z",
"channelId": "UC7MO7ngSqsBcvQvxNf-kpWg",
"title": "The Right to Research Coalition",
"description": "The Right to Research Coalition is a coalition of 80 undergraduate and graduate student organisations from across the world. Together we educate and ...",
"thumbnails": {
"default": {
"url": "https://lh5.googleusercontent.com/-p0RT2XiO3_0/AAAAAAAAAAI/AAAAAAAAAAA/tdAJTswPnB0/photo.jpg"
},
"medium": {
"url": "https://lh5.googleusercontent.com/-p0RT2XiO3_0/AAAAAAAAAAI/AAAAAAAAAAA/tdAJTswPnB0/photo.jpg"
},
"high": {
"url": "https://lh5.googleusercontent.com/-p0RT2XiO3_0/AAAAAAAAAAI/AAAAAAAAAAA/tdAJTswPnB0/photo.jpg"
}
},
"channelTitle": "R2RCvideo",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/nWC7qhbPZRH0qyEBOcWdFR8TI5k\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCmSSq5573Ru9asXsXykgqTw"
},
"snippet": {
"publishedAt": "2014-10-12T02:26:56.000Z",
"channelId": "UCmSSq5573Ru9asXsXykgqTw",
"title": "Toys Games TV",
"description": "Welcome to Toys Games TV Channel! Looking for a safe channel for your kids? Look no further, on TGTV we review primarily Disney, PBS & Sprout character ...",
"thumbnails": {
"default": {
"url": "https://lh3.googleusercontent.com/-5qqjMUWhRow/AAAAAAAAAAI/AAAAAAAAAAA/2la9IA5DNhU/photo.jpg"
},
"medium": {
"url": "https://lh3.googleusercontent.com/-5qqjMUWhRow/AAAAAAAAAAI/AAAAAAAAAAA/2la9IA5DNhU/photo.jpg"
},
"high": {
"url": "https://lh3.googleusercontent.com/-5qqjMUWhRow/AAAAAAAAAAI/AAAAAAAAAAA/2la9IA5DNhU/photo.jpg"
}
},
"channelTitle": "ToysGamesTV",
"liveBroadcastContent": "upcoming"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/enqEI6qDr8UfYcjixI9Cjpd6SU0\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCtjLPHCyI5V-xuumAXzAizA"
},
"snippet": {
"publishedAt": "2008-06-05T04:13:13.000Z",
"channelId": "UCtjLPHCyI5V-xuumAXzAizA",
"title": "UNUChannel",
"description": "Channel produced by the United Nations University (UNU). The overarching goal of the United Nations University is to contribute to global sustainable ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/i/tjLPHCyI5V-xuumAXzAizA/1.jpg"
},
"medium": {
"url": "https://i.ytimg.com/i/tjLPHCyI5V-xuumAXzAizA/mq1.jpg"
},
"high": {
"url": "https://i.ytimg.com/i/tjLPHCyI5V-xuumAXzAizA/hq1.jpg"
}
},
"channelTitle": "UNUChannel",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/44t2atyjsxpSOVj7OfeK9GTfy0M\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCJ7-0_cR9HiA9iX8n3kugcg"
},
"snippet": {
"publishedAt": "2010-06-29T15:08:02.000Z",
"channelId": "UCJ7-0_cR9HiA9iX8n3kugcg",
"title": "Naturhistoriska riksmuseet",
"description": "Naturhistoriska riksmuseets och Cosmonovas YouTube-kanal.",
"thumbnails": {
"default": {
"url": "https://lh5.googleusercontent.com/-OItSjQXSj_c/AAAAAAAAAAI/AAAAAAAAAAA/ybdmiik-0eA/photo.jpg"
},
"medium": {
"url": "https://lh5.googleusercontent.com/-OItSjQXSj_c/AAAAAAAAAAI/AAAAAAAAAAA/ybdmiik-0eA/photo.jpg"
},
"high": {
"url": "https://lh5.googleusercontent.com/-OItSjQXSj_c/AAAAAAAAAAI/AAAAAAAAAAA/ybdmiik-0eA/photo.jpg"
}
},
"channelTitle": "SthlmNaturhistoriska",
"liveBroadcastContent": "none"
}
}
]
}
Thanks in advance. Any help would be much appreciated.
From the documentation:
regionCode - (string) The regionCode parameter instructs the API to return
search results for the specified country. The parameter value is an
ISO 3166-1 alpha-2 country code.
It looks like specifying the regionCode returns search results as if you were in that country, not for videos/channels that are associated with that country. For example, if you specified CN (China) as the region code, you wouldn't get results for videos that have been blocked in China.
It seems that there's no good way to get all channels that belong to a particular country. What you could do is execute the search.list() with your specified search criteria and set type=Channel. Then, based on the response, issue a request to channels.list() to get the country and compare to see if it is from that specific country. It's pretty inefficient, and while I was trying to test a similar way of doing it, I found that I can set my country in the "About" section of my channel. However, since the field is optional, there's no guarantee that users are actually setting this for their channels, so ultimately it's hard for you to get the information you're looking for.

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.

Searching Channel with Youtube API

I am using Youtube Data Api V3 in my iOS App. Can some body give me some example for search thing the some Channel by name.
I am trying in the following way but its not working
https://www.googleapis.com/youtube/v3/search/list?key={YOUR_API_KEY}&part=snippet&type=channel&q=AnimalPlanetTV
Can anybody help me how i can get the channel data by name
Thanks
For Searching AnyYoutube Channel
https://youtube.googleapis.com/youtube/v3/channels?part=snippet&q=yoursearchquery&key=yourkey
This is a live example
You need to use Channel list of API V3
The result is like that with snippet
{
"kind": "youtube#channelListResponse",
"etag": "\"gMjDJfS6nsym0T-NKCXALC_u_rM/RKAMAh1QnoE3ilYYcvWIqvcDEZo\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"gMjDJfS6nsym0T-NKCXALC_u_rM/MenmiFqQVVN5JQ9MJpC9gddZ4Lw\"",
"id": "UCkEBDbzLyH-LbB2FgMoSMaQ",
"snippet": {
"title": "Animal Planet",
"description": "Animal Planet is the world's only entertainment brand that immerses viewers in the full range of life in the animal kingdom with rich, deep content via multiple platforms and offers animal lovers and pet owners access to a centralized online, television and mobile community for immersive, engaging, high-quality entertainment, information and enrichment.",
"publishedAt": "2007-02-14T18:26:59.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/-FEsYkupUb-A/AAAAAAAAAAI/AAAAAAAAAAA/6SiqnVvRZJY/s88-c-k-no/photo.jpg"
},
"medium": {
"url": "https://yt3.ggpht.com/-FEsYkupUb-A/AAAAAAAAAAI/AAAAAAAAAAA/6SiqnVvRZJY/s240-c-k-no/photo.jpg"
},
"high": {
"url": "https://yt3.ggpht.com/-FEsYkupUb-A/AAAAAAAAAAI/AAAAAAAAAAA/6SiqnVvRZJY/s240-c-k-no/photo.jpg"
}
}
}
}
]
}

Youtube Data API v3 search query with Freebase topics id and date

I am trying to use the YouTube Data API to search video by using Freebase topics.
It works for a simple search with one topic but it doesn't work for a search with 2 parameters : a topic id and a "publishedAfter" date.
For example, to search for videos about Richard Branson (Freebase id = /m/0n839), the youtube data api site :
https://developers.google.com/youtube/v3/docs/search/list#try-it
with the parameters :
part : snippet
topicId : /m/0n839
show a result of 2165 videos
But when you try to search videos about id = /m/0n839 with
part : snippet
topicId : /m/0n839
publishedAfter : 2013-05-21T21:47:38Z
the response indicates 147 videos but only 3 videos are contained in the response.
In the response, you can see that the 3 video ids are J6PY5vxLU8Y, SCkFwpW3kiE, CBvDp0i8Iok.
{
"kind": "youtube#searchListResponse",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/_-rYO0M0nvpPO6QN7DPFGEYa9ho\"",
"pageInfo": {
"totalResults": 147,
"resultsPerPage": 5
},
"nextPageToken": "CAUQAA",
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/3nxQ-ejnv0qekcbyq09HD2RQt_w\"",
"id": {
"kind": "youtube#video",
"videoId": "J6PY5vxLU8Y"
},
"snippet": {
"publishedAt": "2013-05-22T09:58:34.000Z",
"channelId": "UCimPiDCqxvfqwVJltL4YzHg",
"title": "Bono, Richard Branson, and Olivia Wilde Joined Matt Damon's Strike!",
"description": "Support the strike: http://strikewithme.org/ Millions of celebrities have joined Matt Damon's \"Toilet Strike\" protesting the lack of access to safe water and...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/hqdefault.jpg"
}
},
"channelTitle": "water"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/gNslTbFkShGLlUBcXgHw7q9tuJc\"",
"id": {
"kind": "youtube#video",
"videoId": "SCkFwpW3kiE"
},
"snippet": {
"publishedAt": "2013-05-23T16:27:31.000Z",
"channelId": "UCeF4WiRKOA4XzphWYzR9aVw",
"title": "Sir Richard Branson dresses as an air stewardess after losing bet",
"description": "(Reuters) - A man was arrested at the Cannes film festival on Friday after firing a starting pistol during a live TV broadcast on the palm-lined waterfront, ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/SCkFwpW3kiE/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/SCkFwpW3kiE/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/SCkFwpW3kiE/hqdefault.jpg"
}
},
"channelTitle": "TheDailyPolitics247"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/-_OEOHhzgCBTLr7x5UoDk2kHlJM\"",
"id": {
"kind": "youtube#video",
"videoId": "CBvDp0i8Iok"
},
"snippet": {
"publishedAt": "2013-05-25T22:38:00.000Z",
"channelId": "UC2j75rAKcfjBAhW7WmNY4Qg",
"title": "Virgin Galactic Spaceship Passes Big Test (Y)",
"description": "A spaceship bankrolled by British tycoon Sir Richard Branson made its first engine-powered flight Monday. The test flight moves Virgin Galactic toward its go...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/CBvDp0i8Iok/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/CBvDp0i8Iok/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/CBvDp0i8Iok/hqdefault.jpg"
}
},
"channelTitle": "NewActionNews"
}
}
]
}
If you search for the next videos with nextPageToken : "CAUQAA", the response contains the same video ids (J6PY5vxLU8Y, SCkFwpW3kiE, CBvDp0i8Iok):
{
"kind": "youtube#searchListResponse",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/xMtmG2pQsuo_TFF8AtaaPea-cNc\"",
"pageInfo": {
"totalResults": 144,
"resultsPerPage": 5
},
"nextPageToken": "CAoQAA",
"prevPageToken": "CAUQAQ",
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/3nxQ-ejnv0qekcbyq09HD2RQt_w\"",
"id": {
"kind": "youtube#video",
"videoId": "J6PY5vxLU8Y"
},
"snippet": {
"publishedAt": "2013-05-22T09:58:34.000Z",
"channelId": "UCimPiDCqxvfqwVJltL4YzHg",
"title": "Bono, Richard Branson, and Olivia Wilde Joined Matt Damon's Strike!",
"description": "Support the strike: http://strikewithme.org/ Millions of celebrities have joined Matt Damon's \"Toilet Strike\" protesting the lack of access to safe water and...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/hqdefault.jpg"
}
},
"channelTitle": "water"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/cEIRgKqwt1aa9hcWMNtGTiCJImc\"",
"id": {
"kind": "youtube#video",
"videoId": "h7hJ3FDGWY8"
},
"snippet": {
"publishedAt": "2013-05-22T10:01:25.000Z",
"channelId": "UCqcE1T9zcUQyX3hHH4EM7sQ",
"title": "Sir Richard Branson in Dubai",
"description": "The man behind the Virgin brand stopped by Kris Fade's show last week - broadcasting from the Burj Khalifa, the world's tallest building.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/h7hJ3FDGWY8/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/h7hJ3FDGWY8/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/h7hJ3FDGWY8/hqdefault.jpg"
}
},
"channelTitle": "Kimberleyleonard"
}
}
]
}
Did I do something wrong ?
The "totalResults" attribute has, in previous versions of the API, always just been an estimated value that the search algorithms provide before actually retrieving any results, so it's likely safe to assume that is the case for v3 as well. However, it is a little odd that the estimate could be so far off; for your query, there really are just several results (5 or 6, I think ... as several have been uploaded since you made this initial post).
I've played around with various parameters for a bit, and it looks as though the factor which has the single-most influence as to the accuracy of the totalResults approximation is the 'q' parameter -- the more specific of a value you provide there, the more accurate the totalResults become.
Of course, in your query, then, the q parameter is empty, and the totalResults approximation is incredibly far off (in fact, if you change the publishedAfter parameter to be May 1st intead of May 21st, you actually get it approximating LESS total results, even though it's an earlier date!). If you do a query like this, however:
https://www.googleapis.com/youtube/v3/search?part=id&maxResults=50&publishedAfter=2010-05-01T21%3A47%3A38Z&topicId=%2Fm%2F0n839&key={YOUR_KEY}&q=Bran
Then you get a totalResults approximation that exactly matches the number of real results.
Of course this can be frustrating, because when incorporating Freebase IDs you often don't WANT to use the q parameter -- the whole point of freebase IDs is to use semantically relevant info that's based in more than just string matching! But it's clear that this is telling us something about the internal YouTube search algorithms and what they rely on. I'd venture that as Freebase integration becomes more mature, the search algorithms will be better able to adapt and you'll start seeing better totalResults approximations again.
As a workaround, you can use what you've noticed with the 'nextPageToken' to get a better count. In your query, set your maxResults to 50, and when you get actual results, have your routine count them. If they're less than 50, you've got them all. If it is 50 on that page, you might want to pre-fetch the next set of results (if they are new results, you're good to go, while if they are the same results as what you have, then you had exactly 50 responses). The one problem is that this will prevent you from displaying in your app an accurate count of total results (i.e. if you've got pagination going somewhere), so it's not perfect, but what workaround is?
I'm pretty sure the discrepancy between number of results and number actually shown is due to how date restrict ( start_time: 1369172858, the representation of "publishedAfter : 2013-05-21T21:47:38Z") is implemented.
By the way, I now see 10 matches, including the three mentioned.
First results are retrieved using the narrowist restrict range that includes the requested date range. That's how you can get ~140 matches. The videos that survive retrieval are then filtered, rejecting those outside the actual requested range. It's pretty plausible that 130 videos are dropped at that stage, leaving the 10 that actually satisfy the request.
The count of matches indicates number retrieved -- for date range, this will typically be an overestimate, possibly severe.
We generally don't warrant that the number reported as "matched" all actually match, since various kinds of filtering happen after retrieval.

How to Get All Movies (not videos) with YouTube V3 API

I want to list all the movies available on YouTube (i.e. those available via //youtube.com/movies). I can see how to query those using API V2, but this has a limit of 1000 responses.
With the V3 api I can see the category for movies has id 30, but I can't work out how to get all movies with this category. The only category queries appear to search on guide categories, which are different.
Any clues on how I can get this list? Please help if you can!
I believe that you can get the autogenerated channels, related to movies, and use their id to get the playlists related to this channels and finally the items (videos..) from this playlists, that must be the videos related to the movies of the selected channels:
Retrieve movie channels:
Request
https://www.googleapis.com/youtube/v3/search?part=snippet&q=movies&type=channel&key={YOUR_API_KEY}
Partial response
"items": [
{
"id": {
"kind": "youtube#channel",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ"
},
"kind": "youtube#searchResult",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/sQpwXP-0MUEZzOQx4F0yKj0eUR4\"",
"snippet": {
"publishedAt": "2005-12-15T03:07:36.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "movies",
"description": "YouTube Movies (United States).",
"thumbnails": {
"default": {
"url": "http://i.ytimg.com/i/czhp4wznQWonO7Pb8HQ2MQ/1.jpg"
},
"medium": {
"url": "http://i.ytimg.com/i/czhp4wznQWonO7Pb8HQ2MQ/mq1.jpg"
},
"high": {
"url": "http://i.ytimg.com/i/czhp4wznQWonO7Pb8HQ2MQ/hq1.jpg"
}
}
}
},
e.g. Get the list of movies in channel "YouTube Movies (United States)"
Request
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCczhp4wznQWonO7Pb8HQ2MQ&key={YOUR_API_KEY}
Partial response:
{
"id": "PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C",
"kind": "youtube#playlist",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/TWrkoCkmJvq14neCcutnApHMMgU\"",
"snippet": {
"publishedAt": "2012-12-06T20:11:40.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "The Nicolas Cage Collection",
"description": "From panicked fathers to spirits of vengeance, Nicolas Cage has done it all.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/hqdefault.jpg"
}
}
}
},
Get items from this playlist:
Request:
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C&key={YOUR_API_KEY}
Partial response:
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/KSlqEnNGq36l47_k9W3fd79KfYQ\"",
"pageInfo": {
"totalResults": 15,
"resultsPerPage": 5
},
"nextPageToken": "CAUQAA",
"items": [
{
"id": "PLcBtbpFAOApiV34TU797yEFAUZuwhFrvJya3MqlZWkGM",
"kind": "youtube#playlistItem",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/C_xTa48Xof7giXobSula2vWX43A\"",
"snippet": {
"publishedAt": "2012-12-06T20:12:49.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "Stolen",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/nHiy8SVZdpU/hqdefault.jpg"
}
},
"playlistId": "PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "nHiy8SVZdpU"
}
}
},
{
"id": "PLcBtbpFAOApiV34TU797yED-1zeMCoMGVxtVgtX9ZdsQ",
"kind": "youtube#playlistItem",
"etag": "\"eTr3dHIt5_K9qdGtRKL-5XdpiQI/LgSyqtZkwJXv6-2ajW0g-FsgddQ\"",
"snippet": {
"publishedAt": "2012-12-06T20:19:26.000Z",
"channelId": "UCczhp4wznQWonO7Pb8HQ2MQ",
"title": "Trespass",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/J_7Zug6ouy4/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/J_7Zug6ouy4/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/J_7Zug6ouy4/hqdefault.jpg"
}
},
"playlistId": "PLjygWhZE6KY0Uhw12FsAc8raAClz0l71C",
"position": 1,
"resourceId": {
"kind": "youtube#video",
"videoId": "J_7Zug6ouy4"
}
}
},
and in this way you can create the list of videos as you want
Here's my current answer - still working on it so I've not accepted it yet
I worked out the categoryId for Movies is 30. I then did a search for videos using this categoryId, and the query string "movie" (just because I need to put something). This gives more than 1000 results, and google limits queries to 1000 results even with the v3 api.
So I need to partition my query. I have been able to do this with publishedBefore and publishedAfter. Note these are upload dates and not release dates.
This gives me a list of movies.
Here's a sample query
https://www.googleapis.com/youtube/v3/search?nextPageToken=CDIQAA&publishedBefore=2010-02-01T00%3A00%3A00Z&maxResults=50&q=movie&videoCategoryId=30&part=id%2Csnippet&key=yourAPIKeyHere&type=video&publishedAfter=2010-01-01T00%3A00%3A00Z
Once I have the movie IDs I query the individual movie ids
https://www.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails&maxResults=50&id=O7cSKNevYQc%2CN84-SoboM6c%2C9K_WO3lqDSc%2CWTJP0Z-bknc%2CdF9hwjeRbGE%2CPnefvJ9T1N0%2CDuM6B4yKgTU%2C0tI8iP2f58I%2Cr4lNJEnY0FA%2COFnMrx6yEcA%2CmUZUAeqOmbg%2CDjq0tHK-KTo%2CkY44nxk0qjg%2CcLYkUR5MY14%2CTZpcfYOOEXA%2C-0jA9DMX8Qs%2C2TQDV1m4X2s%2CBh3Tye1OQvk%2Ct5IwjMDVNz4%2CkOi88X6xeKg%2Ck53CuaAUtik%2CNaRuenqLb9g%2Cn9h-0Wgix7Q%2CQG8SiW2a_l0%2Cmk-D66Z1Ydg%2ClvmwofckpNc%2CgRQK4fTXfBM%2CPZHgLy48R3Q%2CwczeO0DVM0g%2CTpMDTG3dEYE%2C6JI8pN7BqEQ%2COv9yllk3hsY%2CsN09sfLPu0g%2CbfhLYJGN948%2CPiWusdK75Ys%2CeE5jh0YwTCY%2C_cIw3vr2Q18%2CSA4xg_k0aqI%2CUZdha0zTM6w%2CwUdkDSIBw94%2CAhR-LDSIOaI%2C1XMt40vJayU%2C83fPx5-aUL8%2CmJLjaKzu7PQ%2CZvj_zRGnwU0%2CtyIPMd7JXOA%2CToE10sC36KQ%2COVKXjOW6cD8%2CLPW1cXVjMrg&key=LALALA
I still then need to filter the results by looking at the following json in the results
"contentDetails": {
"duration": "PT1H35M14S",
"regionRestriction": {
"allowed": [
"US"
]
}
Unfortunately this still doesn't give me the movie year or director (which are useful for working out which movie this actually is), or the price (which, you know, people find interesting)

Resources