本文整理汇总了Python中flickrapi.FlickrAPI.photos_getExif方法的典型用法代码示例。如果您正苦于以下问题:Python FlickrAPI.photos_getExif方法的具体用法?Python FlickrAPI.photos_getExif怎么用?Python FlickrAPI.photos_getExif使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flickrapi.FlickrAPI
的用法示例。
在下文中一共展示了FlickrAPI.photos_getExif方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sync_photo
# 需要导入模块: from flickrapi import FlickrAPI [as 别名]
# 或者: from flickrapi.FlickrAPI import photos_getExif [as 别名]
def sync_photo(photo):
flickr = FlickrAPI(API_KEY)
infos = flickr.photos_getInfo(photo_id=photo.flickr_id).find('photo')
exifs = flickr.photos_getExif(photo_id=photo.flickr_id).find('photo').findall('exif')
print "\tSyncing Photo: %s" % smart_str(photo.title)
for exif in exifs:
if exif.attrib['label'] == 'Aperture' and exif.attrib['tag'] == 'FNumber':
photo.aperture = exif.find('clean').text
if exif.attrib['label'] == 'Model' and exif.attrib['tag'] == 'Model':
photo.camera = exif.find('raw').text
if exif.attrib['label'] == 'Exposure' and exif.attrib['tag'] == 'ExposureTime':
photo.exposure = exif.find('raw').text
if exif.attrib['label'] == 'ISO Speed' and exif.attrib['tag'] == 'ISO':
photo.iso = exif.find('raw').text
if exif.attrib['label'] == 'Lens' and exif.attrib['tag'] == 'Lens':
photo.lens = exif.find('raw').text
photo.posted_date = datetime.fromtimestamp(float(infos.find('dates').attrib['posted']))
photo.description = infos.find('description').text
tags = infos.find('tags').findall('tag')
photo.tags.clear() # clear all previous tags if present
#Save photo prior saving the many to many relationship with tags
try:
photo.save()
except:
print '\t\tFail to Save Photo: %s' % smart_str(photo.title)
return photo
for tag in tags:
tag_id = tag.text[0:31]
print '\t\tFound tag: %s' % tag_id
try:
t = Tag.objects.get(pk=tag_id)
photo.tags.add(t)
except:
t = Tag(name=tag.text, raw=tag.attrib['raw'])
t.save()
photo.tags.add(t)
#print '[Flickr] Exif for %s: %s, %s, %s' % (photo.title, photo.lens, photo.iso, photo.posted_date)
return photo