How to detect youtube pay videos using api v3 - youtube

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.

Related

Retrieve Channels-Tab from YouTube Channel via YouTube-API

As you may know some Content-Creators on YouTube not only got one Channel. Some Channels have a Channel-Tab where you can see the other channels hosted by the creator. I would like to get these channels, but unfortunately the YouTube-API can't retrieve the data via channels: list. Is there a parameter or another function how I can get this information?
Channel example: https://www.youtube.com/c/DunklerParabelritter/channels
Thank you in advance,
Aaron!
It seems that once again YouTube Data API v3 doesn't provide a basic feature.
I would recommend you to use my open-source YouTube operational API. Indeed by requesting the JSON document https://yt.lemnoslife.com/channels?part=channels&id=CHANNEL_ID the data you are looking for are in item["channelSections"].
Note that the channel id associated to the channel you shared is UCK4LDHLxBqiAtcwCm4z7DRg, so you would obtain:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UCK4LDHLxBqiAtcwCm4z7DRg",
"channelSections": [
{
"title": "Mit Empfehlung des Dunklen!",
"sectionChannels": [
{
"channelId": "UCWZu-P34DVZUVrYAROU3Cmw",
"title": "Prinz",
"thumbnails": [
{
"url": "https:\/\/yt3.googleusercontent.com\/knQfgyidSRlVLQfAw64R9DFWmnQt3BwdJUaRW1zHEVRgLswRcR9lsan_S4tGe4BfYJyo9Jppbg=s48-c-k-c0x00ffffff-no-rj-mo",
"width": 48,
"height": 48
},
...
],
"videoCount": 128,
"subscriberCount": 111000
},
...
],
"nextPageToken": null
}
]
}
]
}

Youtube api set a dimension

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

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.

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

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

Resources