simplify thumbnail dict building

This commit is contained in:
kennell 2015-10-18 21:25:26 +02:00
parent b243340f0c
commit b7cedb1604

View file

@ -75,9 +75,10 @@ def xml_to_thumbnails(fnode):
for node in fnode: for node in fnode:
thumbnail = {'url': node.text} thumbnail = {'url': node.text}
if 'key' in node.attrib: if 'key' in node.attrib:
if re.match("^[0-9]+x[0-9]+$", node.attrib['key']): m = re.match('^([0-9]+)x([0-9]+)$', node.attrib['key'])
thumbnail['width'] = int_or_none(node.attrib['key'].split('x')[0]) if m:
thumbnail['height'] = int_or_none(node.attrib['key'].split('x')[1]) thumbnail['width'] = int(m.group(1))
thumbnail['height'] = int(m.group(2))
thumbnails.append(thumbnail) thumbnails.append(thumbnail)
return thumbnails return thumbnails