[zdf] Make width extraction more robust

This commit is contained in:
Philipp Hagemeister 2013-12-25 15:33:09 +01:00
parent c3afc93a69
commit 61224dbcdd

View File

@ -1,10 +1,10 @@
# coding: utf-8 # coding: utf-8
import operator
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
int_or_none,
unified_strdate, unified_strdate,
) )
@ -67,7 +67,7 @@ def xml_to_format(fnode):
''', format_id) ''', format_id)
ext = format_m.group('container') ext = format_m.group('container')
proto = format_m.group('proto') proto = format_m.group('proto').lower()
quality = fnode.find('./quality').text quality = fnode.find('./quality').text
abr = int(fnode.find('./audioBitrate').text) // 1000 abr = int(fnode.find('./audioBitrate').text) // 1000
@ -85,11 +85,11 @@ def xml_to_format(fnode):
'vcodec': format_m.group('vcodec'), 'vcodec': format_m.group('vcodec'),
'abr': abr, 'abr': abr,
'vbr': vbr, 'vbr': vbr,
'width': int(fnode.find('./width').text), 'width': int_or_none(fnode.find('./width').text),
'height': int(fnode.find('./height').text), 'height': int_or_none(fnode.find('./height').text),
'filesize': int(fnode.find('./filesize').text), 'filesize': int_or_none(fnode.find('./filesize').text),
'format_note': format_note, 'format_note': format_note,
'protocol': format_m.group('proto').lower(), 'protocol': proto,
'_available': is_available, '_available': is_available,
} }