【发布时间】:2010-11-21 16:33:46
【问题描述】:
我想将大量图片移入 picassa。我在使用 InsertPhotoSimple 上传时没有问题,但我也想上传元数据并且在使用 InsertPhoto 时遇到问题。谁能指出一个简单的例子或告诉我我做错了什么?
这是我现在拥有的:
#!/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')
但是当我运行它时,它每次都会窒息: 回溯(最近一次通话最后): 文件“./picassa.py”,第 36 行,在 ? upload_photo = gd_client.InsertPhoto(album_url, metadata, filename, content_type='image/jpeg') InsertPhoto 中的文件“/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/photos/service.py”,第 425 行 转换器=gdata.photos.PhotoEntryFromString) 文件“/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/service.py”,第 1236 行,在 Post 媒体源=媒体源,转换器=转换器) PostOrPut 中的文件“/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/service.py”,第 1286 行 data_str = str(数据) str 中的文件“/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init.py”,第 377 行 返回 self.ToString() ToString 中的文件“/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init.py”,第 374 行 return ElementTree.tostring(self._ToElementTree(), encoding=string_encoding) _ToElementTree 中的文件“/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init.py”,第 369 行 self._AddMembersToElementTree(new_tree)
我知道我错过了一些愚蠢而简单的东西,但我看不出它是什么。谢谢
【问题讨论】:
标签: picasa