1

我想将大量图片移动到 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')

但是当我运行它时,它每次都会阻塞: Traceback(最近一次调用最后一次):文件“./picassa.py”,第 36 行,在?upload_photo = gd_client.InsertPhoto(album_url, metadata, filename, content_type='image/jpeg') 文件“/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/photos/service.py”,第 425 行,在InsertPhoto converter=gdata.photos.PhotoEntryFromString) 文件 "/home1/alptownc/public_html/photos/gdata-2.0.13/gdata/service.py", 第 1236 行, 在 Post media_source=media_source, converter=converter) 文件 "/home1 /alptownc/public_html/photos/gdata-2.0.13/gdata/service.py”,第 1286 行,在 PostOrPut data_str = str(data) 文件“/home1/alptownc/public_html/photos/gdata-2.0.13/atom/ init .py",第 377 行,在str 返回 self.ToString() 文件“/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init .py ”,第 374 行,在 ToString return ElementTree.tostring(self._ToElementTree(), encoding=string_encoding) _ToElementTree self._AddMembersToElementTree( new_tree ) 中的文件“/home1/alptownc/public_html/photos/gdata-2.0.13/atom/init .py”,第 369 行

我知道我错过了一些愚蠢而简单的东西,但我看不出它是什么。谢谢

4

2 回答 2

0

我认为您需要使用insertPhotoEntry而不仅仅是insertPhoto

于 2013-01-14T04:08:37.017 回答
0

查看您的代码后,它似乎没有任何问题。我发现这个指向 Google Developers 的链接可能会有所帮助。

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

于 2013-03-27T22:27:55.657 回答