Created
February 11, 2013 11:34
-
-
Save brokendish/4753988 to your computer and use it in GitHub Desktop.
Picasaウエブアルバムから指定されたアルバム内の全写真の詳細情報(Exif)を取得してHTMLとして出力する。
Picasaのユーザー名、パスワード、アルバム名を引数として特定のアルバムを対象とする。
出力したHTMLファイルは自分でクリックして起動する。
実行:python picasa.py ユーザ名 パスワード 'アルバム名'>aaa.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import gdata.photos.service | |
import gdata.media | |
import gdata.geo | |
import getpass | |
import sys | |
import datetime | |
#実行:python picasa.py ユーザ名 パスワード 'アルバム名'>aaa.html | |
#第1引数:ユーザ名(メールアドレス) | |
email=sys.argv[1] | |
#第2引数:パスワード | |
password=sys.argv[2] | |
#第3引数:アルバム名 | |
albumname = sys.argv[3] | |
gd_client = gdata.photos.service.PhotosService() | |
gd_client.email = email | |
gd_client.password = password | |
gd_client.source = 'exampleCo-exampleApp-1' | |
gd_client.ProgrammaticLogin() | |
username=email | |
albumid = "" | |
albums = gd_client.GetUserFeed(user=username) | |
for album in albums.entry: | |
if album.title.text == albumname: | |
albumid = album.gphoto_id.text | |
photos = gd_client.GetFeed( | |
'/data/feed/api/user/%s/albumid/%s?kind=photo' % ( | |
username, albumid)) | |
print '<html xmlns="http://www.w3.org/1999/xhtml" lang="ja">' | |
print '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' | |
print '<body bgcolor="#585858" text="#E6D2B1"></body>' | |
print '<style type="text/css">' | |
print 'td, th { border: 1px #857464 solid; }' | |
print 'table { border: 1px #555555 solid; }' | |
print '.aa{ background-color: #39303A; }' | |
print '</style>' | |
print '<h2>Picasa WebAlbum -- %s</h2>' % (sys.argv[3]) | |
for photo in photos.entry: | |
print '<table>' | |
print '<tr><td><a href="%s"><img src="%s"/></a></td>' % (photo.content.src, photo.media.thumbnail[2].url) | |
print '<td><table>' | |
print '<tr><td>%s\n</td></tr>' % (photo.summary.text) | |
if photo.exif.make and photo.exif.model: | |
camera = '%s %s' % (photo.exif.make.text, photo.exif.model.text) | |
exposure = '%s' % (photo.exif.exposure.text) | |
flash = '%s' % (photo.exif.flash.text) | |
focallength = '%s' % (photo.exif.focallength.text) | |
fstop = '%s' % (photo.exif.fstop.text) | |
iso = '%s' % (photo.exif.iso.text) | |
make = '%s' % (photo.exif.make.text) | |
model = '%s' % (photo.exif.model.text) | |
time = '%s' % datetime.date.fromtimestamp(int(photo.exif.time.text)/1000) | |
else: | |
camera = 'unknown' | |
print '<tr><td class="aa">camera:<td>%s\n</td></td></tr>' % (camera) | |
print '<tr><td class="aa">メーカ(make):<td>%s\n</td></td></tr>' % (make) | |
print '<tr><td class="aa">モデル(model):<td>%s\n</td></td></tr>' % (model) | |
print '<tr><td class="aa">ISO:<td>%s\n</td></td></tr>' % (iso) | |
print '<tr><td class="aa">絞り(fstop):<td>%s\n</td></td></tr>' % (fstop) | |
print '<tr><td class="aa">露出(exposure):<td>%s\n</td></td></tr>' % (exposure) | |
print '<tr><td class="aa">レンズ焦点距離(focallength):<td>%s\n</td></td></tr>' % (focallength) | |
print '<tr><td class="aa">フラッシュ(flash):<td>%s\n</td></td></tr>' % (flash) | |
print '<tr><td class="aa">日時(time):<td>%s\n</td></td></tr>' % (time) | |
print '</table></td>' | |
print '</tr>' | |
print '</table>' | |
print '<br>' | |
print '<h2>-------------------Other Album----------------------</h2>' | |
albums = gd_client.GetUserFeed(user=username) | |
print '<table>' | |
for album in albums.entry: | |
print '<tr><td class="aa">title:</td><td>%s</td><td class="aa">number of photos:</td><td>%s</td><td class="aa"> id:</td><td>%s</td></tr>' % (album.title.text, | |
album.numphotos.text, album.gphoto_id.text) | |
print '</table>' | |
print'</html>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment