Thursday, March 22, 2012

[YouTube-API] batch feed problem (atom, python)

Hi to all.

I have a batch feed that was working for a while. Yesterday I copied the folder where the files are, and I started to get the following error (is worth to say that I checked: I didn't delete or move any needed file, nor modified them, but it seems soo much coincidence that the error appeared when I did it).

Traceback (most recent call last):
  File "data.py", line 106, in <module>
    feed = retrieve_batch_feed(client, ids)
  File "/scratch/youtube/youtube_lib.py", line 118, in retrieve_batch_feed
    feed = client.Post(query,uri,converter=gdata.youtube.YouTubeVideoFeedFromString)
  File "/scratch/youtube/gdata/service.py", line 1236, in Post
    media_source=media_source, converter=converter)
  File "/scratch/youtube/gdata/service.py", line 1322, in PostOrPut
    headers=extra_headers, url_params=url_params)
  File "/scratch/youtube/atom/atom/__init__.py", line 93, in optional_warn_function
    return f(*args, **kwargs)
  File "/scratch/youtube/atom/service.py", line 186, in request
    data=data, headers=all_headers)
  File "/scratch/youtube/atom/http_interface.py", line 148, in perform_request
    return http_client.request(operation, url, data=data, headers=headers)
  File "/scratch/youtube/atom/atom/http.py", line 129, in request
    raise atom.http_interface.UnparsableUrlObject('Unable to parse url '
atom.http_interface.UnparsableUrlObject: Unable to parse url parameter because it was not a string or atom.url.Url

so, client is a YouTubeService instance, ids is a list of ids. The retrieve_batch_feed function goes like this:

def retrieve_batch_feed(client, ids):
    query
= '<feed xmlns=\"http://www.w3.org/2005/Atom\"'
    query
+= ' xmlns:media=\"http://search.yahoo.com/mrss/\"'
    query
+= ' xmlns:batch=\"http://schemas.google.com/gdata/batch\"'
    query
+= ' xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">'
    query
+= '<batch:operation type=\"query\"/>'
   
for vid in ids:
     
#query += '<entry><batch:id>'+'batch_'+vid+'</batch:id> <id>http://gdata.youtube.com/feeds/api/videos/'+vid+'</id></entry>'
      query
+= '<entry> <batch:id>batch_'+vid+'</batch:id> <id>video:'+vid+'</id> </entry>'
    query
+= '</feed>'
    uri
= 'http://gdata.youtube.com/feeds/api/videos/batch'
    feed
= client.Post(query, uri, converter=gdata.youtube.YouTubeVideoFeedFromString)
   
return feed

So, any idea of what's wrong with this feed?
thanks,
Jose


--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/_7KbQWWJlEgJ.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment