Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/hotstar.py (Python)

Code before:
    _TYPE = {
        'movies': 'movie',
        'sports': 'match',
        'episode': 'episode',
        'tv': 'episode',
        None: 'content',
    }

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        video_id = mobj.group('id')
        video_type = mobj.group('type')
        cookies = self._get_cookies(url)
        video_type = self._TYPE.get(video_type, video_type)
        video_data = self._call_api(f'o/v1/{video_type}/detail', video_id)['body']['results']['item']
        title = video_data['title']

        if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'):
            raise ExtractorError('This video is DRM protected.', expected=True)
        headers = {'Referer': 'https://www.hotstar.com/in'}
        formats = []
        subs = {}
        geo_restricted = False
        _, urlh = self._download_webpage_handle('https://www.hotstar.com/in', video_id)
        st = urlh.headers.get('x-origin-date')
        # change to v2 in the future
        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
            format_url = url_or_none(playback_set.get('playbackUrl'))
            if not format_url:
                continue
            format_url = re.sub(
                r'(?<=//staragvod)(\d)', r'web\1', format_url)
            tags = str_or_none(playback_set.get('tagsCombination')) or ''
            if tags and 'encryption:plain' not in tags:
                continue
            ext = determine_ext(format_url)
            try:
                if 'package:hls' in tags or ext == 'm3u8':
                    hls_formats, hls_subs = self._extract_m3u8_formats_and_subtitles(
                        format_url, video_id, 'mp4',
                        entry_protocol='m3u8_native',
                        m3u8_id='hls', headers=headers)
                    formats.extend(hls_formats)
                    subs = self._merge_subtitles(subs, hls_subs)
                elif 'package:dash' in tags or ext == 'mpd':
                    dash_formats, dash_subs = self._extract_mpd_formats_and_subtitles(
                        format_url, video_id, mpd_id='dash', headers=headers)
                    formats.extend(dash_formats)

Review comment (suggestion):
```suggestion
        # Required to fix https://github.com/yt-dlp/yt-dlp/issues/396
        st = urlh.headers.get('x-origin-date')
```

Code after:
    _TYPE = {
        'movies': 'movie',
        'sports': 'match',
        'episode': 'episode',
        'tv': 'episode',
        None: 'content',
    }

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        video_id = mobj.group('id')
        video_type = mobj.group('type')
        cookies = self._get_cookies(url)
        video_type = self._TYPE.get(video_type, video_type)
        video_data = self._call_api(f'o/v1/{video_type}/detail', video_id)['body']['results']['item']
        title = video_data['title']

        if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'):
            raise ExtractorError('This video is DRM protected.', expected=True)
        headers = {'Referer': 'https://www.hotstar.com/in'}
        formats = []
        subs = {}
        geo_restricted = False
        _, urlh = self._download_webpage_handle('https://www.hotstar.com/in', video_id)
        # Required to fix https://github.com/yt-dlp/yt-dlp/issues/396
        st = urlh.headers.get('x-origin-date')
        # change to v2 in the future
        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
            format_url = url_or_none(playback_set.get('playbackUrl'))
            if not format_url:
                continue
            format_url = re.sub(
                r'(?<=//staragvod)(\d)', r'web\1', format_url)
            tags = str_or_none(playback_set.get('tagsCombination')) or ''
            if tags and 'encryption:plain' not in tags:
                continue
            ext = determine_ext(format_url)
            try:
                if 'package:hls' in tags or ext == 'm3u8':
                    hls_formats, hls_subs = self._extract_m3u8_formats_and_subtitles(
                        format_url, video_id, 'mp4',
                        entry_protocol='m3u8_native',
                        m3u8_id='hls', headers=headers)
                    formats.extend(hls_formats)
                    subs = self._merge_subtitles(subs, hls_subs)
                elif 'package:dash' in tags or ext == 'mpd':
                    dash_formats, dash_subs = self._extract_mpd_formats_and_subtitles(
                        format_url, video_id, mpd_id='dash', headers=headers)