Unable to delete video using Youtube data API

Unable to delete videos to work using the Youtube data API. I am using the Python client library.

All this seems straight from the docs, so I'm very confused about why it doesn't work. Here is my function:

def delete_youtube_video_by_id(video_id): yt_service = gdata.youtube.service.YouTubeService() yt_service.email = YOUTUBE_EMAIL yt_service.password = YOUTUBE_SECRET_PASSWORD yt_service.source = YOUTUBE_SOURCE yt_service.developer_key = YOUTUBE_SECRET_DEVELOPER_KEY yt_service.client_id = YOUTUBE_CLIENT_ID yt_service.ProgrammaticLogin() video_entry = yt_service.GetYouTubeVideoEntry(video_id=video_id) response = yt_service.DeleteVideoEntry(video_entry) return response 

In the docs, this should return True if the video was successfully deleted. However, it returns None:

 >>> response = delete_youtube_video_by_id('my_youtube_video_id') >>> type(response) <type 'NoneType'> >>> 

And the video is not deleted. I know that the credentials are good, because they are the same credentials that I, first of all, to download the video, and I know that the identifier is good, because I got it directly from my YouTube channel.

Any ideas?

+6
source share
1 answer

I’m sure that this is due to the need to get the video from the download feed, and not from the general video. Otherwise, the record is not edited.

This will translate to

video_entry = yt_service.GetYouTubeVideoEntry('https://gdata.youtube.com/feeds/api/users/default/uploads/VIDEO_ID')

The Python GData client library still uses the v1 data API, which has been deprecated for a long time, and the client library as a whole is not supported.

I would recommend switching to v3 and the corresponding new client library , as definitely the future environment. We have several Python samples available now , and although there isn’t only one to delete a video, it should look something like this:

youtube.videos().delete(id=VIDEO_ID).execute()

(assuming youtube is a properly authorized YouTube client interface, following the existing examples on this page).

+4
source

All Articles