Simple example to upload photos into google picasa

对着背影说爱祢 提交于 2019-12-13 01:39:45

问题


I would like to move a large number of pictures into picassa. I'm having no trouble uploading using InsertPhotoSimple, but I want to upload metadata too and am having trouble with InsertPhoto. Can anyone point me to a simple example or tell me what I'm doing wrong?

Here is what I have now:

#!/bin/python

import gdata.photos.service
import gdata.media

gd_client = gdata.photos.service.PhotosService()
gd_client.email = 'my_google_email'
gd_client.password = 'my_pass'
gd_client.source = 'my_source'
gd_client.ProgrammaticLogin()

album_url = '/data/feed/api/user/%s/albumid/%s' % ('default', 'default')
filename = 'myfile.jpg'
metadata = gdata.photos.PhotoEntry()
metadata.title = 'My Photo Title'
metadata.media.keywords = 'keyword1, keyword2, keyword3'

upload_photo = gd_client.InsertPhoto(album_url, metadata, filename, content_type='image/jpeg')

But when I run this, it chokes every time with: Traceback (most recent call last): File "./picassa.py", line 36, in ? upload_photo = gd_client.InsertPhoto(album_url, metadata, filename, content_type='image/jpeg') File "/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/photos/service.py", line 425, in InsertPhoto converter=gdata.photos.PhotoEntryFromString) File "/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/service.py", line 1236, in Post media_source=media_source, converter=converter) File "/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/service.py", line 1286, in PostOrPut data_str = str(data) File "/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init.py", line 377, in str return self.ToString() File "/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init.py", line 374, in ToString return ElementTree.tostring(self._ToElementTree(), encoding=string_encoding) File "/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init.py", line 369, in _ToElementTree self._AddMembersToElementTree(new_tree)

I know I'm missing something stupid and simple, but I can't see what it is. Thanks


回答1:


I think you need to use insertPhotoEntry instead of just insertPhoto ?




回答2:


Having looked at your code, there doesn't appear to be anything wrong with it. I found this link to Google Developers which may help.

https://developers.google.com/picasa-web/docs/1.0/developers_guide_php#PostPhotos



来源:https://stackoverflow.com/questions/4238915/simple-example-to-upload-photos-into-google-picasa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!