From 20e971246ccd24d71487cfe30cfbb611ce54b7e6 Mon Sep 17 00:00:00 2001 From: Ashutosh Chaudhary Date: Mon, 23 Jan 2017 05:12:52 +0530 Subject: [PATCH 1/2] Added voot extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/voot.py | 53 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 youtube_dl/extractor/voot.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index cfddf5b92..e3015e4c4 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1226,3 +1226,4 @@ from .youtube import ( from .zapiks import ZapiksIE from .zdf import ZDFIE, ZDFChannelIE from .zingmp3 import ZingMp3IE +from .voot import VootIE diff --git a/youtube_dl/extractor/voot.py b/youtube_dl/extractor/voot.py new file mode 100644 index 000000000..4d86bbfba --- /dev/null +++ b/youtube_dl/extractor/voot.py @@ -0,0 +1,53 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class VootIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?voot\.com/shows/(?:.+?[/-]?)/1/(?:.+?[0-9]?)/(?:.+?[/-]?)/(?P[0-9]+)' + _TEST = { + 'url': 'https://www.voot.com/shows/ishq-ka-rang-safed/1/360558/is-this-the-end-of-kamini-/441353', + 'info_dict': { + 'id': '441353', + 'ext': 'mp4', + 'title': 'Ishq Ka Rang Safed - Season 01 - Episode 340', + 'thumbnail': r're:^https?://.*\.jpg$', + } + } + + _GET_CONTENT_TEMPLATE = 'https://wapi.voot.com/ws/ott/getMediaInfo.json?platform=Web&pId=3&mediaId=%s' + + def _download_json(self, url_or_request, video_id, note='Downloading JSON metadata', fatal=True): + json_data = super(VootIE, self)._download_json(url_or_request, video_id, note, fatal=fatal) + if json_data['status']['code'] != 0: + if fatal: + raise ExtractorError(json_data['status']['message']) + return None + return json_data['assets'] + + def _real_extract(self, url): + video_id = self._match_id(url) + video_data = self._download_json( + self._GET_CONTENT_TEMPLATE % video_id, + video_id) + + thumbnail = '' + formats = [] + + if video_data: + format_url = video_data.get('URL') + formats.extend(self._extract_m3u8_formats(format_url, video_id, 'mp4', m3u8_id='hls', fatal=False)) + + if video_data['Pictures']: + for picture in video_data['Pictures']: + thumbnail = picture.get('URL') + + self._sort_formats(formats) + + return { + 'id': video_id, + 'title': video_data.get('MediaName'), + 'thumbnail': thumbnail, + 'formats':formats, + } \ No newline at end of file From 2ea834e632dfcd741b77d097028985cf7189e12e Mon Sep 17 00:00:00 2001 From: ashutosh chaudhary <216.ashutosh@gmail.com> Date: Mon, 23 Jan 2017 05:16:42 +0530 Subject: [PATCH 2/2] Updated code to get only first available thumbnail --- youtube_dl/extractor/voot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/voot.py b/youtube_dl/extractor/voot.py index 4d86bbfba..db5bda660 100644 --- a/youtube_dl/extractor/voot.py +++ b/youtube_dl/extractor/voot.py @@ -41,7 +41,9 @@ class VootIE(InfoExtractor): if video_data['Pictures']: for picture in video_data['Pictures']: + #Get only first available thumbnail thumbnail = picture.get('URL') + break self._sort_formats(formats) @@ -50,4 +52,4 @@ class VootIE(InfoExtractor): 'title': video_data.get('MediaName'), 'thumbnail': thumbnail, 'formats':formats, - } \ No newline at end of file + }