Contributed by Neev Technologies on 1 Oct 2012
Updating a video from youtube api gets a it frustrating since the youtube api documentation does not give you full info about how to fetch a video and update it. It starts from “assuming we have a video entry that was just posted in new_entry variable”.
# assuming we have a video entry that was just posted in our ‘new_entry’ variable
new_entry.media.title.text = 'My Updated Video Title' new_entry.media.description.text = 'Just updated' updated_entry = yt_service.UpdateVideoEntry(new_entry)
The common question arises that “what about the videos uploaded earlier?” or how should we get the “new_entry” veriable for the old videos?
For this Youtube says you can retrieve the video entry by GetYouTubeVideoEntry function.
Documentation also says that for getting a specific video entry you can use GetYouTubeEntry function which will give you the video entry for specific video id.
new_entry = yt_service.GetYouTubeVideoEntry(video_id='the0KZLEacs')
Combining the above two functions we think that we can edit the video with ease. Well that’s not completely correct. If you try to update the video using these combinations, you will get error saying edit_uri not found. Since the GetYouTubeEntry function that you used doesnot have the link for edit_uri, without which you cannot upload the video.
Youtube failed to specify how to use the function so that we will get an edit_uri with the links. It only gives you the data in public
methods.
You will find this issue listed on google groups but there is no solution given anywhere. After looking for a solution to this issue from
last 2 -3 days i finally found out a solution. The solution of this issue is very simple instead of using “video_id” parameter we have to use the “uri” parameter so that we will get the video feed for the specified video_entry which consists of edit_uri.
Below is the complete code for fetching and updating the Youtube video.
new_entry=yt_service.GetYouTubeVideoEntry(uri=’http://gdata.youtube.com/feeds/api/users/default/uploads/video_id’)
new_entry.media.title.text = 'My Updated Video Title' new_entry.media.description.text = 'Just updated' updated_entry = yt_service.UpdateVideoEntry(new_entry)
The above code will update the title and description of the video on youtube.
Contributor: Piyush Puntambekar.
Visit us at Neevtech.com to know more about our offerings.
© 2015 Neevtech Blog | Neev Technologies
Leave a Comment