2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
20 class Zee5IE(InfoExtractor
):
24 https?://(?:www\.)?zee5\.com/(?:[^#?]+/)?
26 (?:tv-shows|kids|zee5originals)(?:/[^#/?]+){3}
28 )/(?P<display_id>[^#/?]+)/
30 (?P<id>[^#/?]+)/?(?:$|[?#])
33 'url': 'https://www.zee5.com/movies/details/krishna-the-birth/0-0-63098',
37 'display_id': 'krishna-the-birth',
38 'title': 'Krishna - The Birth',
40 'description': compat_str
,
41 'alt_title': 'Krishna - The Birth',
42 'uploader': 'Zee Entertainment Enterprises Ltd',
43 'release_date': '20060101',
44 'upload_date': '20060101',
45 'timestamp': 1136073600,
46 'thumbnail': r
're:^https?://.*\.jpg$',
48 'episode': 'Episode 0',
55 'url': 'https://www.zee5.com/kids/kids-shows/bandbudh-aur-budbak/0-6-1899/yoga-se-hoga-bandbudh-aur-budbak/0-1-239839',
59 'display_id': 'yoga-se-hoga-bandbudh-aur-budbak',
60 'title': 'Yoga Se Hoga-Bandbudh aur Budbak',
62 'description': compat_str
,
63 'alt_title': 'Yoga Se Hoga-Bandbudh aur Budbak',
64 'uploader': 'Zee Entertainment Enterprises Ltd',
65 'release_date': '20150101',
66 'upload_date': '20150101',
67 'timestamp': 1420070400,
68 'thumbnail': r
're:^https?://.*\.jpg$',
69 'series': 'Bandbudh Aur Budbak',
72 'episode': 'Episode 1',
80 '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',
83 'url': 'https://www.zee5.com/global/hi/tv-shows/details/kundali-bhagya/0-6-366/kundali-bhagya-march-08-2021/0-1-manual_7g9jv1os7730',
86 _DETAIL_API_URL
= 'https://spapi.zee5.com/singlePlayback/getDetails?content_id={}&device_id={}&platform_name=desktop_web&country=IN&check_parental_control=false'
87 _DEVICE_ID
= 'iIxsxYf40cqO3koIkwzKHZhnJzHN13zb'
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'
93 username
, password
= self
._get
_login
_info
()
95 if len(username
) == 10 and username
.isdigit() and self
._USER
_TOKEN
is None:
97 otp_request_json
= self
._download
_json
('https://b2bapi.zee5.com/device/sendotp_v1.php?phoneno=91{}'.format(username
),
98 None, note
='Sending OTP')
99 if otp_request_json
['code'] == 0:
100 self
.to_screen(otp_request_json
['message'])
102 raise ExtractorError(otp_request_json
['message'], expected
=True)
103 otp_code
= self
._get
_tfa
_info
('OTP')
104 otp_verify_json
= self
._download
_json
('https://b2bapi.zee5.com/device/verifyotp_v1.php?phoneno=91{}&otp={}&guest_token={}&platform=web'.format(username
, otp_code
, self
._DEVICE
_ID
),
105 None, note
='Verifying OTP', fatal
=False)
106 if not otp_verify_json
:
107 raise ExtractorError('Unable to verify OTP.', expected
=True)
108 self
._USER
_TOKEN
= otp_verify_json
.get('token')
109 if not self
._USER
_TOKEN
:
110 raise ExtractorError(otp_request_json
['message'], expected
=True)
111 elif username
.lower() == 'token' and len(password
) > 1198:
112 self
._USER
_TOKEN
= password
114 raise ExtractorError(self
._LOGIN
_HINT
, expected
=True)
116 def _real_initialize(self
):
119 def _real_extract(self
, url
):
120 video_id
, display_id
= self
._match
_valid
_url
(url
).group('id', 'display_id')
121 access_token_request
= self
._download
_json
(
122 'https://useraction.zee5.com/token/platform_tokens.php?platform_name=web_app',
123 video_id
, note
='Downloading access token')
125 'x-access-token': access_token_request
['token']
128 data
['Authorization'] = 'bearer %s' % self
._USER
_TOKEN
130 data
['X-Z5-Guest-Token'] = self
._DEVICE
_ID
132 json_data
= self
._download
_json
(
133 self
._DETAIL
_API
_URL
.format(video_id
, self
._DEVICE
_ID
),
134 video_id
, headers
={'content-type': 'application/json'}
, data
=json
.dumps(data
).encode('utf-8'))
135 asset_data
= json_data
['assetDetails']
136 show_data
= json_data
.get('showDetails', {})
137 if 'premium' in asset_data
['business_type']:
138 raise ExtractorError('Premium content is DRM protected.', expected
=True)
139 if not asset_data
.get('hls_url'):
140 self
.raise_login_required(self
._LOGIN
_HINT
, metadata_available
=True, method
=None)
141 formats
, m3u8_subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(asset_data
['hls_url'], video_id
, 'mp4', fatal
=False)
142 self
._sort
_formats
(formats
)
145 for sub
in asset_data
.get('subtitle_url', []):
146 sub_url
= sub
.get('url')
149 subtitles
.setdefault(sub
.get('language', 'en'), []).append({
150 'url': self
._proto
_relative
_url
(sub_url
),
152 subtitles
= self
._merge
_subtitles
(subtitles
, m3u8_subs
)
155 'display_id': display_id
,
156 'title': asset_data
['title'],
158 'subtitles': subtitles
,
159 'duration': int_or_none(asset_data
.get('duration')),
160 'description': str_or_none(asset_data
.get('description')),
161 'alt_title': str_or_none(asset_data
.get('original_title')),
162 'uploader': str_or_none(asset_data
.get('content_owner')),
163 'age_limit': parse_age_limit(asset_data
.get('age_rating')),
164 'release_date': unified_strdate(asset_data
.get('release_date')),
165 'timestamp': unified_timestamp(asset_data
.get('release_date')),
166 'thumbnail': url_or_none(asset_data
.get('image_url')),
167 'series': str_or_none(asset_data
.get('tvshow_name')),
168 'season': try_get(show_data
, lambda x
: x
['seasons']['title'], str),
169 'season_number': int_or_none(try_get(show_data
, lambda x
: x
['seasons'][0]['orderid'])),
170 'episode_number': int_or_none(try_get(asset_data
, lambda x
: x
['orderid'])),
171 'tags': try_get(asset_data
, lambda x
: x
['tags'], list)
175 class Zee5SeriesIE(InfoExtractor
):
176 IE_NAME
= 'zee5:series'
177 _VALID_URL
= r
'''(?x)
180 https?://(?:www\.)?zee5\.com/(?:[^#?]+/)?
181 (?:tv-shows|kids|zee5originals)(?:/[^#/?]+){2}/
183 (?P<id>[^#/?]+)(?:/episodes)?/?(?:$|[?#])
186 'url': 'https://www.zee5.com/kids/kids-shows/bandbudh-aur-budbak/0-6-1899',
187 'playlist_mincount': 156,
192 'url': 'https://www.zee5.com/tv-shows/details/bhabi-ji-ghar-par-hai/0-6-199',
193 'playlist_mincount': 1500,
198 'url': 'https://www.zee5.com/tv-shows/details/agent-raghav-crime-branch/0-6-965',
199 'playlist_mincount': 24,
204 'url': 'https://www.zee5.com/ta/tv-shows/details/nagabhairavi/0-6-3201',
205 'playlist_mincount': 3,
210 'url': 'https://www.zee5.com/global/hi/tv-shows/details/khwaabon-ki-zamin-par/0-6-270',
211 'playlist_mincount': 150,
216 'url': 'https://www.zee5.com/tv-shows/details/chala-hawa-yeu-dya-ladies-zindabaad/0-6-2943/episodes',
217 'only_matching': True,
220 def _entries(self
, show_id
):
221 access_token_request
= self
._download
_json
(
222 'https://useraction.zee5.com/token/platform_tokens.php?platform_name=web_app',
223 show_id
, note
='Downloading access token')
225 'X-Access-Token': access_token_request
['token'],
226 'Referer': 'https://www.zee5.com/',
228 show_url
= 'https://gwapi.zee5.com/content/tvshow/{}?translation=en&country=IN'.format(show_id
)
231 show_json
= self
._download
_json
(show_url
, video_id
=show_id
, headers
=headers
)
232 for season
in show_json
.get('seasons') or []:
233 season_id
= try_get(season
, lambda x
: x
['id'], compat_str
)
234 next_url
= 'https://gwapi.zee5.com/content/tvshow/?season_id={}&type=episode&translation=en&country=IN&on_air=false&asset_subtype=tvshow&page=1&limit=100'.format(season_id
)
237 episodes_json
= self
._download
_json
(
238 next_url
, video_id
=show_id
, headers
=headers
,
239 note
='Downloading JSON metadata page %d' % page_num
)
240 for episode
in try_get(episodes_json
, lambda x
: x
['episode'], list) or []:
241 video_id
= episode
.get('id')
242 yield self
.url_result(
243 'zee5:%s' % video_id
,
244 ie
=Zee5IE
.ie_key(), video_id
=video_id
)
245 next_url
= url_or_none(episodes_json
.get('next_episode_api'))
247 def _real_extract(self
, url
):
248 show_id
= self
._match
_id
(url
)
249 return self
.playlist_result(self
._entries
(show_id
), playlist_id
=show_id
)