2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class ZDFIE(InfoExtractor):
14 _VALID_URL = r'^https?://www\.zdf\.de/ZDFmediathek(?P<hash>#)?/(.*beitrag/(?:video/)?)(?P<id>[0-9]+)(?:/[^/?]+)?(?:\?.*)?'
17 'url': 'http://www.zdf.de/ZDFmediathek/beitrag/video/2037704/ZDFspezial---Ende-des-Machtpokers--?bc=sts;stt',
21 'title': 'ZDFspezial - Ende des Machtpokers',
22 'description': 'Union und SPD haben sich auf einen Koalitionsvertrag geeinigt. Aber was bedeutet das für die Bürger? Sehen Sie hierzu das ZDFspezial "Ende des Machtpokers - Große Koalition für Deutschland".',
24 'uploader': 'spezial',
25 'uploader_id': '225948',
26 'upload_date': '20131127',
28 'skip': 'Videos on ZDF.de are depublicised in short order',
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
34 xml_url = 'http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?ak=web&id=%s' % video_id
35 doc = self._download_xml(
37 note='Downloading video info',
38 errnote='Failed to download video info')
40 title = doc.find('.//information/title').text
41 description = doc.find('.//information/detail').text
42 duration = int(doc.find('.//details/lengthSec').text)
43 uploader_node = doc.find('.//details/originChannelTitle')
44 uploader = None if uploader_node is None else uploader_node.text
45 uploader_id_node = doc.find('.//details/originChannelId')
46 uploader_id = None if uploader_id_node is None else uploader_id_node.text
47 upload_date = unified_strdate(doc.find('.//details/airtime').text)
49 def xml_to_format(fnode):
50 video_url = fnode.find('url').text
51 is_available = 'http://www.metafilegenerator' not in video_url
53 format_id = fnode.attrib['basetype']
54 format_m = re.match(r'''(?x)
55 (?P<vcodec>[^_]+)_(?P<acodec>[^_]+)_(?P<container>[^_]+)_
56 (?P<proto>[^_]+)_(?P<index>[^_]+)_(?P<indexproto>[^_]+)
59 ext = format_m.group('container')
60 proto = format_m.group('proto').lower()
62 quality = fnode.find('./quality').text
63 abr = int(fnode.find('./audioBitrate').text) // 1000
64 vbr_node = fnode.find('./videoBitrate')
65 vbr = None if vbr_node is None else int(vbr_node.text) // 1000
67 width_node = fnode.find('./width')
68 width = None if width_node is None else int_or_none(width_node.text)
69 height_node = fnode.find('./height')
70 height = None if height_node is None else int_or_none(height_node.text)
77 'format_id': format_id + '-' + quality,
80 'acodec': format_m.group('acodec'),
81 'vcodec': format_m.group('vcodec'),
86 'filesize': int_or_none(fnode.find('./filesize').text),
87 'format_note': format_note,
89 '_available': is_available,
92 format_nodes = doc.findall('.//formitaeten/formitaet')
93 formats = list(filter(
94 lambda f: f['_available'],
95 map(xml_to_format, format_nodes)))
97 self._sort_formats(formats)
102 'description': description,
103 'duration': duration,
104 'uploader': uploader,
105 'uploader_id': uploader_id,
106 'upload_date': upload_date,