2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 def extract_from_xml_url(ie, video_id, xml_url):
14 doc = ie._download_xml(
16 note='Downloading video info',
17 errnote='Failed to download video info')
19 title = doc.find('.//information/title').text
20 description = doc.find('.//information/detail').text
21 duration = int(doc.find('.//details/lengthSec').text)
22 uploader_node = doc.find('.//details/originChannelTitle')
23 uploader = None if uploader_node is None else uploader_node.text
24 uploader_id_node = doc.find('.//details/originChannelId')
25 uploader_id = None if uploader_id_node is None else uploader_id_node.text
26 upload_date = unified_strdate(doc.find('.//details/airtime').text)
28 def xml_to_format(fnode):
29 video_url = fnode.find('url').text
30 is_available = 'http://www.metafilegenerator' not in video_url
32 format_id = fnode.attrib['basetype']
33 format_m = re.match(r'''(?x)
34 (?P<vcodec>[^_]+)_(?P<acodec>[^_]+)_(?P<container>[^_]+)_
35 (?P<proto>[^_]+)_(?P<index>[^_]+)_(?P<indexproto>[^_]+)
38 ext = format_m.group('container')
39 proto = format_m.group('proto').lower()
41 quality = fnode.find('./quality').text
42 abr = int(fnode.find('./audioBitrate').text) // 1000
43 vbr_node = fnode.find('./videoBitrate')
44 vbr = None if vbr_node is None else int(vbr_node.text) // 1000
46 width_node = fnode.find('./width')
47 width = None if width_node is None else int_or_none(width_node.text)
48 height_node = fnode.find('./height')
49 height = None if height_node is None else int_or_none(height_node.text)
56 'format_id': format_id + '-' + quality,
59 'acodec': format_m.group('acodec'),
60 'vcodec': format_m.group('vcodec'),
65 'filesize': int_or_none(fnode.find('./filesize').text),
66 'format_note': format_note,
68 '_available': is_available,
71 format_nodes = doc.findall('.//formitaeten/formitaet')
72 formats = list(filter(
73 lambda f: f['_available'],
74 map(xml_to_format, format_nodes)))
75 ie._sort_formats(formats)
80 'description': description,
83 'uploader_id': uploader_id,
84 'upload_date': upload_date,
89 class ZDFIE(InfoExtractor):
90 _VALID_URL = r'^https?://www\.zdf\.de/ZDFmediathek(?P<hash>#)?/(.*beitrag/(?:video/)?)(?P<id>[0-9]+)(?:/[^/?]+)?(?:\?.*)?'
93 'url': 'http://www.zdf.de/ZDFmediathek/beitrag/video/2037704/ZDFspezial---Ende-des-Machtpokers--?bc=sts;stt',
97 'title': 'ZDFspezial - Ende des Machtpokers',
98 '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".',
100 'uploader': 'spezial',
101 'uploader_id': '225948',
102 'upload_date': '20131127',
104 'skip': 'Videos on ZDF.de are depublicised in short order',
107 def _real_extract(self, url):
108 video_id = self._match_id(url)
110 xml_url = 'http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?ak=web&id=%s' % video_id
111 return extract_from_xml_url(self, video_id, xml_url)