carolinux / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
0 stars 1 forks source link

"local variable 'edit_uri' referenced before assignment" error in YouTubeService.UpdateVideoEntry #466

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have following program that fetches an Youtube entry and tries to update its 
title and description:

import sys
import gdata.youtube
import gdata.youtube.service

email = sys.argv[1]
password = sys.argv[2]
youtube_id = sys.argv[3]
new_title = sys.argv[4]
new_description = sys.argv[5]

yt_service = gdata.youtube.service.YouTubeService()

# The YouTube API does not currently support HTTPS/SSL access.
yt_service.ssl = False

yt_service.developer_key = 'key here'
yt_service.client_id = 'client id here'
yt_service.email = email
yt_service.password = password
yt_service.source = 'source here'
yt_service.ProgrammaticLogin()

entry = yt_service.GetYouTubeVideoEntry(video_id=youtube_id)

entry.media.title.text = new_title
entry.media.description.text = new_description

yt_service.UpdateVideoEntry(entry)

This will result in following error:

Traceback (most recent call last):
  File "get-youtube-info.py", line 35, in <module>
    yt_service.UpdateVideoEntry(entry)
  File "/tmp/ck8/lib/python2.6/site-packages/gdata/youtube/service.py", line 742, in UpdateVideoEntry
    return self.Put(video_entry, uri=edit_uri,
UnboundLocalError: local variable 'edit_uri' referenced before assignment

Gdata Python API version is 2.0.12. Probably I'm missing something but this 
still should not result in exception about unbound local variables.

Original issue reported on code.google.com by jjudin on 12 Nov 2010 at 8:33

GoogleCodeExporter commented 9 years ago

Original comment by manoochehri@google.com on 17 Dec 2010 at 7:52

GoogleCodeExporter commented 9 years ago
I get this error again following the same steps as the original poster using 
gdata-2.0.13.  

The video entry returned from youtube does not have a link where link.rel == 
'edit'. I ran the following in my debug console using one of my videos:
    for link in entry.link:
        print link.rel

Output:
    alternate
    http://gdata.youtube.com/schemas/2007#video.responses
    http://gdata.youtube.com/schemas/2007#video.ratings
    http://gdata.youtube.com/schemas/2007#video.complaints
    http://gdata.youtube.com/schemas/2007#video.related
    http://gdata.youtube.com/schemas/2007#mobile
    self

Original comment by gae.loca...@gmail.com on 2 Mar 2011 at 7:08

GoogleCodeExporter commented 9 years ago
Also, I read this: 
http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/346eb7c8bd
d6c3ae

And I am authenticating with my dev_key.  The truncated console output to 
demonstrate:
>>> yt_service.developer_key
     'AI39si77lfnLeXv9...'

Original comment by gae.loca...@gmail.com on 2 Mar 2011 at 7:17