From fd2bd579117b7039a2b99080752b8b5952d09f93 Mon Sep 17 00:00:00 2001 From: Alex Seiler Date: Tue, 24 May 2016 18:59:54 +0200 Subject: [PATCH] [blick] Add new extractor (blick.ch is a swiss newspaper platform, which provides also videos) --- youtube_dl/extractor/blick.py | 123 +++++++++++++++++++++++++++++ youtube_dl/extractor/extractors.py | 1 + 2 files changed, 124 insertions(+) create mode 100644 youtube_dl/extractor/blick.py diff --git a/youtube_dl/extractor/blick.py b/youtube_dl/extractor/blick.py new file mode 100644 index 000000000..3a0977205 --- /dev/null +++ b/youtube_dl/extractor/blick.py @@ -0,0 +1,123 @@ +# encoding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +import re + + +class BlickIE(InfoExtractor): + _VALID_URL = r'(?:https?://)?(?:www\.)?blick\.ch/.*-id(?P\d+).*\.html' + + _TESTS = [{ + 'url': 'http://www.blick.ch/sport/uli-forte-vor-dem-abstiegs-showdown-ich-gehe-davon-aus-dass-der-fussball-gott-fcz-fan-ist-id5070813.html', + 'info_dict': { + 'id': '5070813', + 'ext': 'mp4', + 'title': 'uli-forte-vor-dem-abstiegs-showdown-ich-gehe-davon-aus-dass-der-fussball-gott-fcz-fan-ist', + 'thumbnail': 'http://blick.simplex.tv/content/51/52/70062/simvid_1.jpg', + 'description': 'Am Mittwochabend entscheidet sich, ob der FCZ oder der FC Lugano aus der Super League absteigt. Uli Forte schwört dabei auf den Fussball-Gott und zündet in der Kirche eine Kerze an.' + } + }, { + 'url': 'http://www.blick.ch/sport/tennis/nominiert-fuer-musik-preis-in-schweden-so-toll-singt-guenthardts-tochter-alessandra-id5066863.html', + 'info_dict': { + 'id': '5066863', + 'ext': 'mp4', + 'title': 'nominiert-fuer-musik-preis-in-schweden-so-toll-singt-guenthardts-tochter-alessandra', + 'thumbnail': 'http://f.blick.ch/img/incoming/crop5066860/5146024130-csquare-w300-h300/Bildschirmfoto-2016-05-23-um-14.jpg', + 'description': 'Da ist Papa Heinz mächtig stolz. Seine Tochter Alessandra Günthardt ist für einen schwedischen Musik-Preis unter den drei Nominierten. Die Abstimmung läuft noch bis 7. Juni.' + } + }] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + webpage = self._download_webpage(url, video_id) + + found_videos_og = re.findall(r'= 1000 and tbr < 2000: + attr = 'sq' + elif tbr >= 2000: + attr = 'hq' + except TypeError: + attr = 'un' + elem['format_id'] = attr + '-' + str(tbr) + entry_info_dict['duration'] = duration + return entry_info_dict + + def calculateDuration(self, m3u8_url, video_id): + content = self._download_webpage_handle( + m3u8_url, + video_id, + note='Downloading m3u8 information', + errnote='Failed to download m3u8 information', + fatal=False + ) + if content is False: + return None + m3u8_doc, rlh = content + duration = 0.0 + try: + for line in m3u8_doc.splitlines(): + if line.startswith('#EXTINF:'): + dur = line[8:].strip()[:-1] + duration += float(dur) + except ValueError: + return None + return duration diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index f9fed18f6..e2a6cf315 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -84,6 +84,7 @@ from .bleacherreport import ( BleacherReportIE, BleacherReportCMSIE, ) +from .blick import BlickIE from .blinkx import BlinkxIE from .bloomberg import BloombergIE from .bokecc import BokeCCIE