3 from .common
import InfoExtractor
4 from ..compat
import compat_str
17 class Zee5IE(InfoExtractor
):
21 https?://(?:www\.)?zee5\.com/(?:[^#?]+/)?
23 (?:tv-shows|kids|web-series|zee5originals)(?:/[^#/?]+){3}
25 )/(?P<display_id>[^#/?]+)/
27 (?P<id>[^#/?]+)/?(?:$|[?#])
30 'url': 'https://www.zee5.com/movies/details/krishna-the-birth/0-0-63098',
34 'display_id': 'krishna-the-birth',
35 'title': 'Krishna - The Birth',
37 'description': compat_str
,
38 'alt_title': 'Krishna - The Birth',
39 'uploader': 'Zee Entertainment Enterprises Ltd',
40 'release_date': '20060101',
41 'upload_date': '20060101',
42 'timestamp': 1136073600,
43 'thumbnail': r
're:^https?://.*\.jpg$',
45 'episode': 'Episode 0',
52 'url': 'https://www.zee5.com/kids/kids-shows/bandbudh-aur-budbak/0-6-1899/yoga-se-hoga-bandbudh-aur-budbak/0-1-239839',
56 'display_id': 'yoga-se-hoga-bandbudh-aur-budbak',
57 'title': 'Yoga Se Hoga-Bandbudh aur Budbak',
59 'description': compat_str
,
60 'alt_title': 'Yoga Se Hoga-Bandbudh aur Budbak',
61 'uploader': 'Zee Entertainment Enterprises Ltd',
62 'release_date': '20150101',
63 'upload_date': '20150101',
64 'timestamp': 1420070400,
65 'thumbnail': r
're:^https?://.*\.jpg$',
66 'series': 'Bandbudh Aur Budbak',
69 'episode': 'Episode 1',
77 'url': 'https://www.zee5.com/hi/tv-shows/details/kundali-bhagya/0-6-366/kundali-bhagya-march-08-2021/0-1-manual_7g9jv1os7730?country=IN',
80 'url': 'https://www.zee5.com/global/hi/tv-shows/details/kundali-bhagya/0-6-366/kundali-bhagya-march-08-2021/0-1-manual_7g9jv1os7730',
83 'url': 'https://www.zee5.com/web-series/details/mithya/0-6-4z587408/maine-dekhi-hai-uski-mrityu/0-1-6z587412',
86 _DETAIL_API_URL
= 'https://spapi.zee5.com/singlePlayback/getDetails/secure?content_id={}&device_id={}&platform_name=desktop_web&country=IN&check_parental_control=false'
87 _DEVICE_ID
= 'TszZPYPuY9Pq2cJizV0U000000000000'
89 _LOGIN_HINT
= 'Use "--username <mobile_number>" to login using otp or "--username token" and "--password <user_token>" to login using user token.'
90 _NETRC_MACHINE
= 'zee5'
91 _GEO_COUNTRIES
= ['IN']
93 def _perform_login(self
, username
, password
):
94 if len(username
) == 10 and username
.isdigit() and self
._USER
_TOKEN
is None:
96 otp_request_json
= self
._download
_json
(f
'https://b2bapi.zee5.com/device/sendotp_v1.php?phoneno=91{username}',
97 None, note
='Sending OTP')
98 if otp_request_json
['code'] == 0:
99 self
.to_screen(otp_request_json
['message'])
101 raise ExtractorError(otp_request_json
['message'], expected
=True)
102 otp_code
= self
._get
_tfa
_info
('OTP')
103 otp_verify_json
= self
._download
_json
(f
'https://b2bapi.zee5.com/device/verifyotp_v1.php?phoneno=91{username}&otp={otp_code}&guest_token={self._DEVICE_ID}&platform=web',
104 None, note
='Verifying OTP', fatal
=False)
105 if not otp_verify_json
:
106 raise ExtractorError('Unable to verify OTP.', expected
=True)
107 self
._USER
_TOKEN
= otp_verify_json
.get('token')
108 if not self
._USER
_TOKEN
:
109 raise ExtractorError(otp_request_json
['message'], expected
=True)
110 elif username
.lower() == 'token' and len(password
) > 1198:
111 self
._USER
_TOKEN
= password
113 raise ExtractorError(self
._LOGIN
_HINT
, expected
=True)
115 def _real_extract(self
, url
):
116 video_id
, display_id
= self
._match
_valid
_url
(url
).group('id', 'display_id')
117 access_token_request
= self
._download
_json
(
118 'https://useraction.zee5.com/token/platform_tokens.php?platform_name=web_app',
119 video_id
, note
='Downloading access token')
121 'x-access-token': access_token_request
['token']
124 data
['Authorization'] = 'bearer %s' % self
._USER
_TOKEN
126 data
['X-Z5-Guest-Token'] = self
._DEVICE
_ID
128 json_data
= self
._download
_json
(
129 self
._DETAIL
_API
_URL
.format(video_id
, self
._DEVICE
_ID
),
130 video_id
, headers
={'content-type': 'application/json'}
, data
=json
.dumps(data
).encode('utf-8'))
131 asset_data
= json_data
['assetDetails']
132 show_data
= json_data
.get('showDetails', {})
133 if 'premium' in asset_data
['business_type']:
134 raise ExtractorError('Premium content is DRM protected.', expected
=True)
135 if not asset_data
.get('hls_url'):
136 self
.raise_login_required(self
._LOGIN
_HINT
, metadata_available
=True, method
=None)
137 formats
, m3u8_subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(asset_data
['hls_url'], video_id
, 'mp4', fatal
=False)
138 self
._sort
_formats
(formats
)
141 for sub
in asset_data
.get('subtitle_url', []):
142 sub_url
= sub
.get('url')
145 subtitles
.setdefault(sub
.get('language', 'en'), []).append({
146 'url': self
._proto
_relative
_url
(sub_url
),
148 subtitles
= self
._merge
_subtitles
(subtitles
, m3u8_subs
)
151 'display_id': display_id
,
152 'title': asset_data
['title'],
154 'subtitles': subtitles
,
155 'duration': int_or_none(asset_data
.get('duration')),
156 'description': str_or_none(asset_data
.get('description')),
157 'alt_title': str_or_none(asset_data
.get('original_title')),
158 'uploader': str_or_none(asset_data
.get('content_owner')),
159 'age_limit': parse_age_limit(asset_data
.get('age_rating')),
160 'release_date': unified_strdate(asset_data
.get('release_date')),
161 'timestamp': unified_timestamp(asset_data
.get('release_date')),
162 'thumbnail': url_or_none(asset_data
.get('image_url')),
163 'series': str_or_none(asset_data
.get('tvshow_name')),
164 'season': try_get(show_data
, lambda x
: x
['seasons']['title'], str),
165 'season_number': int_or_none(try_get(show_data
, lambda x
: x
['seasons'][0]['orderid'])),
166 'episode_number': int_or_none(try_get(asset_data
, lambda x
: x
['orderid'])),
167 'tags': try_get(asset_data
, lambda x
: x
['tags'], list)
171 class Zee5SeriesIE(InfoExtractor
):
172 IE_NAME
= 'zee5:series'
173 _VALID_URL
= r
'''(?x)
176 https?://(?:www\.)?zee5\.com/(?:[^#?]+/)?
177 (?:tv-shows|web-series|kids|zee5originals)(?:/[^#/?]+){2}/
179 (?P<id>[^#/?]+)(?:/episodes)?/?(?:$|[?#])
182 'url': 'https://www.zee5.com/kids/kids-shows/bandbudh-aur-budbak/0-6-1899',
183 'playlist_mincount': 156,
188 'url': 'https://www.zee5.com/tv-shows/details/bhabi-ji-ghar-par-hai/0-6-199',
189 'playlist_mincount': 1500,
194 'url': 'https://www.zee5.com/tv-shows/details/agent-raghav-crime-branch/0-6-965',
195 'playlist_mincount': 24,
200 'url': 'https://www.zee5.com/ta/tv-shows/details/nagabhairavi/0-6-3201',
201 'playlist_mincount': 3,
206 'url': 'https://www.zee5.com/global/hi/tv-shows/details/khwaabon-ki-zamin-par/0-6-270',
207 'playlist_mincount': 150,
212 'url': 'https://www.zee5.com/tv-shows/details/chala-hawa-yeu-dya-ladies-zindabaad/0-6-2943/episodes',
213 'only_matching': True,
215 'url': 'https://www.zee5.com/web-series/details/mithya/0-6-4z587408',
216 'only_matching': True,
219 def _entries(self
, show_id
):
220 access_token_request
= self
._download
_json
(
221 'https://useraction.zee5.com/token/platform_tokens.php?platform_name=web_app',
222 show_id
, note
='Downloading access token')
224 'X-Access-Token': access_token_request
['token'],
225 'Referer': 'https://www.zee5.com/',
227 show_url
= f
'https://gwapi.zee5.com/content/tvshow/{show_id}?translation=en&country=IN'
230 show_json
= self
._download
_json
(show_url
, video_id
=show_id
, headers
=headers
)
231 for season
in show_json
.get('seasons') or []:
232 season_id
= try_get(season
, lambda x
: x
['id'], compat_str
)
233 next_url
= f
'https://gwapi.zee5.com/content/tvshow/?season_id={season_id}&type=episode&translation=en&country=IN&on_air=false&asset_subtype=tvshow&page=1&limit=100'
236 episodes_json
= self
._download
_json
(
237 next_url
, video_id
=show_id
, headers
=headers
,
238 note
='Downloading JSON metadata page %d' % page_num
)
239 for episode
in try_get(episodes_json
, lambda x
: x
['episode'], list) or []:
240 video_id
= episode
.get('id')
241 yield self
.url_result(
242 'zee5:%s' % video_id
,
243 ie
=Zee5IE
.ie_key(), video_id
=video_id
)
244 next_url
= url_or_none(episodes_json
.get('next_episode_api'))
246 def _real_extract(self
, url
):
247 show_id
= self
._match
_id
(url
)
248 return self
.playlist_result(self
._entries
(show_id
), playlist_id
=show_id
)