2011年3月17日木曜日

gdata でpicasaを操作

People FInder の入力作業に協力しようとしたのだけど、未作業の写真をなかなか見つけられないので、コメント数が1以下の写真だけを調べるスクリプトを書いてみた。といっても、ここにあるスクリプトほぼそのままだが。
import gdata.photos.service
import gdata.media
import gdata.geo

email=xxxxx
password=xxxx

gd_client = gdata.photos.service.PhotosService()
gd_client.email = email
gd_client.password = password
gd_client.source = 'exampleCo-exampleApp-1'
gd_client.ProgrammaticLogin()

username="tohoku.anpi"

albums = gd_client.GetUserFeed(user=username)
for album in albums.entry:
  print 'title: %s, number of photos: %s, id: %s' % (album.title.text,
      album.numphotos.text, album.gphoto_id.text)
  photos = gd_client.GetFeed(
      '/data/feed/api/user/%s/albumid/%s?kind=photo' % (
          username, album.gphoto_id.text))
  for photo in photos.entry:
      comments = gd_client.GetFeed('/data/feed/api/user/%s/albumid/%s/photoid/%s?kind=comment&max-results=10' % (username, album.gphoto_id.text, photo.gphoto_id.text))
      if len(comments.entry) < 2:
          print 'Photo title:', photo.title.text, len(comments.entry)

0 件のコメント: