无法通过Python API更改Picasa Web相册中的日期

4 投票
1 回答
870 浏览
提问于 2025-04-16 09:11

我无法通过Python的API来更改我的Picasa网络相册专辑的日期。我花了很多时间在这上面,现在感到很绝望。代码如下:

# set values
remote_album.timestamp.text = str(get_published_as_timestamp())
remote_album.published.text = published + 'T04:01:01.000Z'

# test before
print remote_album.published
print remote_album.published.text
print remote_album.timestamp.text

# save it remotely
remote_album = picasa.Put(remote_album, remote_album.GetEditLink().href, converter=gdata.photos.AlbumEntryFromString)

# test after
print remote_album.published.text
print remote_album.timestamp.text

# :'-(

输出结果是:

<ns0:published xmlns:ns0="http://www.w3.org/2005/Atom">2010-12-24T04:01:01.000Z</ns0:published>
2010-12-24T04:01:01.000Z
1293148000
1970-01-15T23:12:28.000Z
1293148000

1 个回答

2

我能够通过以下方式更改我的相册时间戳:

album.timestamp = gdata.photos.Timestamp(
    text="%d000" % time.mktime((2010, 02, 03, 12, 00, 00, -1, -1, -1)))
updated_album = gd_client.Put(
    album, 
    album.GetEditLink().href, 
    converter=gdata.photos.AlbumEntryFromString)

显然,我的代码和你的不同(而且我今天才刚开始使用gdata API),但它展示了如何创建一个新的时间戳对象并将其分配给相册的时间戳。

http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html#ModifyAlbums

希望这对你有帮助

撰写回答