Skip to content

Commit

Permalink
Merge pull request #17 from forshtat/master
Browse files Browse the repository at this point in the history
Use new 'photo' object format
  • Loading branch information
amka committed Aug 11, 2018
2 parents 49be713 + 7e7c688 commit cb3f2a1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions spelt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,19 @@ def normpath(filename):
logging.error(e)
return items

image_types = {'s':0, 'm':1, 'x': 2, 'o':3, 'p': 4, 'q': 5, 'r': 6, 'y': 7, 'z': 8, 'w': 9}
if 'items' in response:
for item in response['items']:
sizes = item.get('sizes')
if len(sizes)==0:
logging.info('Item skipped!')
continue
newlist = sorted(sizes, key=lambda x: image_types.get(x.get('type')), reverse=True)
image = {
'id': item['id'],
'date': datetime.datetime.fromtimestamp(item['date']),
'url':
item.get('photo_2560') or
item.get('photo_1280') or
item.get('photo_807') or
item.get('photo_604') or
item.get('photo_130') or
item.get('photo_75')
newlist[0].get('url')
}
if item.get('text'):
image['title'] = normpath(item['text'])
Expand Down

0 comments on commit cb3f2a1

Please sign in to comment.