]>
Commit | Line | Data |
---|---|---|
da6dcbad A |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
7 | from ..utils import ( | |
8 | int_or_none, | |
9 | parse_age_limit, | |
10 | str_or_none, | |
11 | try_get, | |
12 | unified_strdate, | |
13 | unified_timestamp, | |
14 | url_or_none, | |
15 | ) | |
16 | ||
17 | ||
18 | class Zee5IE(InfoExtractor): | |
19 | _VALID_URL = r'https?://(?:www\.)?zee5\.com/[^#?]*/(?P<display_id>[-\w]+)/(?P<id>[-\d]+)' | |
20 | _TESTS = [{ | |
21 | 'url': 'https://www.zee5.com/movies/details/krishna-the-birth/0-0-63098', | |
22 | 'info_dict': { | |
23 | "id": "0-0-63098", | |
24 | "ext": "m3u8", | |
25 | "display_id": "krishna-the-birth", | |
26 | "title": "Krishna - The Birth", | |
27 | "duration": 4368, | |
28 | "average_rating": 4, | |
29 | "description": str, | |
30 | "alt_title": "Krishna - The Birth", | |
31 | "uploader": "Zee Entertainment Enterprises Ltd", | |
32 | "release_date": "20060101", | |
33 | "upload_date": "20060101", | |
34 | "timestamp": 1136073600, | |
35 | "thumbnail": "https://akamaividz.zee5.com/resources/0-0-63098/list/270x152/0063098_list_80888170.jpg", | |
36 | "tags": list | |
37 | }, | |
38 | 'params': { | |
39 | 'format': 'bv', | |
40 | }, | |
41 | }, { | |
42 | 'url': 'https://zee5.com/tvshows/details/krishna-balram/0-6-1871/episode-1-the-test-of-bramha/0-1-233402', | |
43 | 'info_dict': { | |
44 | "id": "0-1-233402", | |
45 | 'ext': 'm3u8', | |
46 | "display_id": "episode-1-the-test-of-bramha", | |
47 | "title": "Episode 1 - The Test Of Bramha", | |
48 | "duration": 1336, | |
49 | "average_rating": 4, | |
50 | "description": str, | |
51 | "alt_title": "Episode 1 - The Test Of Bramha", | |
52 | "uploader": "Green Gold", | |
53 | "release_date": "20090101", | |
54 | "upload_date": "20090101", | |
55 | "timestamp": 1230768000, | |
56 | "thumbnail": "https://akamaividz.zee5.com/resources/0-1-233402/list/270x152/01233402_list.jpg", | |
57 | "series": "Krishna Balram", | |
58 | "season_number": 1, | |
59 | "episode_number": 1, | |
60 | "tags": list, | |
61 | }, | |
62 | 'params': { | |
63 | 'format': 'bv', | |
64 | }, | |
65 | }] | |
66 | ||
67 | def _real_extract(self, url): | |
68 | video_id, display_id = re.match(self._VALID_URL, url).group('id', 'display_id') | |
69 | access_token_request = self._download_json( | |
70 | 'https://useraction.zee5.com/token/platform_tokens.php?platform_name=web_app', | |
71 | video_id, note="Downloading access token") | |
72 | token_request = self._download_json( | |
73 | 'https://useraction.zee5.com/tokennd', | |
74 | video_id, note="Downloading video token") | |
75 | json_data = self._download_json( | |
76 | 'https://gwapi.zee5.com/content/details/{}?translation=en&country=IN'.format(video_id), | |
77 | video_id, headers={'X-Access-Token': access_token_request['token']}) | |
78 | m3u8_url = try_get( | |
79 | json_data, | |
80 | (lambda x: x['hls'][0], lambda x: x['video_details']['hls_url']), | |
81 | str) | |
82 | formats = self._extract_m3u8_formats( | |
83 | 'https://zee5vodnd.akamaized.net' + m3u8_url.replace('/drm1/', '/hls1/') + token_request['video_token'], | |
84 | video_id, fatal=False) | |
85 | mpd_url = try_get( | |
86 | json_data, | |
87 | (lambda x: x['video'][0], lambda x: x['video_details']['url']), | |
88 | str) | |
89 | formats += self._extract_mpd_formats( | |
90 | 'https://zee5vodnd.akamaized.net' + mpd_url + token_request['video_token'], | |
91 | video_id, fatal=False) | |
92 | ||
93 | self._sort_formats(formats) | |
94 | return { | |
95 | 'id': video_id, | |
96 | 'display_id': display_id, | |
97 | 'title': json_data['title'], | |
98 | 'formats': formats, | |
99 | 'duration': int_or_none(json_data.get('duration')), | |
100 | 'average_rating': int_or_none(json_data.get('rating')), | |
101 | 'description': str_or_none(json_data.get('description')), | |
102 | 'alt_title': str_or_none(json_data.get('original_title')), | |
103 | 'uploader': str_or_none(json_data.get('content_owner')), | |
104 | 'age_limit': parse_age_limit(json_data.get('age_rating')), | |
105 | 'release_date': unified_strdate(json_data.get('release_date')), | |
106 | 'timestamp': unified_timestamp(json_data.get('release_date')), | |
107 | 'thumbnail': url_or_none(json_data.get('image_url')), | |
108 | 'series': try_get(json_data, lambda x: x['tvshow_details']['title'], str), | |
109 | 'season': try_get(json_data, lambda x: x['season_details']['title'], str), | |
110 | 'season_number': int_or_none(try_get(json_data, lambda x: x['season_details']['index'])), | |
111 | 'episode_number': int_or_none(try_get(json_data, lambda x: x['index'])), | |
112 | 'tags': try_get(json_data, lambda x: x['tags'], list) | |
113 | } |