]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/zdf.py
4 from .common
import InfoExtractor
11 class ZDFIE(InfoExtractor
):
12 _VALID_URL
= r
'^http://www\.zdf\.de\/ZDFmediathek(?P<hash>#)?\/(.*beitrag\/video\/)(?P<video_id>[^/\?]+)(?:\?.*)?'
14 def _real_extract(self
, url
):
15 mobj
= re
.match(self
._VALID
_URL
, url
)
16 video_id
= mobj
.group('video_id')
18 xml_url
= u
'http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?ak=web&id=%s' % video_id
19 info_xml
= self
._download
_webpage
(
20 xml_url
, video_id
, note
=u
'Downloading video info')
21 doc
= parse_xml_doc(info_xml
)
23 title
= doc
.find('.//information/title').text
24 description
= doc
.find('.//information/detail').text
25 uploader_node
= doc
.find('.//details/originChannelTitle')
26 uploader
= None if uploader_node
is None else uploader_node
.text
27 duration_str
= doc
.find('.//details/length').text
28 duration_m
= re
.match(r
'''(?x)^
30 :(?P<minutes>[0-9]{2})
31 :(?P<seconds>[0-9]{2})
36 (int(duration_m
.group('hours')) * 60 * 60) +
37 (int(duration_m
.group('minutes')) * 60) +
38 int(duration_m
.group('seconds'))
43 upload_date
= unified_strdate(doc
.find('.//details/airtime').text
)
45 def xml_to_format(fnode
):
46 video_url
= fnode
.find('url').text
47 is_available
= u
'http://www.metafilegenerator' not in video_url
49 format_id
= fnode
.attrib
['basetype']
50 format_m
= re
.match(r
'''(?x)
51 (?P<vcodec>[^_]+)_(?P<acodec>[^_]+)_(?P<container>[^_]+)_
52 (?P<proto>[^_]+)_(?P<index>[^_]+)_(?P<indexproto>[^_]+)
55 PROTO_ORDER
= ['http', 'rtmp', 'rtsp']
57 proto_pref
= -PROTO_ORDER
.index(format_m
.group('proto'))
61 quality
= fnode
.find('./quality').text
62 QUALITY_ORDER
= ['veryhigh', '300', 'high', 'med', 'low']
64 quality_pref
= -QUALITY_ORDER
.index(quality
)
68 abr
= int(fnode
.find('./audioBitrate').text
) // 1000
69 vbr
= int(fnode
.find('./videoBitrate').text
) // 1000
70 pref
= (is_available
, proto_pref
, quality_pref
, vbr
, abr
)
73 'format_id': format_id
,
75 'ext': format_m
.group('container'),
76 'acodec': format_m
.group('acodec'),
77 'vcodec': format_m
.group('vcodec'),
80 'width': int(fnode
.find('./width').text
),
81 'height': int(fnode
.find('./height').text
),
82 'quality_name': quality
,
83 'filesize': int(fnode
.find('./filesize').text
),
84 'format_note': None if is_available
else u
'(unavailable)',
88 format_nodes
= doc
.findall('.//formitaeten/formitaet')
89 formats
= sorted(map(xml_to_format
, format_nodes
),
90 key
=operator
.itemgetter('_pref'))
96 'description': description
,
99 'upload_date': upload_date
,