[Hotstar] Bugfix for a1ddaa899c

Closes #3595
This commit is contained in:
pukkandan 2022-05-16 19:37:05 +05:30
parent b4d3738338
commit 5d5c0f7e99
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39

View file

@ -70,8 +70,7 @@ def _call_api(self, path, video_id, query_name='contentId'):
'x-platform-code': 'PCTV',
})
def _call_api_v2(self, path, video_id, st=None):
cookies = self._get_cookies(self._BASE_URL)
def _call_api_v2(self, path, video_id, st=None, cookies=None):
return self._call_api_impl(
f'{path}/content/{video_id}', video_id, st=st, cookies=cookies, query={
'desired-config': 'audio_channel:stereo|container:fmp4|dynamic_range:hdr|encryption:plain|ladder:tv|package:dash|resolution:fhd|subs-tag:HotstarVIP|video_codec:h265',
@ -160,6 +159,7 @@ def _video_url(cls, video_id, video_type=None, *, slug='ignore_me', root=None):
def _real_extract(self, url):
video_id, video_type = self._match_valid_url(url).group('id', 'type')
video_type = self._TYPE.get(video_type, video_type)
cookies = self._get_cookies(url) # Cookies before any request
video_data = self._call_api(f'o/v1/{video_type}/detail', video_id)['body']['results']['item']
if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'):
@ -173,7 +173,7 @@ def _real_extract(self, url):
headers = {'Referer': f'{self._BASE_URL}/in'}
# change to v2 in the future
playback_sets = self._call_api_v2('play/v1/playback', video_id, st=st)['playBackSets']
playback_sets = self._call_api_v2('play/v1/playback', video_id, st=st, cookies=cookies)['playBackSets']
for playback_set in playback_sets:
if not isinstance(playback_set, dict):
continue