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

Code before:
        'Origin': _BASE_URL,
        'Referer': f'{_BASE_URL}/',
    }
    _TESTS = [{
        'url': 'https://mir24.tv/news/16635210/dni-kultury-rossii-otkrylis-v-uzbekistane.-na-prazdnichnom-koncerte-vystupili-zvezdy-rossijskoj-estrada',
        'info_dict': {
            'id': '16635210',
            'title': 'Дни культуры России открылись в Узбекистане. На праздничном концерте выступили звезды российской эстрады',
            'ext': 'mp4',
        },
        'params': {'skip_download': True},
    }]
    _IMPERSONATE_TARGET = True

    def _real_extract(self, url):
        video_id = self._match_id(url)
        url, smuggled_data = unsmuggle_url(url, {})
        impersonate = self._configuration_arg('impersonate', [''])
        try:
            webpage = self._request_webpage(url, video_id, headers=filter_dict({
                'Accept-Encoding': 'identity',
                'Referer': smuggled_data.get('referer'),
            }), impersonate=impersonate)
        except ExtractorError:
            raise ExtractorError('try again with  --extractor-args "generic:impersonate"', expected=True)
        webpage = webpage.read().decode()

        iframe_url = self._search_regex(
            r'<iframe[^>]+src=["\'](https?://mir24\.tv/players/[^"\']+)',
            webpage, 'iframe URL')

        parsed_url = urllib.parse.urlparse(iframe_url)
        query_params = urllib.parse.parse_qs(parsed_url.query)

        m3u8_url_encoded = query_params.get('source', [''])[0]
        if not m3u8_url_encoded:
            raise self.raise_no_formats('Не удалось найти параметр source в iframe')

        m3u8_url = urllib.parse.unquote(m3u8_url_encoded).replace('///', '//')

        title = self._og_search_title(webpage, default=None) or self._html_search_meta(
            'og:title', webpage, 'title', default=video_id)

        return {
            'id': video_id,
            'title': title,
            'formats': self._extract_m3u8_formats(m3u8_url, video_id, 'mp4'),
        }


Review comment (suggestion):
Let's keep it simple
```suggestion
        webpage = self._download_webpage(url, video_id, impersonate=True)
```

Code after:
            'title': 'Дни культуры России открылись в Узбекистане. На праздничном концерте выступили звезды российской эстрады',
            'ext': 'mp4',
            'thumbnail': r're:https://images\.mir24\.tv/.+\.jpg',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id, impersonate=True)

        iframe_url = self._search_regex(
            r'<iframe\b[^>]+\bsrc=["\'](https?://mir24\.tv/players/[^"\']+)',
            webpage, 'iframe URL')

        m3u8_url = traverse_obj(iframe_url, (
            {parse_qs}, 'source', -1, {self._proto_relative_url}, {url_or_none}, {require('m3u8 URL')}))
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, 'mp4', m3u8_id='hls')

        return {
            'id': video_id,
            'title': self._og_search_title(webpage, default=None) or self._html_extract_title(webpage),
            'thumbnail': self._og_search_thumbnail(webpage, default=None),
            'formats': formats,
            'subtitles': subtitles,
        }