I tried to set 3d dimension flag in Videos.insert and Videos.update query. But the flag doesn't change.
Update query example:
Request:
PUT https://www.googleapis.com/youtube/v3/videos?part=contentDetails&key={YOUR_API_KEY}
{
"id": "g8X8zeL0uEQ",
"contentDetails": {
"dimension": "3d"
}
}
Response:
200
- SHOW HEADERS -
{
"kind": "youtube#video",
"etag": "\"0Fu6lI6VPLdRMlQU3wwNcowdAUs/fSl6VDWHqWRlQ_1QhmdiESxxFiY\"",
"id": "g8X8zeL0uEQ",
"contentDetails": {
"duration": "PT7S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": false,
"projection": "rectangular"
}
}
You can use contentDetails.dimension to set dimensions flag for videos. It indicates whether the video is available in 3D or in 2D. The contentDetails object contains information about the video content, including the length of the video and an indication of whether captions are available for the video. But insert and update query are not able to set 3D flag.
"contentDetails": {
"duration": string,
"dimension": string,
"definition": string,
"caption": string,
"licensedContent": boolean,
"regionRestriction": {
"allowed": [
string
],
"blocked": [
string
]
},
Related
For example, the HTTP request GET https://www.googleapis.com/youtube/v3/videos?id=kjDwZNs6GLs&part=contentDetails&key=[API_KEY] gives back the below response payload:
{
"kind": "youtube#videoListResponse",
"etag": "fMWPUAE-QPUqczFLIOqPLkA_HBs",
"items": [
{
"kind": "youtube#video",
"etag": "JVU1XymxBIBUDHOdlmlwJ1nlhTM",
"id": "4ZkEob55qso",
"contentDetails": {
"duration": "PT2M4S",
"dimension": "2d",
"definition": "sd",
"caption": "false",
"licensedContent": true,
"contentRating": {},
"projection": "rectangular"
}
}
],
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
}
}
The duration in the JSON payload is PT2M4S, but if you go check the actual video on YouTube https://www.youtube.com/watch?v=4ZkEob55qso the duration displayed in the video player is 2:03. I couldn't find any mention of this discrepancy in the API documentation https://developers.google.com/youtube/v3/docs/videos#contentDetails.duration, does anyone know exactly why the YT Data API gives back a 1-second longer video duration?
Is there any way to know whether a video is free or paid?
What property is indicates videos which needs Payment?
https://www.youtube.com/watch?v=wWu03qUnHlk
{
"kind": "youtube#video",
"etag": "\"_gJQceDMxJ8gP-8T2HLXUoURK8c/9J_Rsvw1p9XGci8Ne9GRDP6m6NE\"",
"id": "wWu03qUnHlk",
"contentDetails": {
"duration": "PT1H11M51S",
"dimension": "2d",
"definition": "hd",
"caption": "true",
"licensedContent": true,
"regionRestriction": {
"allowed": [
"US"
]
},
"projection": "rectangular"
}
}
No such feature in the Youtube API. All the video properties are found in Youtube Resource Representation and there's no property that indicates if it's paid or not.
This is confirmed by a Google Engineer in this post.
Using the Youtube Data API's Channels:list with the brandingSettings part works when using the id filter but not the forUsername filter for me.
For example, GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&forUsername=h3h3Productions&key={YOUR_API_KEY} results in the following, which is missing brandSettings:
{
"kind": "youtube#channelListResponse",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/Qagk6ayL_umilQ398UZyAHwxK_g\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/tTzKQvYs0Y2GpqN2wqgudxB2TnQ\"",
"id": "UCDWIvJwLJsE4LG1Atne2blQ"
}
]
}
But GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UCDWIvJwLJsE4LG1Atne2blQ&key={YOUR_API_KEY} (which you'll notice uses the ID of the same user), leaves it intact:
{
"kind": "youtube#channelListResponse",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/2ZOHdezDOZFRR9xisREY04R4OOg\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/58_5G5_Hi-64MiC8m5NC76sDIOA\"",
"id": "UCDWIvJwLJsE4LG1Atne2blQ",
"brandingSettings": {
"channel": {
"title": "h3h3Productions",
"description": "Wacky, zany, goofy comedy. ",
"keywords": "comedy humor satire parody funny sketch \"sketch comedy\" reaction \"reaction video\" review h3h3 h3h3productions",
"showRelatedChannels": true,
"showBrowseView": true,
"featuredChannelsTitle": "SECOND CHANNEL",
"featuredChannelsUrls": [
"UC7pp40MU_6rLK5pvJYG3d0Q"
],
"unsubscribedTrailer": "tVaAv0cPRok",
"profileColor": "#000000",
"country": "US"
},
"image": {
"bannerImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1060-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerMobileImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w640-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTabletLowImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1138-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTabletImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1707-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTabletHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w2276-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTabletExtraHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w2560-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerMobileLowImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w320-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerMobileMediumHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w960-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerMobileHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1280-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerMobileExtraHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1440-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTvImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w2120-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTvLowImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w854-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTvMediumImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1280-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg",
"bannerTvHighImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1920-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg"
},
"hints": [
{
"property": "channel.banner.mobile.medium.image.url",
"value": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w640-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg"
},
{
"property": "channel.banner.image_height.int",
"value": "0"
},
{
"property": "channel.featured_tab.template.string",
"value": "Everything"
},
{
"property": "channel.modules.show_comments.bool",
"value": "True"
}
]
}
}
]
}
Am I doing something wrong? Keeping everything the same but switching the part to snippet or statistics works how you'd expect in both cases. I've also tried this on a few more channels and get the same results.
I think this is working as intended. See YouTube API - No channel branding settings returned for queries by username. Tl;dr: even though you can look for channels by using their usernames, the migration from V2 carried with it the fact that not every YouTube channel has a unique username, so that's why it works correctly when you use the channel ID (which is unique). I also tried it by specifying forMine instead of the channel ID and it worked as expected.
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.
By using search example, i am able to get video details like name, id, thumb nail URL. But how can i get video total duration using YouTube Data API. Thanks in advance.
You will have to make a call to the Youtube Data API's Video resource after you make the search call. You can put up to 50 video id's in search, so you wont have to call it for each element.
https://developers.google.com/youtube/v3/docs/videos/list
You'll want to set part=contentDetails, because duration is there.
For example the following call:
https://www.googleapis.com/youtube/v3/videos?id=9bZkp7q19f0&part=contentDetails&key={YOUR_API_KEY}
Gives this result:
{
"kind": "youtube#videoListResponse",
"etag": "\"XlbeM5oNbUofJuiuGi6IkumnZR8/ny1S4th-ku477VARrY_U4tIqcTw\"",
"items": [
{
"id": "9bZkp7q19f0",
"kind": "youtube#video",
"etag": "\"XlbeM5oNbUofJuiuGi6IkumnZR8/HN8ILnw-DBXyCcTsc7JG0z51BGg\"",
"contentDetails": {
"duration": "PT4M13S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": true,
"regionRestriction": {
"blocked": [
"DE"
]
}
}
}
]
}