YouTube API thumbnail urls not resolving - youtube

I am hoping this is a one off, but today I came across a video that reports the following when calling the "Videos: list" endpoint by a videoId:
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/**uEGlS01**/maxresdefault.jpg",
"width": 1280,
"height": 720
}
}
... but neither the "maxres" or "standard" urls render an image (they 404 and render the nasty YouTube default grey image). Usually when those sizes were not available, those objects were not in the array.
Can anyone shed some light on this?
EDIT **
I should mention that the remainder of the thumb urls work as expected and embedding of the video fails to render a poster image with the exception of Chrome on desktop (which uses WEBP)

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.

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?

Facebook Graph API get photos returns with duplicated size.? Can I reduct the return?

How should I removed the duplicated size photos?
I just want one size for each photo.
But it returns images array and each array is one image with different sizes.
The service I'm calling is:
{user-id}/photos/uploaded?fields=images
returns:
"data": [
{
"images": [
{
"height": 960,
"source": "https://scontent.xx.fbcdn.net/hphotos-ash2/v/t1.0-9/10734238_10204858324278565_766379049543592577_n.jpg?oh=6ece9809697d2ca4019087d2173702d3&oe=56D2FB6C",
"width": 720
},
{
"height": 800,
"source": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-ash2/v/t1.0-0/p600x600/10734238_10204858324278565_766379049543592577_n.jpg?oh=8aabb9ba4538fdcf853b8c9107601f15&oe=56941F5E&__gda__=1455658621_d167345958233195768c68333d481f1a",
"width": 600
},
{
"height": 640,
"source": "https://fbcdn-photos-c-a.akamaihd.net/hphotos-ak-ash2/v/t1.0-0/p480x480/10734238_10204858324278565_766379049543592577_n.jpg?oh=2810aba0ea4eda0ee5ff73b5df75a70c&oe=56C3DF77&__gda__=1452026196_7d112ea2ad4fa41b108a883a27819241",
"width": 480
},

Get all playlist ids from channel id - youtube api v3

I am currently learning the use of the youtube api. I want to retrieve all playlists id from a channel id. I read through the documentation and saw that I can use youtube.channels.list for such task. I did basic testing on the api_page. Still, I am not able to figure what params to use to get the playlist id. How can I retrieve all playlist ids from a given channel id?
https://www.googleapis.com/youtube/v3/channels?part=id&id=UCF0pVplsI8R5kcAqgtoRqoA&key={YOUR_API_KEY}
A simple way :
With the YouTube API v3 with the ressource playlists.list
Use this parameters to get the playlists ID of a channel :
part: 'snippet'
channelId: 'UCBkNpeyvBO2TdPGVC_PsPUA'
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCBkNpeyvBO2TdPGVC_PsPUA&key={YOUR_API_KEY}
The output :
"items": [
{
"kind": "youtube#playlist",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/K21sgPQuMRCjhSMBjm3v3n5tl1o\"",
"id": "PL2qcutlDmS0CnyV8Jcbl2d7yFxd2iGg67",
"snippet": {
"publishedAt": "2014-07-08T03:13:37.000Z",
"channelId": "UCBkNpeyvBO2TdPGVC_PsPUA",
"title": "These Things Happen Series",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/93mgU_VXZrA/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "GEazyTV"
}
},
{
"kind": "youtube#playlist",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/5ifuvTYKbyV6DUPqbTa2bnO2jWY\"",
"id": "PL2qcutlDmS0B0jwHOQYzgRhJpnxDwPBHc",
"snippet": {
"publishedAt": "2014-06-05T07:36:58.000Z",
"channelId": "UCBkNpeyvBO2TdPGVC_PsPUA",
"title": "B-Sides",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/f7Ua9wKvVtI/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "GEazyTV"
}
},
...
This is a sample example with a random channel.
If you don't know how to get the channelID of a channel use ressource channels.list:
With this parameters to get the video ID of a playlist :
part: 'id'
forUsername: 'channel_name'
https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=GEazyTV&key={YOUR_API_KEY}
"items": [
{
"kind": "youtube#channel",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/vIwM6ev74Om0AOupX26jJoEDELU\"",
"id": "UCBkNpeyvBO2TdPGVC_PsPUA"
}
I'm not sure how I came across this solution, but I've found that if you follow these steps then you can retrieve the playlistID to use:
Create an API Key using the Google API Console.
Use
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&key=[KEY FROM GOOGLE API CONSOLE]&id=[CHANNEL ID]
where you are replacing everything, including the brackets, with the corresponding info (I find channel ids are easy to come by since they are normally in the URL. The PlaylistID is the one that tends to be difficult).
The resulting feed from the URL in step 2 should contain an uploads object, containing the playlistID which is used in the URL in step 4.
Use
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=[PLAYLIST ID RETRIEVED IN STEP 3 HERE]&key=[KEY FROM GOOGLE API CONSOLE]
The link from step 4 is what should end up being used in the app.
This works for me every time, and I integrate the YouTube v3 API in many apps. I completely agree with #Utkanos' comment that while #mpgn's answer works sometimes, it certainly doesn't work for all channels.
Youtube Api v3 Channel Playlist video max 50
This url format work
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=[]&key=[]&maxResults=50

Resources