]>
Commit | Line | Data |
---|---|---|
daaaf5f5 AC |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
e2b4808f S |
5 | from ..utils import ( |
6 | ExtractorError, | |
7 | int_or_none, | |
8 | try_get, | |
9 | unified_timestamp, | |
10 | ) | |
daaaf5f5 AC |
11 | |
12 | ||
13 | class VootIE(InfoExtractor): | |
e2b4808f S |
14 | _VALID_URL = r'https?://(?:www\.)?voot\.com/(?:[^/]+/)+(?P<id>\d+)' |
15 | _GEO_COUNTRIES = ['IN'] | |
16 | _TESTS = [{ | |
daaaf5f5 AC |
17 | 'url': 'https://www.voot.com/shows/ishq-ka-rang-safed/1/360558/is-this-the-end-of-kamini-/441353', |
18 | 'info_dict': { | |
5c5e60cf | 19 | 'id': '0_8ledb18o', |
daaaf5f5 AC |
20 | 'ext': 'mp4', |
21 | 'title': 'Ishq Ka Rang Safed - Season 01 - Episode 340', | |
e2b4808f | 22 | 'description': 'md5:06291fbbbc4dcbe21235c40c262507c1', |
e2b4808f S |
23 | 'timestamp': 1472162937, |
24 | 'upload_date': '20160825', | |
25 | 'duration': 1146, | |
26 | 'series': 'Ishq Ka Rang Safed', | |
27 | 'season_number': 1, | |
28 | 'episode': 'Is this the end of Kamini?', | |
29 | 'episode_number': 340, | |
30 | 'view_count': int, | |
31 | 'like_count': int, | |
32 | }, | |
33 | 'params': { | |
34 | 'skip_download': True, | |
35 | }, | |
36 | 'expected_warnings': ['Failed to download m3u8 information'], | |
37 | }, { | |
38 | 'url': 'https://www.voot.com/kids/characters/mighty-cat-masked-niyander-e-/400478/school-bag-disappears/440925', | |
39 | 'only_matching': True, | |
40 | }, { | |
41 | 'url': 'https://www.voot.com/movies/pandavas-5/424627', | |
42 | 'only_matching': True, | |
43 | }] | |
daaaf5f5 AC |
44 | |
45 | def _real_extract(self, url): | |
46 | video_id = self._match_id(url) | |
daaaf5f5 | 47 | |
e2b4808f S |
48 | media_info = self._download_json( |
49 | 'https://wapi.voot.com/ws/ott/getMediaInfo.json', video_id, | |
50 | query={ | |
51 | 'platform': 'Web', | |
52 | 'pId': 2, | |
53 | 'mediaId': video_id, | |
54 | }) | |
55 | ||
56 | status_code = try_get(media_info, lambda x: x['status']['code'], int) | |
57 | if status_code != 0: | |
58 | raise ExtractorError(media_info['status']['message'], expected=True) | |
59 | ||
60 | media = media_info['assets'] | |
daaaf5f5 | 61 | |
5c5e60cf | 62 | entry_id = media['EntryId'] |
e2b4808f | 63 | title = media['MediaName'] |
1c4804ef | 64 | formats = self._extract_m3u8_formats( |
5c5e60cf | 65 | 'https://cdnapisec.kaltura.com/p/1982551/playManifest/pt/https/f/applehttp/t/web/e/' + entry_id, |
23f511f5 RA |
66 | video_id, 'mp4', m3u8_id='hls') |
67 | self._sort_formats(formats) | |
daaaf5f5 | 68 | |
e2b4808f | 69 | description, series, season_number, episode, episode_number = [None] * 5 |
daaaf5f5 | 70 | |
e2b4808f S |
71 | for meta in try_get(media, lambda x: x['Metas'], list) or []: |
72 | key, value = meta.get('Key'), meta.get('Value') | |
73 | if not key or not value: | |
74 | continue | |
75 | if key == 'ContentSynopsis': | |
76 | description = value | |
77 | elif key == 'RefSeriesTitle': | |
78 | series = value | |
79 | elif key == 'RefSeriesSeason': | |
80 | season_number = int_or_none(value) | |
81 | elif key == 'EpisodeMainTitle': | |
82 | episode = value | |
83 | elif key == 'EpisodeNo': | |
84 | episode_number = int_or_none(value) | |
daaaf5f5 AC |
85 | |
86 | return { | |
5c5e60cf S |
87 | 'extractor_key': 'Kaltura', |
88 | 'id': entry_id, | |
e2b4808f S |
89 | 'title': title, |
90 | 'description': description, | |
91 | 'series': series, | |
92 | 'season_number': season_number, | |
93 | 'episode': episode, | |
94 | 'episode_number': episode_number, | |
95 | 'timestamp': unified_timestamp(media.get('CreationDate')), | |
96 | 'duration': int_or_none(media.get('Duration')), | |
97 | 'view_count': int_or_none(media.get('ViewCounter')), | |
98 | 'like_count': int_or_none(media.get('like_counter')), | |
1c4804ef | 99 | 'formats': formats, |
daaaf5f5 | 100 | } |