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')
34 # determine title and media streams from webpage
35 html = self._download_webpage(url, video_id)
37 title = self._html_search_regex(r'<h2>(.*?)</h2>', html, u'title')
38 xmlurl = self._search_regex(
39 r'(/mediathek/(?:.+)/(?:video|audio)[0-9]+-avCustom.xml)', html, u'XML URL')
41 doc = self._download_xml(domain + xmlurl, video_id)
43 for a in doc.findall('./assets/asset'):
44 url_el = a.find('.//progressiveDownloadUrl')
47 abr = int(a.find('bitrateAudio').text) // 1000
48 media_type = a.find('mediaType').text
51 'filesize': int(a.find('fileSize').text),
55 vbr_el = a.find('bitrateVideo')
59 'format_id': u'%s-%d' % (media_type, abr),
62 vbr = int(vbr_el.text) // 1000
65 'width': int(a.find('frameWidth').text),
66 'height': int(a.find('frameHeight').text),
67 'format_id': u'%s-%d' % (media_type, vbr),
69 formats.append(format)
70 formats.sort(key=lambda f: (f.get('vbr'), f['abr']))
72 raise ExtractorError(u'Could not find any valid formats')