In Youtube data api v3 GET Videos request, what exactly indicates that video has been checked and is marked age restricted? - youtube-api

Youtube data API GET Videos request has field "contentDetails.contentRating.ytRating" (indicated here.
But for some of the videos, the field "contentRating" is empty, thus does not contain ytAgeRestricted value. Does that mean that those videos are NOT age restricted? Or it means that those videos are simply have not been checked by Youtube? Are there any videos which are not checked by Youtube and have no indication on age restriction?
Example of video ID with empty contentRating in response - k5fmfdQU5lw
{
"videoInfo": {
"etag": "m4HIaaqSXP5OLjanlhkLAZUQK8o",
"items": [
{
"contentDetails": {
"caption": "false",
"contentRating": {},
"definition": "hd",
"dimension": "2d",
"duration": "PT20M10S",
"licensedContent": true,
"projection": "rectangular"
}
}
]
}
}

Related

Create OnlineMeeting in MS Graph with Call-in Info

I am building some utilities to automate aspects of Microsoft Teams at my company. One thing we are trying is automating scheduling/creation of Online Meetings under various circumstances. Overall this is working fine, but I can't figure out how to get / attach telephone call-in information for the calls we're creating.
Here's an example POST /app/onlineMeetings:
{
"meetingType": "meetNow",
"participants": {
"organizer": {
"identity": {
"user": {
"id": "<user-id>"
}
}
}
},
"subject": "Personal Room"
}
And here's what a typical response looks like:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#app/onlineMeetings/$entity",
"joinUrl": "<join-url>",
"subject": "Personal Room",
"isCancelled": false,
"meetingType": "MeetNow",
"accessLevel": "SameEnterprise",
"id": "<meeting-id>",
"audioConferencing": null,
"meetingInfo": null,
"participants": {
"organizer": {
"upn": "<user-name>",
"sipProxyAddress": "<user-name>",
"identity": {
}
},
"attendees": []
},
"chatInfo": {}
}
As you can see, the audioConferencing key is null. If a user accesses the joinUrl, they can join the call and audio conferencing information is displayed at that time -- but I can't figure out how to get it out in advance (e.g. to send in an email).
Also note that since this is not a VTC-enabled meeting, the id can't be used to issue a new GET request for additional information, as discussed here

Can't Delete Youtube Subscription With API

I have the code setup for the Youtube API with oauth login. Login appears to work properly. I can even see the requests hitting my analytics. However, when I run the code to unsubscribe from a channel, it never works on any channel ID I give it. It should be noted that I'm using the exact example from googles dev docs(see "full sample" option for javascript)... I'm guessing the code is correct and this is some other auth/lookup problem.
API code:
alert("deleting steven!!!!!!");
buildApiRequest('DELETE',
'/youtube/v3/subscriptions',
{'id': 'UCMtFAi84ehTSYSE9XoHefig'});
Stock Youtube API Code:
function executeRequest(request) {
request.execute(function(response) {
console.log(response);
});
}
function buildApiRequest(requestMethod, path, params, properties) {
params = removeEmptyParams(params);
var request;
if (properties) {
var resource = createResource(properties);
request = gapi.client.request({
'body': resource,
'method': requestMethod,
'path': path,
'params': params
});
} else {
request = gapi.client.request({
'method': requestMethod,
'path': path,
'params': params
});
}
executeRequest(request);
}
Here is the error:
{
"error": {
"errors": [
{
"domain": "youtube.subscription",
"reason": "subscriptionNotFound",
"message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
}
],
"code": 404,
"message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
}
}
Remember that the ID you have to send is not the channel ID. It's the ID of the subscriptions.
You can get it by sending request to check your subscriptions with the channel. For example
Request:
buildApiRequest('GET',
'/youtube/v3/subscriptions',
{'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
'mine': 'true',
'part': 'snippet,contentDetails'});
Response:
{
"kind": "youtube#subscription",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
"id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
"snippet": {
"publishedAt": "2018-09-30T16:51:47.000Z",
"title": "Rebeca Willett",
"description": "",
"resourceId": {
"kind": "youtube#channel",
"channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
},
"channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
"thumbnails": {
...
}
Using ID in the response to send request for unsubscribing:
buildApiRequest('DELETE',
'/youtube/v3/subscriptions',
{'id': 'Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M'});
Here is the google docs for getting subscriptions ID

Youtube Data API v3 PlaylistItems update not working for Watch Later playlists

Recently, the youtube.playlistItems.list doesn't fetch a playlist item that is suitable for the youtube.playlistItems.update when listing the watchLater playlist. Its works perfectly for playlist that aren't under the relatedPlaylists category of a channel. (e.g. History, favourite, likes etc.)
My list response looks like this:
{
"items": [
{
"id": "V0xWWlh5N2JrM0JSTjAtcDJVUmdjc3JRLjZCM0UwMDFFNUU3NzYzNjc=",
"snippet": {
"publishedAt": "2016-03-21T19:04:22.000Z",
"title": "One Word - Episode 38: Skin Tone (Black Women)",
.
.
.
"channelTitle": "Ryan Carter",
"playlistId": "WLVZXy7bk3BRN0-p2URgcsrQ",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "0gYgzN6B0y4"
}
}
},
But when I use those values:
PUT https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cid&key={YOUR_API_KEY}
{
"id": "V0xWWlh5N2JrM0JSTjAtcDJVUmdjc3JRLjZCM0UwMDFFNUU3NzYzNjc=",
"snippet": {
"playlistId": "WLVZXy7bk3BRN0-p2URgcsrQ",
"resourceId": {
"kind": "youtube#video",
"videoId": "0gYgzN6B0y4"
}
}
}
I get:
404 null
- Show headers -
{
"error": {
"errors": [
{
"domain": "youtube.playlistItem",
"reason": "playlistItemNotFound",
"message": "Playlist item not found."
}
],
"code": 404,
"message": "Playlist item not found."
}
}
Down for just me?
Have Google blocked updates for the Watch Later playlist?
Is the service broken?
Looks like the "bug" was just part of the transition period where YouTube planned to remove the ability to fetch the Watch Later and Watch History playlist through there API. As Tym commented the "bug" is/was tracked here: https://code.google.com/p/gdata-issues/issues/detail?id=8145 .
TLDR:
"Requests to retrieve playlist details (playlists.list) for a channel's watch history or watch later playlist will return an empty list after September 12, 2016. Requests to retrieve playlist items (playlistItems.list) in either of those playlists will also return an empty list after that time. This is true for the new values, HL and WL, as well as for any watch history or watch later playlist IDs that your API Client may have already stored."
https://developers.google.com/youtube/v3/revision_history#september-15-2016

Multiple Invideo promotion using YouTube api

I have to update multiple invideo promotion details for a particular channel.
My request is as follows:
var requestOptions={
part: 'invideoPromotion',
onBehalfOfContentOwner: 'contentOwner',
resource:{
id: channelId,
invideoPromotion: {
"defaultTiming": {
"offsetMs": 2000,
"type": "offsetFromStart"
},
"items": [
{
"promotedByContentOwner": true,
"timing":
{
"offsetMs":4000,
"duration" : 5000,
"type":"offsetFromStart"
},
"id":{
"videoId": videoid1,
"type": "video"
}
},
{
"promotedByContentOwner": true,
"timing":
{
"offsetMs":11000,
"duration" : 5000,
"type":"offsetFromStart"
},
"id":{
"videoId": videoId2,
"type": "video"
}
}
],
"position": {
"type": "corner",
"cornerPosition": "topLeft"
}
}
}
};
console.log(requestOptions);
var request = gapi.client.youtube.channels.update(requestOptions);
request.execute(function (response) {});
But when i try to execute this, I am getting error
0: {error:{code:500}, id:gapiRpc}
error: {code:500}
code: 500
id: "gapiRpc"
Even When I try to do this using the youtube api explorer
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.update ,
I am getting Internal server Error.
Can somebody let me know where I am going wrong.
You cannot promote more than one video. I also tried the same but getting an error "exceeded the number of promoted items". So you can only promote one video at a time.

Getting title and description of embedded YouTube video

On a site I'm developing I embed videos from YouTube and want to get the video title and its description.
How do I get that information?
You can do it with oembed.
Example:
http://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3DM3r2XDceM6A&format=json
Youtube API V2.0 has been deprecated. It shows some wrong value for title "youtube.com/devicesupport" . pLease switch on to API V3.0
YOu can refer the following PHP code and modify yours in js or jquery as per your needs..
function youtube_title($id) {
$id = 'YOUTUBE_ID';
// returns a single line of JSON that contains the video title. Not a giant request.
$videoTitle = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=".$id."&key=YOUR_API_KEY&fields=items(id,snippet(title),statistics)&part=snippet,statistics");
// despite # suppress, it will be false if it fails
if ($videoTitle) {
$json = json_decode($videoTitle, true);
return $json['items'][0]['snippet']['title'];
} else {
return false;
}
}
update:
Jquery code to get the title-
$.getJSON('https://www.googleapis.com/youtube/v3/videos?id={VIDEOID}&key={YOUR API KEY}&part=snippet&callback=?',function(data){
if (typeof(data.items[0]) != "undefined") {
console.log('video exists ' + data.items[0].snippet.title);
} else {
console.log('video not exists');
}
});
To get the DESCRIPTION element, you need to access the gdata version of the video's info, and you can return json using alt=json on the path. In this case, oHg5SJYRHA0 is the video ID, found at the end of the url of the video you're working with on YouTube, e.g.
www.youtube.com/watch?v=oHg5SJYRHA0
http://gdata.youtube.com/feeds/api/videos/oHg5SJYRHA0?v=2&alt=json&prettyprint=true
(the prettyprint is formatting to make that easy to read, you don't need it for what you're doing)
You can grab the JSON, add it into a variable and access it using jQuery:
var youTubeURL = 'http://gdata.youtube.com/feeds/api/videos/oHg5SJYRHA0?v=2&alt=json';
var json = (function() {
var json = null;
$.ajax({
'async': false,
'global': false,
'url': youTubeURL,
'dataType': "json",
'success': function(data) {
json = data;
}
});
return json;
})();
Then access it using object notation:
alert("Title: " + json.entry.title.$t +"\nDescription:\n " + json.entry.media$group.media$description.$t + "\n");
gdata is no longer available
you can use the following instead
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=(Video_ID)&key=(API_Key)
I read this topic a bit in delay.
I did something like this using jSON and YT API's
$json = json_decode( file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$rs['vid']."?v=2&prettyprint=true&alt=jsonc") );
Note: $rs['vid'] is the video ID dinamically retrived from my DB.
Once you put the contents in the handle $json you can retrive like this:
$json->data->description;
$json->data->title;
use var_dump( $json ) to view all values you can access.
I'd start by taking a look at Youtube Data API to get what you want: http://code.google.com/apis/youtube/getting_started.html#data_api
GData is deprecated, but one can still get the video description by calling this endpoint:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=[video_id]&key=[api_key]
It will return a response of the form:
{
"kind": "youtube#videoListResponse",
"etag": "\"...\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"...\"",
"id": "...",
"snippet": {
"publishedAt": "...",
"channelId": "...",
"title": "...",
"description": "...",
"thumbnails": { ... },
"channelTitle": "...",
"tags": [ ... ],
"categoryId": "...",
"liveBroadcastContent": "...",
"localized": {
"title": "...",
"description": "..."
},
"defaultAudioLanguage": "..."
}
}
]
}
The description can be found at items.localized.description.

Resources