From e8f2025edf789647dc8569a69f05c8e1b54f46da Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 21 Apr 2014 06:25:21 +0200 Subject: [PATCH] [mdr] Add support for modern URLs (Fixes #2775) --- youtube_dl/extractor/mdr.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/youtube_dl/extractor/mdr.py b/youtube_dl/extractor/mdr.py index 7aa0080d73..271dccf537 100644 --- a/youtube_dl/extractor/mdr.py +++ b/youtube_dl/extractor/mdr.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import re from .common import InfoExtractor @@ -7,9 +9,13 @@ from ..utils import ( 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,9 +25,9 @@ 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 = [] @@ -41,7 +47,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 +55,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 {