google-code-export / gdata-python-client

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

gdata-python-client Client API: playlist_id is None #583

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello!

I have a problem with the YouTube part of the gdata-python-client, when using 
the new Client API.

I wrote an extension to the gdata YouTubeClient:

---
class YouTubeClient(gdata.youtube.client.YouTubeClient):
    def get_playlist_feed(self, uri=None, username=None):
        if uri is None and username is None:
            raise YouTubeError('You must provide at least a uri or a username '
                               'to the GetYouTubePlaylistFeed() method')
        elif username and not uri:
            uri = '%s%s/%s' % (gdata.youtube.client.YOUTUBE_USER_FEED_URI, username, 'playlists')
        return self.get_feed(uri, desired_class=gdata.youtube.data.PlaylistLinkFeed)

    GetYouTubePlaylistFeed = get_playlist_feed

---

Next I create the client and authorise it using an OAuth2Token:

---
yt_client = YouTubeClient()
token.authorize(yt_client)

---

Then I fetch my playlists and iterate over them:

---
playlist_feed = yt_client.GetYouTubePlaylistFeed(username="default")

for playlist_entry in playlist_feed.entry:
    print(playlist_entry)

---

So far this works quite well, but playlist_entry.playlist_id will always be 
"None", even though it is present in the XML.

Can someone please explain to me why? What am I missing?

Kind regards,
Dennis

P.S: I am using the Client API, because I found myself unable to use the 
Service API with ClientLogin (username/password):
Even though authentication (ProgrammaticLogin) was successful, I would receive 
a 401 "User authentication required" error when trying to get the playlists. I 
do not have this problem when using OAuth2.

P.P.S: I repeatedly tried to post this to google-help-dataapi@googlegroups.com 
and gdata-python-client-library-contributors@googlegroups.com before, but my 
messages are apparently stuck in moderation. Hence I repost here.

Original issue reported on code.google.com by dschridde@gmail.com on 18 Jan 2012 at 1:20

GoogleCodeExporter commented 9 years ago
P.S: Versions are gdata-python-client-2.0.16 and python-2.7.2.

Original comment by dschridde@gmail.com on 18 Jan 2012 at 1:47

GoogleCodeExporter commented 9 years ago
I found the causes: gdata/media/data.py and gdata/youtube/data.py are wrong 
about the XML namespaces.

They are:
MEDIA_TEMPLATE = '{http://search.yahoo.com/mrss//}%s'
YT_TEMPLATE = '{http://gdata.youtube.com/schemas/2007/}%s'

But should be:
MEDIA_TEMPLATE = '{http://search.yahoo.com/mrss/}%s'
YT_TEMPLATE = '{http://gdata.youtube.com/schemas/2007}%s'

Changing these fills the youtube classes with data as intended, but causes some 
weird AttributeError in atom/core.py (self.text is a list which has no decode 
method - traceback attached) when trying to print complete XmlElements. I 
assume that is a more general bug, though.

Original comment by devuran...@gmx.net on 21 Jan 2012 at 7:12

Attachments:

GoogleCodeExporter commented 9 years ago
P.S: More specifically: The error happens when walking the 
gdata.media.data.MediaContent class.

Original comment by devuran...@gmx.net on 21 Jan 2012 at 7:26

GoogleCodeExporter commented 9 years ago
P.P.S: Reported the AttributeError as issue #585.

Original comment by devuran...@gmx.net on 21 Jan 2012 at 7:33

GoogleCodeExporter commented 9 years ago
Patch for this issue, as laid out in comment #2.

Original comment by devuran...@gmx.net on 24 Jan 2012 at 10:20

Attachments:

GoogleCodeExporter commented 9 years ago
Any news on this?

Original comment by devuran...@gmx.net on 11 Apr 2012 at 9:28

GoogleCodeExporter commented 9 years ago
Any news?

Original comment by devuran...@gmx.net on 15 May 2012 at 8:13

GoogleCodeExporter commented 9 years ago
Any news?

Original comment by devuran...@gmx.net on 10 Jan 2013 at 10:35