From 3f79e71c626d852e78f2a7d1f8fc7e549c2f6e50 Mon Sep 17 00:00:00 2001 From: pingtux Date: Sat, 2 Jan 2016 01:13:49 +0100 Subject: [PATCH 1/2] [20min.ch] Add new extractor (closes #5977) --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/min20.py | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 youtube_dl/extractor/min20.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 7adce5499..52d548753 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -364,6 +364,7 @@ from .mdr import MDRIE from .metacafe import MetacafeIE from .metacritic import MetacriticIE from .mgoon import MgoonIE +from .min20 import Min20IE from .minhateca import MinhatecaIE from .ministrygrid import MinistryGridIE from .miomio import MioMioIE diff --git a/youtube_dl/extractor/min20.py b/youtube_dl/extractor/min20.py new file mode 100644 index 000000000..a3f91671e --- /dev/null +++ b/youtube_dl/extractor/min20.py @@ -0,0 +1,40 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class Min20IE(InfoExtractor): + _VALID_URL = r'http://www\.20min\.ch/.+?-(?P[0-9]+)$' + _TEST = { + 'url': 'http://www.20min.ch/schweiz/news/story/-Wir-muessen-mutig-nach-vorne-schauen--22050469', + 'md5': 'cd4cbb99b94130cff423e967cd275e5e', + 'info_dict': { + 'id': '22050469', + 'ext': 'flv', + 'title': '«Wir müssen mutig nach vorne schauen»', + 'description': 'Kein Land sei innovativer als die Schweiz, sagte Johann Schneider-Ammann in seiner Neujahrsansprache. Das Land müsse aber seine Hausaufgaben machen.', + 'thumbnail': 'http://www.20min.ch/images/content/2/2/0/22050469/10/teaserbreit.jpg' + } + } + + # location of the flv videos, can't be extracted from the web page + _BASE_URL = "http://flv-rr.20min-tv.ch/videos/" + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + title = self._html_search_regex(r'

(.+?)

', webpage, 'title') + flash_id = self._search_regex(r"so\.addVariable\(\"file1\",\"([0-9]+)\"\)", webpage, 'flash_id') + + description = self._html_search_regex(r'', webpage, 'description') + thumbnail = self._html_search_regex(r'', webpage, 'thumbnail') + url = self._BASE_URL + flash_id + "m.flv" + + return { + 'id': video_id, + 'url': url, + 'title': title, + 'description': description, + 'thumbnail': thumbnail + } From 7496950d016feb52276bfc64740f4f6aa6e207cc Mon Sep 17 00:00:00 2001 From: pingtux Date: Sat, 2 Jan 2016 16:19:05 +0100 Subject: [PATCH 2/2] [20min.ch] Added support for videoportal --- youtube_dl/extractor/min20.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/min20.py b/youtube_dl/extractor/min20.py index a3f91671e..23aead19d 100644 --- a/youtube_dl/extractor/min20.py +++ b/youtube_dl/extractor/min20.py @@ -1,12 +1,14 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor class Min20IE(InfoExtractor): - _VALID_URL = r'http://www\.20min\.ch/.+?-(?P[0-9]+)$' - _TEST = { + _VALID_URL = r'http://www\.20min\.ch/(videotv/\?vid=(?P[0-9]+)|.+?-(?P[0-9]+)$)' + _TESTS = [{ 'url': 'http://www.20min.ch/schweiz/news/story/-Wir-muessen-mutig-nach-vorne-schauen--22050469', 'md5': 'cd4cbb99b94130cff423e967cd275e5e', 'info_dict': { @@ -16,15 +18,29 @@ class Min20IE(InfoExtractor): 'description': 'Kein Land sei innovativer als die Schweiz, sagte Johann Schneider-Ammann in seiner Neujahrsansprache. Das Land müsse aber seine Hausaufgaben machen.', 'thumbnail': 'http://www.20min.ch/images/content/2/2/0/22050469/10/teaserbreit.jpg' } - } + }, { + 'url': 'http://www.20min.ch/videotv/?vid=469148&cid=2', + 'md5': 'b52d6bc6ea6398e6a38f12cfd418149c', + 'info_dict': { + 'id': '469148', + 'ext': 'flv', + 'title': '85 000 Franken für 15 perfekte Minuten', + 'description': 'Was die Besucher vom Silvesterzauber erwarten können. (Video: Alice Grosjean/Murat Temel)', + 'thumbnail': 'http://thumbnails.20min-tv.ch/server063/469148/frame-72-469148.jpg' + } + }] # location of the flv videos, can't be extracted from the web page _BASE_URL = "http://flv-rr.20min-tv.ch/videos/" def _real_extract(self, url): - video_id = self._match_id(url) + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('page_id') + if video_id is None: + # URL from the videoportal + video_id = mobj.group('video_id') webpage = self._download_webpage(url, video_id) - title = self._html_search_regex(r'

(.+?)

', webpage, 'title') + title = self._html_search_regex(r'

.*(.+?)

', webpage, 'title') flash_id = self._search_regex(r"so\.addVariable\(\"file1\",\"([0-9]+)\"\)", webpage, 'flash_id') description = self._html_search_regex(r'', webpage, 'description')