我想將大量照片移至Picassa。我無法使用InsertPhotoSimple上傳,但我也想上傳元數據,並且無法使用InsertPhoto。任何人都可以給我一個簡單的例子,或告訴我我做錯了什麼?將照片上傳到Google Picasa的簡單示例
這是我現在有:
#!/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') 文件「/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 return self.ToString() 文件「/home1/alptownc/public_html/photos/gdata-2.0.13/atom/ init .py」,行374,ToString return ElementTree.tostring(self._ToElementTree() ,編碼= string_encoding) 文件 「/home1/alptownc/public_html/photos/gdata-2.0.13/atom/ INIT py」 爲,線369,在_ToElementTree self._AddMembersToElementTree(new_tree)
我知道我錯過了一些愚蠢而簡單的事情,但我看不到它是什麼。謝謝