From 12dc5ea0951a5c0264a7f594b144426f42fa2670 Mon Sep 17 00:00:00 2001 From: relrelb Date: Fri, 20 Apr 2018 20:56:26 +0300 Subject: [PATCH] Add MakoTV extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/makotv.py | 64 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 youtube_dl/extractor/makotv.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 3570fa165..f57a662b8 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -579,6 +579,7 @@ from .mailru import ( ) from .makerschannel import MakersChannelIE from .makertv import MakerTVIE +from .makotv import MakoTVIE from .mangomolo import ( MangomoloVideoIE, MangomoloLiveIE, diff --git a/youtube_dl/extractor/makotv.py b/youtube_dl/extractor/makotv.py new file mode 100644 index 000000000..45d7f3798 --- /dev/null +++ b/youtube_dl/extractor/makotv.py @@ -0,0 +1,64 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + +from urllib import urlencode +from urlparse import urlparse, urlunparse, urljoin + + +class MakoTVIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?mako\.co\.il/mako-vod-.+/VOD-(?P[0-9a-f]{18})\.htm' + _TEST = { + 'url': 'https://www.mako.co.il/mako-vod-keshet/parliament-s1/VOD-5df5a86c1966831006.htm', + 'md5': 'cd8cdff75390f8521831ec5049841764', + 'info_dict': { + 'id': '5df5a86c1966831006', + 'ext': 'm3u8', + 'title': 'הפרלמנט | פרק 1 לצפייה ישירה | makoTV ', + 'thumbnail': r're:^https?://img\.mako\.co\.il/\d{4}/\d{2}/\d{2}/.*\.jpg$', # https://img.mako.co.il/2012/07/08/Parlament_01_VOD_c.jpg + 'description': 'שאולי, אמציה, הקטור, קרקו ואבי מקבלים סדרה משלהם. כל הפרקים של הפרלמנט לצפייה ישירה | makoTV ', + 'upload_date': '20120708', + 'timestamp': 1341751140 + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + parsed_url = list(urlparse(url)) + parsed_url[4] = urlencode({'type': 'service'}) + service = self._download_json(urlunparse(parsed_url), video_id) + video = service['root']['video'] + + config_new = self._download_xml('https://rcs.mako.co.il/flash_swf/players/makoPlayer/configNew.xml', video_id) + playlist_url = config_new.findtext('./PlaylistUrl') + playlist_url = playlist_url.replace('$$vcmid$$', video['guid']) + playlist_url = playlist_url.replace('$$videoChannelId$$', video['chId']) + playlist_url = playlist_url.replace('$$galleryChannelId$$', video['galleryChId']) + playlist = self._download_json('https://www.mako.co.il' + playlist_url, video_id) + + # config = self._download_json('https://www.mako.co.il/makotv/config.json', video_id) + # get_ticket_service = config['sources']['billing-services']['get-ticket-service'] + formats = [] + for media in playlist['media']: + tickets = self._download_json('https://mass.mako.co.il/ClicksStatistics/entitlementsServicesV2.jsp?et=gt&lp={}&rv={}'.format(media['url'], media['cdn']), video_id) + assert tickets['status'] == 'success' + for ticket in tickets['tickets']: + ticket_url = urljoin('https://makostore-hd.ctedgecdn.net', '{}?{}'.format(ticket['url'], ticket['ticket'])) + formats.extend(self._extract_m3u8_formats(ticket_url, video_id)) + + self._sort_formats(formats) + + info = self._search_json_ld(webpage, video_id) + info.update({ + 'id': video_id, + 'title': self._og_search_title(webpage), + 'thumbnail': self._og_search_thumbnail(webpage), + 'description': self._og_search_description(webpage), + 'formats': formats + # TODO more properties (see youtube_dl/extractor/common.py) + }) + + return info