- _GEO_COUNTRIES = ['IN']
-
- def _download_json(self, *args, **kwargs):
- response = super(HotStarBaseIE, self)._download_json(*args, **kwargs)
- if response['resultCode'] != 'OK':
- if kwargs.get('fatal'):
- raise ExtractorError(
- response['errorDescription'], expected=True)
- return None
- return response['resultObj']
-
- def _download_content_info(self, content_id):
- return self._download_json(
- 'https://account.hotstar.com/AVS/besc', content_id, query={
- 'action': 'GetAggregatedContentDetails',
- 'appVersion': '5.0.40',
- 'channel': 'PCTV',
- 'contentId': content_id,
- })['contentInfo'][0]
+ _AKAMAI_ENCRYPTION_KEY = b'\x05\xfc\x1a\x01\xca\xc9\x4b\xc4\x12\xfc\x53\x12\x07\x75\xf9\xee'
+
+ def _call_api_impl(self, path, video_id, query):
+ st = int(time.time())
+ exp = st + 6000
+ auth = 'st=%d~exp=%d~acl=/*' % (st, exp)
+ auth += '~hmac=' + hmac.new(self._AKAMAI_ENCRYPTION_KEY, auth.encode(), hashlib.sha256).hexdigest()
+ response = self._download_json(
+ 'https://api.hotstar.com/' + path, video_id, headers={
+ 'hotstarauth': auth,
+ 'x-country-code': 'IN',
+ 'x-platform-code': 'JIO',
+ }, query=query)
+ if response['statusCode'] != 'OK':
+ raise ExtractorError(
+ response['body']['message'], expected=True)
+ return response['body']['results']
+
+ def _call_api(self, path, video_id, query_name='contentId'):
+ return self._call_api_impl(path, video_id, {
+ query_name: video_id,
+ 'tas': 10000,
+ })
+
+ def _call_api_v2(self, path, video_id):
+ return self._call_api_impl(
+ '%s/in/contents/%s' % (path, video_id), video_id, {
+ 'desiredConfig': 'encryption:plain;ladder:phone,tv;package:hls,dash',
+ 'client': 'mweb',
+ 'clientVersion': '6.18.0',
+ 'deviceId': compat_str(uuid.uuid4()),
+ 'osName': 'Windows',
+ 'osVersion': '10',
+ })