Localization data missing from Youtube data API - youtube

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.

Related

Find out if youtube video is GEMA protected

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.

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.

Youtube API 3.0 search videos and get video statistics at single request

I'm searching youtube videos with youtube api 3.0.
I'm using this type of example API request
https://www.googleapis.com/youtube/v3/search?part=snippet&key=[API_KEY]
But i want to get statistics of videos with in the same api request. How to solve this problem.
Note: When I'm using statistics key with part. I got error.
I'm also tried this request
https://www.googleapis.com/youtube/v3/search?part=snippet,statistics&key=[API_KEY]
The resource search.list don't have the part statistics.
Step 1 :
You need to get the videoId of the video: "videoId": "UHdgXkkVyl0" with search.list.
The request :
https://www.googleapis.com/youtube/v3/search?part=id&q=tuto&type=video&key={YOUR_API_KEY}
The response:
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/34CzOO9FXYQg7kdlOeoe59LsWVk\"",
"id": {
"kind": "youtube#video",
"videoId": "UHdgXkkVyl0"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/U303dB0TgZ89ODlqdwuKs5efOdk\"",
"id": {
"kind": "youtube#video",
"videoId": "LvEA2KHWQec"
}
},
Step 2 :
After you have searched videos with search.list you need to make a second call to the API with the resource video.list with parameters :
part: statistics
id: "id of the video found in previous request"
If you have more than one video id you can specify the id of videos with a comma-separated list like :
id: "Xxsdw6zG1bg, Xxsdw6zG1bg,...." )
The request: https://www.googleapis.com/youtube/v3/videos?part=statistics&id=UHdgXkkVyl0%2C+Xxsdw6zG1bg&key={YOUR_API_KEY}
The response will be like this :
{
"kind": "youtube#videoListResponse",
"etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/rxvjZzq2nNqBg7Me5VQv1ToZm64\"",
"pageInfo": {
"totalResults": 2,
"resultsPerPage": 2
},
"items": [
{
"kind": "youtube#video",
"etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/3fah-cngFxFOnytseMYZU1TK_-8\"",
"id": "UHdgXkkVyl0",
"statistics": {
"viewCount": "3070836",
"likeCount": "72140",
"dislikeCount": "1132",
"favoriteCount": "0",
"commentCount": "7798"
}
},
{
"kind": "youtube#video",
"etag": "\"MmqJLb8ZBOWRQIsg7xej7lrKLMI/J4xM7Dd23TGYU6on-PESyEIAE9A\"",
"id": "Xxsdw6zG1bg",
"statistics": {
"viewCount": "131487",
"likeCount": "1459",
"dislikeCount": "25",
"favoriteCount": "0",
"commentCount": "39"
}
}
]
}
And you have the statistics !
Unfortunately, dislikeCount attribute has became private, in december 2021. according the youtube api docs.

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 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