X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fmdr.py;h=fc7499958d750338116f5e14546e15c52377c0b9;hb=d5d7bdaeb517f389fff5a6557f072f3586e3c440;hp=7aa0080d735fe811d6babf110156f4ab895edbdd;hpb=c3afc93a69fbfbe7712278f7ad03d0369ac9f885;p=youtube-dl diff --git a/youtube_dl/extractor/mdr.py b/youtube_dl/extractor/mdr.py index 7aa0080d7..fc7499958 100644 --- a/youtube_dl/extractor/mdr.py +++ b/youtube_dl/extractor/mdr.py @@ -1,15 +1,18 @@ +from __future__ import unicode_literals + import re from .common import InfoExtractor -from ..utils import ( - ExtractorError, -) class MDRIE(InfoExtractor): - _VALID_URL = r'^(?P(?:https?://)?(?:www\.)?mdr\.de)/mediathek/(?:.*)/(?Pvideo|audio)(?P[^/_]+)_.*' - + _VALID_URL = r'^(?Phttps?://(?:www\.)?mdr\.de)/(?:.*)/(?Pvideo|audio)(?P[^/_]+)(?:_|\.html)' + # No tests, MDR regularily deletes its videos + _TEST = { + 'url': 'http://www.mdr.de/fakt/video189002.html', + 'only_matching': True, + } def _real_extract(self, url): m = re.match(self._VALID_URL, url) @@ -19,14 +22,14 @@ class MDRIE(InfoExtractor): # determine title and media streams from webpage html = self._download_webpage(url, video_id) - title = self._html_search_regex(r'

(.*?)

', html, u'title') + title = self._html_search_regex(r'(.*?)', html, 'title') xmlurl = self._search_regex( - r'(/mediathek/(?:.+)/(?:video|audio)[0-9]+-avCustom.xml)', html, u'XML URL') + r'dataURL:\'(/(?:.+)/(?:video|audio)[0-9]+-avCustom.xml)', html, 'XML URL') doc = self._download_xml(domain + xmlurl, video_id) formats = [] for a in doc.findall('./assets/asset'): - url_el = a.find('.//progressiveDownloadUrl') + url_el = a.find('./progressiveDownloadUrl') if url_el is None: continue abr = int(a.find('bitrateAudio').text) // 1000 @@ -41,7 +44,7 @@ class MDRIE(InfoExtractor): if vbr_el is None: format.update({ 'vcodec': 'none', - 'format_id': u'%s-%d' % (media_type, abr), + 'format_id': '%s-%d' % (media_type, abr), }) else: vbr = int(vbr_el.text) // 1000 @@ -49,12 +52,9 @@ class MDRIE(InfoExtractor): 'vbr': vbr, 'width': int(a.find('frameWidth').text), 'height': int(a.find('frameHeight').text), - 'format_id': u'%s-%d' % (media_type, vbr), + 'format_id': '%s-%d' % (media_type, vbr), }) formats.append(format) - if not formats: - raise ExtractorError(u'Could not find any valid formats') - self._sort_formats(formats) return {