The Youtube-API for "Videos: insert" is not working properly - youtube-api

I'm trying to upload a video using the YouTube API.
I'm using the code snippet provided in the documentation page:
https://developers.google.com/youtube/v3/docs/videos/insert
I'm using the Python API.
I'm running this after providing a valid client secret file and file to upload.
I was able to authenticate using auth2, and provide a valid token.
I'm getting the following response:
{'kind': 'youtube#video', 'etag': '"wdgS91PsEbtTfi20GmzFuZzYg2s/75EL94ZW60lJpJbXGn80dBaJI00"', 'id': 'Rz0n45vusps', 'snippet': {'publishedAt': '2020-05-30T05:23:07.000Z', 'channelId': 'UCAfompGqO1DYLi1WZ9GPYiw', 'title': 'Test video upload.', 'description': 'Description of uploaded video.', 'thumbnails': {'default': {'url': 'https://i9.ytimg.com/vi/Rz0n45vusps/default.jpg?sqp=CIDax_YF&rs=AOn4CLCt23wHAw-ViyVPCn5Sbxdh0v9Nzw', 'width': 120, 'height': 90}, 'medium': {'url': 'https://i9.ytimg.com/vi/Rz0n45vusps/mqdefault.jpg?sqp=CIDax_YF&rs=AOn4CLCshm-pBB2CeHW5ynQkhS4TA7zBWA', 'width': 320, 'height': 180}, 'high': {'url': 'https://i9.ytimg.com/vi/Rz0n45vusps/hqdefault.jpg?sqp=CIDax_YF&rs=AOn4CLDwNiO2tURd2POhFKrYOh6vYTfN6A', 'width': 480, 'height': 360}}, 'channelTitle': 'jvalansi84', 'categoryId': '22', 'liveBroadcastContent': 'none', 'localized': {'title': 'Test video upload.', 'description': 'Description of uploaded video.'}}, 'status': {'uploadStatus': 'uploaded', 'privacyStatus': 'private', 'license': 'youtube', 'embeddable': True, 'publicStatsViewable': True}}
But I'm not seeing the actual video in my uploads.
What am I missing?

The problem was that the video was a duplicate. I first uploaded manually, and then tried to use the API.
It would make sense to have some kind of feedback that the video is a duplicate through the API though.

Related

Unable to move file with MS Graph API for Onedrive. 200 Response containing old Parent ID

So I'm quite a fan of the Graph API to manage Onedrive from my server.
Now I'm trying to use the Graph API to move a file from one directory to another one following the documentation here.
Now in order to do so, I send (PATCH) the following to https://graph.microsoft.com/v1.0/me/drive/items/01A2ASUEXPG7EKMCTPDJDY7L5YMVTNWHMO:
{'parentReference': {'id': '01A2ASUEVXTMODEW6HIJC3MSXT5JJ4JLRK'}}
And I receive:
{
"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('b9dc908f-6c6f-463b-a568-9361fabdc995')/drive/items/$entity",
"#microsoft.graph.downloadUrl":"xxxx",
"createdDateTime":"2022-04-20T08:46:12Z",
"eTag":"\"{A6C837EF-6F0A-471A-8FAF-B86566DB1D8E},1\"",
"id":"01A2ASUEXPG7EKMCTPDJDY7L5YMVTNWHMO",
"lastModifiedDateTime":"2022-04-20T08:46:12Z",
"name":"IMG.png",
"webUrl":"https://xxxx-my.sharepoint.com/personal/xxxx-uitzendbureau_nl/Documents/Loonstroken%20(alleen%20voor%20toevoegen)/xxxx/IMG.png",
"cTag":"\"c:{A6C837EF-6F0A-471A-8FAF-B86566DB1D8E},1\"",
"size":382692,
"createdBy":{
"user":{
"email":"Online#xxxx.nl",
"id":"b9dc908f-6c6f-463b-a568-9361fabdc995",
"displayName":"Online beheer"
}
},
"lastModifiedBy":{
"user":{
"email":"Online#xxxxx.nl",
"id":"b9dc908f-6c6f-463b-a568-9361fabdc995",
"displayName":"Online beheer"
}
},
"parentReference":{
"driveType":"business",
"driveId":"b!u2WpOb6qnkS_6foMbPUq90TwxghBinBMhj9DwokQnQefs7rIOSQYS5kmJNV5uSJ7",
"id":"01A2ASUEWGZQX5GCGE2RFL6J3WBIW2LTUC",
"path":"/drive/root:/Loonstroken (alleen voor toevoegen)/xxxxxx"
},
"file":{
"mimeType":"image/png",
"hashes":{
"quickXorHash":"Yk0eRqT2ThqJHamo0AMLstI0CBI="
}
},
"fileSystemInfo":{
"createdDateTime":"2022-04-20T08:46:12Z",
"lastModifiedDateTime":"2022-04-20T08:46:12Z"
},
"image":{
},
"shared":{
"scope":"users"
}
}
As you can see:
'parentReference': {'driveType': 'business', 'driveId': 'xxx', 'id': '01A2ASUEWGZQX5GCGE2RFL6J3WBIW2LTUC', 'path': '/drive/root:/Loonstroken (alleen voor toevoegen)/xxxxxx'}
The parentReference ID has not changed to the one provided in the request, but still a 200 is returned. Also the file obviously was not moved.
Any idea what might be the issue here?
Answering my own question.
Seems this was an issue on Microsoft's end. I now get a correct parentReference in the response.

Google Action Console(Cloud function editor) How to add image to a Media/MediaObject

Hi i'am working with google assistant, i'am using Action Builder in the Google Action Console. And i working with google Cloud function editor provided in the Action Console to test my webhook. I would like to use a media player to read an mp3 song that i provide with an url. i followed the documentation here : https://developers.google.com/assistant/conversational/prompts-media and i used this code :
app.handle('media', (conv) => {
conv.add('This is a media response');
conv.add(new Media({
mediaObjects: [
{
name: 'Media name',
description: 'Media description',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
image: {
large: JAZZ_IN_PARIS_IMAGE,
}
}
],
mediaType: 'AUDIO',
optionalMediaControls: ['PAUSED', 'STOPPED'],
startOffset: '2.12345s'
}));
});
Problem is that this code work when i remove the image but if i keep it i got an error :
Unsuccessful webhook call due to client issue: Error querying agent endpoint. State: URL_UNREACHABLE, reason: UNREACHABLE_5xx.
and in the webhookResponse i got :
"error": "JAZZ_IN_PARIS_IMAGE is not defined"
My question is how to send image in a MediaObject send by a webhook? Where do i have to store my image and how to add it in the response?
In the code snippet, JAZZ_IN_PARIS_IMAGE is not defined directly but is supposed to be an Image object, like png or jpg. A MediaObject can have a large image and/or an icon.
For testing purposes, you can upload a file to your Cloud Storage or just take any image from the web. But when you move forward you really should fix that image URL and provide corrected alt text.
conv.add('This is a media response');
conv.add(new Media({
mediaObjects: [
{
name: 'Media name',
description: 'Media description',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
image: {
large: {
url: 'https://serebii.net/pokearth/sprites/green/025.png',
alt: 'This is a sprite of Pikachu!',
},
}
}
],
mediaType: 'AUDIO',
optionalMediaControls: ['PAUSED', 'STOPPED'],
startOffset: '2.12345s'
}));
});

How to check a video for unpublished captions on any youtube video

I'm trying to build an automated program that alerts me if there are draft captions on a video. Recently there have been some vulgar captions that were added to my videos but were caught as drafts.
I'm using this sample as a base but when I try checking videos it only provides published video caption information. I've looked at the api documentation and it appears that I should see the captions in draft status as well.
https://github.com/youtube/api-samples/blob/master/python/captions.py
def get_authenticated_service(args):
flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE, scope=YOUTUBE_READ_WRITE_SSL_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
storage = Storage("%s-oauth2.json" % sys.argv[0])
credentials = storage.get()
if credentials is None or credentials.invalid:
credentials = run_flow(flow, storage, args)
# Trusted testers can download this discovery document from the developers page
# and it should be in the same directory with the code.
with open("youtube-v3-api-captions.json", "r") as f:
doc = f.read()
return build_from_document(doc, http=credentials.authorize(httplib2.Http()))
# Call the API's captions.list method to list the existing caption tracks.
def list_captions(youtube, video_id):
results = youtube.captions().list(
part="snippet",
videoId=video_id
).execute()
for item in results["items"]:
id = item["id"]
name = item["snippet"]["name"]
language = item["snippet"]["language"]
print("Caption track '%s(%s)' in '%s' language." % (name, id, language))
return results["items"]
args = argparser.parse_args()
youtube = get_authenticated_service(args)
print(list_captions(youtube,"my-video"))
I expect print(list_captions(youtube,"my-video")) to print to my console information on all the captions available to a video including captions that are in draft mode in different languages. I ran a test on one of my videos, I'm expecting draft caption track in polish to appear but only english and the auto captions appear:
Caption track '(XP6L39GAE3cGDethMwzyWkLZChESxt5MnCNokggzJnY=)' in 'ja' language.
Caption track '(zKBRyKIAn6BOtdpekvePw4qtM-_w7Jcv)' in 'en' language.
[{'kind': 'youtube#caption', 'etag': '"Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/9AEECTD98uML9khnVlJ9I3nZyBk"', 'id': 'XP6L39GAE3cGDethMwzyWkLZChESxt5MnCNokggzJnY=', 'snippet': {'videoId': 'RYx1P_z9tNk', 'lastUpdated': '2019-02-20T09:07:56.247Z', 'trackKind': 'ASR', 'language': 'ja', 'name': '', 'audioTrackType': 'unknown', 'isCC': False, 'isLarge': False, 'isEasyReader': False, 'isDraft': False, 'isAutoSynced': False, 'status': 'serving'}}, {'kind': 'youtube#caption', 'etag': '"Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/kxbjbXbUxo9fiHaH8bj_pUuttwg"', 'id': 'zKBRyKIAn6BOtdpekvePw4qtM-_w7Jcv', 'snippet': {'videoId': 'RYx1P_z9tNk', 'lastUpdated': '2019-02-20T16:43:48.873Z', 'trackKind': 'standard', 'language': 'en', 'name': '', 'audioTrackType': 'unknown', 'isCC': False, 'isLarge': False, 'isEasyReader': False, 'isDraft': False, 'isAutoSynced': False, 'status': 'serving'}}]
Caption track '(XP6L39GAE3cGDethMwzyWkLZChESxt5MnCNokggzJnY=)' in 'ja' language.
Caption track '(zKBRyKIAn6BOtdpekvePw4qtM-_w7Jcv)' in 'en' language.
Screenshot about the captions exist on the video:

Unable to play mp4 videos on iOS using jwplayer

Here is my code, please help.
jwplayer("myElement").setup({
playlist: [{
sources: [{
file: "rtmp://draco.streamingwizard.com/wizard/_definst_/demo/sample.mp4"
}],
image: "vtts/bbb-splash.png"
}],
width: 480,
height: 270,
type:"video/mp4"
});
You're using RTMP, which is a Flash protocol. There is no Flash on any mobile device. You'll need to provide an HLS stream or MP4 fallback for mobiles.

updating a youtube video (api v3) returns 'video not found' but works in their API explorer

I'm trying to update the description on my youtube video via some python code.
This is my PUT request
body (this is converted to a json string):
{'id': <the video's youtube id>,
'snippet': {
'categoryId': <category id>,
'channelId': <channel id>,
'description': 'new title',
'title': 'new title'
}}
headers:
{'Authorization': 'Bearer <access token given via the oauth flow>'
url:
https://www.googleapis.com/youtube/v3/videos?part=snippet&key=<my_youtube_api_key>
}
and I'm getting this response:
{
"error": {
"errors": [
{
"message": "Video not found"
}
],
"code": 500,
"message": "Video not found"
}
}
The odd thing is that the same query works from the API explorer on this page:
https://developers.google.com/youtube/v3/docs/videos/update
I'm copying and pasting the params from my python code, so it's not like a youtube video with that id doesn't actually exist.
What's going on?
The only change I've made is add the following header:
'Content-Type':'application/json'
and the API call works now.

Resources