3

I am having trouble getting a video entry which includes a link rel="edit". I need such an entry in order to be able to call DeleteVideoEntry(...) on it.

I am retrieving the video using GetYouTubeVideoEntry(youtube_id=XXXXXXX). My yt_service is initialized with a username, password, and a developer key. I use ProgrammaticLogin. This part seems to work fine. I use the same yt_service to upload said video earlier. Also, if I change the developer key to something bogus (during debugging) and try to authenticate, I get a 403 error. This leads me to believe that authentication works OK.

Needsless to say, the video entry retrieved with GetYouTubeVideoEntry(youtube_id=XXXXXXX) does not contain the edit link and I cannot use the entry in a DeleteVideoEntry(...) call.

Is there some special way to get a video entry which will contain a link element with a rel="edit"? Can anyone suggest some way to resolve my issue? Could this possibly be a bug?

Update:

For the records, when I tried getting the feed of all my uploads, and then looping through the video entries, the video entries do have an edit link. So using this works:

uri = 'http://gdata.youtube.com/feeds/api/users/%s/uploads' % username
feed = yt_service.GetYouTubeVideoFeed(uri)
for entry in feed.entry:
   yt_service.DeleteVideoEntry(entry)

But this does not:

entry = yt_service.GetYouTubeVideoEntry(video_id = video.youtube_id)
yt_service.DeleteVideoEntry(entry)

Using the same yt_service.

grigno
  • 3,128
  • 4
  • 35
  • 47
Krystian Cybulski
  • 10,789
  • 12
  • 67
  • 98

2 Answers2

6

I've just deleted youtube video using gdata and ProgrammaticLogin()

Here is some steps to reproduce:

import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()

yt_service.developer_key = 'developer_key'
yt_service.email = 'email'
yt_service.password = 'password'
yt_service.ProgrammaticLogin()


# video_id should looks like 'iu6Gq-tUsTc'
uri = 'https://gdata.youtube.com/feeds/api/users/%s/uploads/%s' % (username, video_id)  
entry = yt_service.GetYouTubeUserEntry(uri=uri)
response = yt_service.DeleteVideoEntry(entry)
print response  # True

yt_service.GetYouTubeVideoFeed(uri) works because GetYouTubeVideoFeed doesn't check uri and just calls self.Get(uri, ...) but originaly, I think, it expected 'https://gdata.youtube.com/feeds/api/videos' uri.

vice versa yt_service.GetYouTubeVideoEntry() use YOUTUBE_VIDEO_URI = 'https://gdata.youtube.com/feeds/api/videos' but this entry doesn't contains rel="edit"

Hope that helps you out

karthikr
  • 97,368
  • 26
  • 197
  • 188
Alexey Savanovich
  • 1,893
  • 11
  • 19
1

You can view the HTTP headers of the generated requests by setting the debug flag to true. This is as simple as:

 yt_service = gdata.youtube.service.YouTubeService()
 yt_service.debug = True

You can read about this in the documentation here.

David Webb
  • 190,537
  • 57
  • 313
  • 299