Skip to content

Commit

Permalink
[hotstar] pass Referer header to format requests(closes #22836)
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine authored and meunierd committed Feb 13, 2020
1 parent e6c71be commit a066751
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions youtube_dl/extractor/hotstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def _real_extract(self, url):
if video_data.get('drmProtected'):
raise ExtractorError('This video is DRM protected.', expected=True)

headers = {'Referer': url}
formats = []
geo_restricted = False
playback_sets = self._call_api_v2('h/v2/play', video_id)['playBackSets']
Expand All @@ -137,10 +138,11 @@ def _real_extract(self, url):
if 'package:hls' in tags or ext == 'm3u8':
formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls'))
entry_protocol='m3u8_native',
m3u8_id='hls', headers=headers))
elif 'package:dash' in tags or ext == 'mpd':
formats.extend(self._extract_mpd_formats(
format_url, video_id, mpd_id='dash'))
format_url, video_id, mpd_id='dash', headers=headers))
elif ext == 'f4m':
# produce broken files
pass
Expand All @@ -158,6 +160,9 @@ def _real_extract(self, url):
self.raise_geo_restricted(countries=['IN'])
self._sort_formats(formats)

for f in formats:
f.setdefault('http_headers', {}).update(headers)

return {
'id': video_id,
'title': title,
Expand Down

0 comments on commit a066751

Please sign in to comment.