]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/mdr.py
3 from .common
import InfoExtractor
9 class MDRIE(InfoExtractor
):
10 _VALID_URL
= r
'^(?P<domain>(?:https?://)?(?:www\.)?mdr\.de)/mediathek/(?:.*)/(?P<type>video|audio)(?P<video_id>[^/_]+)_.*'
13 u
'url': u
'http://www.mdr.de/mediathek/themen/nachrichten/video165624_zc-c5c7de76_zs-3795826d.html',
14 u
'file': u
'165624.mp4',
15 u
'md5': u
'ae785f36ecbf2f19b42edf1bc9c85815',
17 u
"title": u
"MDR aktuell Eins30 09.12.2013, 22:48 Uhr"
21 u
'url': u
'http://www.mdr.de/mediathek/radio/mdr1-radio-sachsen/audio718370_zc-67b21197_zs-1b9b2483.html',
22 u
'file': u
'718370.mp3',
23 u
'md5': u
'a9d21345a234c7b45dee612f290fd8d7',
25 u
"title": u
"MDR 1 RADIO SACHSEN 10.12.2013, 05:00 Uhr"
29 def _real_extract(self
, url
):
30 m
= re
.match(self
._VALID
_URL
, url
)
31 video_id
= m
.group('video_id')
32 domain
= m
.group('domain')
33 mediatype
= m
.group('type')
35 # determine title and media streams from webpage
36 html
= self
._download
_webpage
(url
, video_id
)
38 title
= self
._html
_search
_regex
(r
'<h2>(.*?)</h2>', html
, u
'title')
39 xmlurl
= self
._search
_regex
(
40 r
'(/mediathek/(?:.+)/(?:video|audio)[0-9]+-avCustom.xml)', html
, u
'XML URL')
42 doc
= self
._download
_xml
(domain
+ xmlurl
, video_id
)
44 for a
in doc
.findall('./assets/asset'):
45 url_el
= a
.find('.//progressiveDownloadUrl')
48 abr
= int(a
.find('bitrateAudio').text
) // 1000
49 media_type
= a
.find('mediaType').text
52 'filesize': int(a
.find('fileSize').text
),
56 vbr_el
= a
.find('bitrateVideo')
60 'format_id': u
'%s-%d' % (media_type
, abr
),
63 vbr
= int(vbr_el
.text
) // 1000
66 'width': int(a
.find('frameWidth').text
),
67 'height': int(a
.find('frameHeight').text
),
68 'format_id': u
'%s-%d' % (media_type
, vbr
),
70 formats
.append(format
)
71 formats
.sort(key
=lambda f
: (f
.get('vbr'), f
['abr']))
73 raise ValueError('Could not find any valid formats')