Find out if youtube video is GEMA protected - youtube

I am looking to find out wether a video on youtube is blocked (in germany) because its GEMA protected. Ideally via the youtube API.
I would like to know if its protected before the player tells me so.
An example for an video which is GEMA protected (the protection only occurs with german ip):
https://www.youtube.com/watch?v=BgfcToAjfdc

You can check this in an HTTP request by using search.list and specifying part=contentDetails. contentDetails has a blocked section that gives you the region code of any countries where the video is blocked.
For example, for this video, you would call:
https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=BgfcToAjfdc&key=[API_KEY]
And you get:
{
"kind": "youtube#videoListResponse",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/wC5hYBNHuSGatyO7FsTaHrWY5HI\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/4dW1h00OUpXXhtaz2M71v9cXGsQ\"",
"id": "BgfcToAjfdc",
"contentDetails": {
"duration": "PT5M26S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": false,
"regionRestriction": {
"blocked": [
"DE"
]
You can see in the blocked section that the video is blocked in Germany.

Related

YouTube Data API video duration is 1 second longer

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?

Localization data missing from Youtube data API

I am currently using the Youtube data API trying to get localised subtitle data and while this works for most videos it isn't working for this one: https://www.youtube.com/watch?v=Q0FhXknxYj4. The video has Danish subtitles but when you use the API or API demo (setting part as localization) here: https://developers.google.com/youtube/v3/docs/videos/list there is no subtitle data.
Example response for working video:
{
"kind": "youtube#videoListResponse",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/zgsYC3imu6Fd_dFVfGFSGv4yads\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/3xUeT9GTC6osUJsmbTXqY1OMfsc\"",
"id": "S3YnYrcD1sQ",
"localizations": {
"da": {
"title": "København: Europas første markedsplads for byrelaterede data - Hitachi",
"description": "Hitachi skaber en datamarkedsplads for Danmarks hovedstad, der skal styrke innovationen.\n\nhttp://www.hitachi.eu/en/case_studies/city-data-exchange"
},
"en": {
"title": "Copenhagen: Europe's first city data exchange - Hitachi",
"description": "Hitachi is creating a data marketplace for Denmark's capital, to help power innovation.\n\nhttp://www.hitachi.eu/en/case_studies/city-data-exchange"
}
}
}
]
}
Example response for broken video (Q0FhXknxYj4):
{
"kind": "youtube#videoListResponse",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/UrnoPP0xkF1sGZFODge_h_h01KU\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/Y82zqHiktkqS1qFvTSCoJ5BEJas\"",
"id": "Q0FhXknxYj4"
}
]
}
Does anyone know why the API might not pull in the localisation data even though the subtitles are there?
Many thanks,
Emily
Your first example does not contain any subtitle data either. It only contains localizations of the video title and description.
You need to be using captions, not list, to list subtitle details.

YouTube Data API V3 search list returns different results than youtube search

I'm trying to use the YouTube data api v3 to get the most viewed videos for a channel. This other SO question said the best way to do this is "search->list with specifying the channelId and order = viewcount".
What I've found is this result sometimes differs from what I see by directly going to a YouTube channel.
For a specific example, I'm looking at this channel:
https://www.youtube.com/user/TheGIIF/videos
It has 3 videos.
Compare that with the following request:
GET https://www.googleapis.com/youtube/v3/search?order=viewCount&part=id&channelId=UCKvRfU5Yaf8XijZPXFJfmlg&key={YOUR_API_KEY}
This returns the following json:
{
"kind": "youtube#searchListResponse",
"etag": "\"k1sYjErg4tK7WaQQxvJkW5fVrfg/xXXGtXCJVmIX8cvSbV7aTD43t0g\"",
"pageInfo": {
"totalResults": 2,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"k1sYjErg4tK7WaQQxvJkW5fVrfg/pX-Ao3RW_w2XWZZfiA3_50lj7Ks\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCKvRfU5Yaf8XijZPXFJfmlg"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"k1sYjErg4tK7WaQQxvJkW5fVrfg/5uoVIdj1bFGaDCWnwAVwP1RwTyI\"",
"id": {
"kind": "youtube#video",
"videoId": "EsX40Bu84O0"
}
}
]
}
So only one available video. Why the discrepancy?
And, not sure if this is just coincidental, but if I search the channel name within the channel:
https://www.youtube.com/user/TheGIIF/search?query=thegiif
I only get back 1 video, the same video as the json response above.

Video meta data using YouTube Data API v3

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"
]
}
}
}
]
}

Youtube API v3 returning different or missing playlists

I'm having some problems with the v3 API when getting playlists by ID.
I have a javascript app that allows you to search for playlists (via a call to www.googleapis.com/youtube/v3/search) then save those playlists to one of several "devices", which is then persisted on the server. When you return, the page gets the devices and the list of Youtube playlist IDs associated. To display more details (name, image, etc), call(s) are made to www.googleapis.com/youtube/v3/playlists.
The problem is that /playlists doesn't seem to be returning valid playlists. The most bare-bones test-case is a call to:
https://www.googleapis.com/youtube/v3/playlists?key=KEY&part=id%2Csnippet&id=PL736C3116AD309B58
which returns
{
"kind": "youtube#playlistListResponse",
"etag": "\"5cYuq_ImPkYn_h2RKDdX8DHvM2g/T0etSAnItCRUAPOtHRCu92sMKQU\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": []
}
Note that it shows "totalResults: 1", but 0 actual results.
A call to the youtube website for the same playlist ID (http://www.youtube.com/playlist?list=PL736C3116AD309B58) shows a valid playlist.
This used to work.
I'm not authenticating with oauth, but I'm comparing the results against non-authenticated web requests or against the non-oauthed API searches.
I have no idea why this is the case, but when clicking on one of the videos in the playlist you linked to, it shows SP736C3116AD309B58 as the playlistId (notice the prepending SP instead of PL). However, I verified that the PL id was indeed to the one showing up in search...
But a call to this endpoint gives you the data you're looking for...
Call:
https://www.googleapis.com/youtube/v3/playlists?key={API_KEY}&part=id%2Csnippet&id=SP736C3116AD309B58
Response:
{
"kind": "youtube#playlistListResponse",
"etag": "\"5cYuq_ImPkYn_h2RKDdX8DHvM2g/iOZzhrEf1VYbGO25CZhT4ga_Gw4\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"id": "SP736C3116AD309B58",
"kind": "youtube#playlist",
"etag": "\"5cYuq_ImPkYn_h2RKDdX8DHvM2g/U04KGNFEmQkvMoEC7XrbSayIGUY\"",
"snippet": {
"publishedAt": "2009-04-21T15:23:31.000Z",
"channelId": "UCNYrK4tc5i1-eL8TXesH2pg",
"title": "Auto-Tune the News",
"description": "The only news you need has a bass line",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/hMtZfW2z9dw/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/hMtZfW2z9dw/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/hMtZfW2z9dw/hqdefault.jpg"
}
}
},
"status": {
"privacyStatus": "public"
}
}
]
}
Is there any reason you aren't just capturing this data in the actual Search call?

Resources