From 22afd45ac8d69ec2060fe97109d3fc7852091c40 Mon Sep 17 00:00:00 2001 From: Sebastian Bank Date: Tue, 26 Apr 2016 19:36:42 +0200 Subject: [PATCH] [tele5] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/tele5.py | 63 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 youtube_dl/extractor/tele5.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 8b215c5ab..fcabd5f79 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -743,6 +743,7 @@ from .teamcoco import TeamcocoIE from .techtalks import TechTalksIE from .ted import TEDIE from .tele13 import Tele13IE +from .tele5 import Tele5IE from .telebruxelles import TeleBruxellesIE from .telecinco import TelecincoIE from .telegraaf import TelegraafIE diff --git a/youtube_dl/extractor/tele5.py b/youtube_dl/extractor/tele5.py new file mode 100644 index 000000000..6965ecef8 --- /dev/null +++ b/youtube_dl/extractor/tele5.py @@ -0,0 +1,63 @@ +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import strip_jsonp + + +class Tele5IE(InfoExtractor): + _VALID_URL = r'http://www\.tele5\.de/a-z/(?P.+)\.html' + + _TEST = { + 'url': 'http://www.tele5.de/a-z/man-vs-fly/ganze-folgen/video/boxer.html', + 'md5': '620973dde66000285b6a17d04d3950b8', + 'info_dict': { + 'id': '0_3vnqiwvl', + 'ext': 'mp4', + 'title': 'Man vs. Fly - Boxer (1)', + 'duration': 296, + }, + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + video_script = self._search_regex(r'(?s)', + webpage, 'player script') + video_params = self._parse_json(video_script, 'player script') + video_js_url = ('http://api.medianac.com/html5/html5lib/v2.39/mwEmbedFrame.php?' + '&wid={wid}' + '&uiconf_id={uiconf_id}' + '&cache_st={cache_st}' + '&entry_id={entry_id}' + '&flashvars[streamerType]=rtmp' + '&flashvars[mediaProtocol]=rtmp' + '&playerId={targetId}' + '&ServiceUrl=http%3A%2F%2Fapi.medianac.com' + '&CdnUrl=http%3A%2F%2Fapi.medianac.com' + '&ServiceBase=%2Fapi_v3%2Findex.php%3Fservice%3D' + '&UseManifestUrls=true' + '&forceMobileHTML5=true' + '&urid=2.39' + '&callback=mwi_kalturaplayer{cache_st}').format(**video_params) + + html = self._download_json(video_js_url, 'video js', transform_source=strip_jsonp)['content'] + info = self._search_regex(r'window\.kalturaIframePackageData = (\{.*?\}\});', html, None) + info = self._parse_json(info, None)['entryResult'] + + base = info['meta']['thumbnailUrl'].partition('/thumbnail/')[0] + url_tmpl = base + '/playManifest/entryId/{entryId}/flavorId/{id}/format/url/protocol/http/a.mp4' + return { + 'id': info['meta']['id'], + 'title': info['meta']['name'], + 'duration': info['meta']['duration'], + 'formats': [{ + 'url': url_tmpl.format(**f), + 'ext': f['fileExt'], + 'format_id': str(f['flavorParamsId']), + 'width': f['width'], + 'height': f['height'], + 'tbr': f['bitrate'], + 'fps': f['frameRate'], + 'filesize': f['size'] + } for f in info['contextData']['flavorAssets']] + }