From 0e3ae92441e33f9fda2b92aefefd2aad27b9837a Mon Sep 17 00:00:00 2001 From: pulpe Date: Thu, 5 Jun 2014 18:48:03 +0200 Subject: [PATCH 1/4] [TagesschauIE] Add extractor for tagesschau.de (fixes #3049) --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/tagesschau.py | 81 ++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 youtube_dl/extractor/tagesschau.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index def58f1d6..4a640ab9c 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -266,6 +266,7 @@ from .streamcz import StreamCZIE from .swrmediathek import SWRMediathekIE from .syfy import SyfyIE from .sztvhu import SztvHuIE +from .tagesschau import TagesschauIE from .teamcoco import TeamcocoIE from .techtalks import TechTalksIE from .ted import TEDIE diff --git a/youtube_dl/extractor/tagesschau.py b/youtube_dl/extractor/tagesschau.py new file mode 100644 index 000000000..ffcf1c8c4 --- /dev/null +++ b/youtube_dl/extractor/tagesschau.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +import re +import json + +from .common import InfoExtractor + + +class TagesschauIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?tagesschau\.de/multimedia/video/video(?P-?\d+)\.html' + + _TESTS = [{ + 'url': 'http://www.tagesschau.de/multimedia/video/video1399128.html', + 'md5': 'bcdeac2194fb296d599ce7929dfa4009', + 'info_dict': { + 'id': '1399128', + 'ext': 'mp4', + 'title': 'Harald Range, Generalbundesanwalt, zu den Ermittlungen', + 'description': 'md5:69da3c61275b426426d711bde96463ab', + 'thumbnail': 're:^http:.*\.jpg$', + }, + }, { + 'url': 'http://www.tagesschau.de/multimedia/video/video-196.html', + 'md5': '8aaa8bf3ae1ca2652309718c03019128', + 'info_dict': { + 'id': '196', + 'ext': 'mp4', + 'title': 'Ukraine-Konflikt: Klitschko in Kiew als B\xfcrgermeister vereidigt', + 'description': 'md5:f22e4af75821d174fa6c977349682691', + 'thumbnail': 're:http://.*\.jpg', + }, + }] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + + if video_id.startswith('-'): + display_id = video_id.strip('-') + else: + display_id = video_id + + webpage = self._download_webpage(url, display_id) + + playerpage = self._download_webpage( + 'http://www.tagesschau.de/multimedia/video/video%s~player_autoplay-true.html' % video_id, display_id) + + medias = re.findall(r'"(http://media.+?)", type:"video/(.+?)", quality:"(.+?)"', playerpage) + + formats = [] + for url, ext, res in medias: + + if res == 's': + res = 'small' + quality = 0 + elif res == 'm': + res = 'medium' + quality = 1 + elif res == 'l': + res = 'large' + quality = 2 + + formats.append({ + 'format_id': res+'_'+ext, + 'url': url, + 'quality': quality, + 'ext': ext, + }) + + self._sort_formats(formats) + + thumbnail = re.findall(r'"(/multimedia/.+?\.jpg)"', playerpage)[-1] + + return { + 'id': display_id, + 'title': self._og_search_title(webpage).strip(), + 'thumbnail': 'http://www.tagesschau.de'+thumbnail, + 'formats': formats, + 'description': self._og_search_description(webpage).strip(), + } From 7ffad0af5ab392ed5ea7ec9165fd42d012a669f5 Mon Sep 17 00:00:00 2001 From: pulpe Date: Thu, 5 Jun 2014 18:49:34 +0200 Subject: [PATCH 2/4] [TagesschauIE] Remove unused import --- youtube_dl/extractor/tagesschau.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/tagesschau.py b/youtube_dl/extractor/tagesschau.py index ffcf1c8c4..bd935063f 100644 --- a/youtube_dl/extractor/tagesschau.py +++ b/youtube_dl/extractor/tagesschau.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals import re -import json from .common import InfoExtractor From 6a15923b77dc610b85810a15ce8a76f6688ed5e9 Mon Sep 17 00:00:00 2001 From: pulpe Date: Thu, 5 Jun 2014 19:34:30 +0200 Subject: [PATCH 3/4] [TagesschauIE] Add note to 2nd _download_webpage --- youtube_dl/extractor/tagesschau.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/tagesschau.py b/youtube_dl/extractor/tagesschau.py index bd935063f..fec1ff67e 100644 --- a/youtube_dl/extractor/tagesschau.py +++ b/youtube_dl/extractor/tagesschau.py @@ -43,7 +43,7 @@ class TagesschauIE(InfoExtractor): webpage = self._download_webpage(url, display_id) playerpage = self._download_webpage( - 'http://www.tagesschau.de/multimedia/video/video%s~player_autoplay-true.html' % video_id, display_id) + 'http://www.tagesschau.de/multimedia/video/video%s~player_autoplay-true.html' % video_id, display_id, 'Downloading player page') medias = re.findall(r'"(http://media.+?)", type:"video/(.+?)", quality:"(.+?)"', playerpage) From a45e6aadd7c8aa42d769b9c0ee0c7d29258efcf1 Mon Sep 17 00:00:00 2001 From: pulpe Date: Fri, 6 Jun 2014 09:00:28 +0200 Subject: [PATCH 4/4] [TagesschauIE] Fix possible error if quality is not defined --- youtube_dl/extractor/tagesschau.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/youtube_dl/extractor/tagesschau.py b/youtube_dl/extractor/tagesschau.py index fec1ff67e..e2ad7c393 100644 --- a/youtube_dl/extractor/tagesschau.py +++ b/youtube_dl/extractor/tagesschau.py @@ -59,6 +59,8 @@ class TagesschauIE(InfoExtractor): elif res == 'l': res = 'large' quality = 2 + else: + quality = 0 formats.append({ 'format_id': res+'_'+ext,