simplify thumbnail dict building
authorkennell <kevin@fileperms.org>
Sun, 18 Oct 2015 19:25:26 +0000 (21:25 +0200)
committerkennell <kevin@fileperms.org>
Sun, 18 Oct 2015 19:25:26 +0000 (21:25 +0200)
youtube_dl/extractor/zdf.py

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