[voot] Add extractor
authorAshutosh Chaudhary <ashutosh.chaudhary@gmail.com>
Sun, 22 Jan 2017 23:42:52 +0000 (05:12 +0530)
committerSergey M․ <dstftw@gmail.com>
Sun, 6 Aug 2017 01:05:24 +0000 (08:05 +0700)
youtube_dl/extractor/extractors.py
youtube_dl/extractor/voot.py [new file with mode: 0644]

index d0e04dd7d6de8f0dc10e501cfda23a092d3567ad..48dda8b8e5ebf5493c9c3f76ac1b80a490c90c33 100644 (file)
@@ -1333,3 +1333,4 @@ from .zapiks import ZapiksIE
 from .zaq1 import Zaq1IE
 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 (file)
index 0000000..db5bda6
--- /dev/null
@@ -0,0 +1,55 @@
+# 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<id>[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']:
+                #Get only first available thumbnail
+                thumbnail = picture.get('URL')
+                break
+
+        self._sort_formats(formats)
+
+        return {
+            'id': video_id,
+            'title': video_data.get('MediaName'),
+            'thumbnail': thumbnail,
+            'formats':formats,
+        }