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

Code before:
            'ext': 'mp4',
        },
    }]

    @classmethod
    def _extract_embed_urls(cls, url, webpage):
        for mobj in re.finditer(r'<script[^>]+>[^>]*playerMdStream.mdstreamVideo\(\s*[\'"](?P<video_id>\w+)', webpage):
            yield f'https://mdstrm.com/embed/{mobj.group("video_id")}'

        for mobj in re.finditer(r'<iframe[^>]src\s*=\s*"https://mdstrm.com/(?P<video_type>[\w-]+)/(?P<video_id>\w+)',
                                webpage):
            yield f'https://mdstrm.com/{mobj.group("video_type")}/{mobj.group("video_id")}'

        for mobj in re.finditer(
            r'''(?x)
                <(?:div|ps-mediastream)[^>]+
                class\s*=\s*"[^"]*MediaStreamVideoPlayer[^"]*"[^>]+
                data-video-id\s*=\s*"(?P<video_id>\w+)\s*"
                (?:\s*data-video-type\s*=\s*"(?P<video_type>[^"]+))?
                ''', webpage):

            video_type = 'embed'
            if mobj.group('video_type') == 'live':
                video_type = 'live-stream'

            yield f'https://mdstrm.com/{video_type}/{mobj.group("video_id")}'

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

        if 'Debido a tu ubicación no puedes ver el contenido' in webpage:
            self.raise_geo_restricted()

        player_config = self._search_json(r'window.MDSTRM.OPTIONS\s*=', webpage, 'metadata', video_id)

        formats, subtitles = [], {}
        for video_format in player_config['src']:
            if video_format == 'hls':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(player_config['src'][video_format], video_id)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            elif video_format == 'mpd':
                fmts, subs = self._extract_mpd_formats_and_subtitles(player_config['src'][video_format], video_id)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append({
                    'url': player_config['src'][video_format],
                })


Review comment (suggestion):
```suggestion
            video_type = 'live-stream' if mobj.group('video_type') == 'live else 'embed'
            yield f'https://mdstrm.com/{video_type}/{mobj.group("video_id")}'
```

Code after:
            'ext': 'mp4',
        },
    }]

    @classmethod
    def _extract_embed_urls(cls, url, webpage):
        for mobj in re.finditer(r'<script[^>]+>[^>]*playerMdStream.mdstreamVideo\(\s*[\'"](?P<video_id>\w+)', webpage):
            yield f'https://mdstrm.com/embed/{mobj.group("video_id")}'

        yield from re.findall(
            r'<iframe[^>]src\s*=\s*"(https://mdstrm.com/[\w-]+/\w+)', webpage)

        for mobj in re.finditer(
            r'''(?x)
                <(?:div|ps-mediastream)[^>]+
                class\s*=\s*"[^"]*MediaStreamVideoPlayer[^"]*"[^>]+
                data-video-id\s*=\s*"(?P<video_id>\w+)\s*"
                (?:\s*data-video-type\s*=\s*"(?P<video_type>[^"]+))?
                ''', webpage):

            video_type = 'live-stream' if mobj.group('video_type') == 'live' else 'embed'
            yield f'https://mdstrm.com/{video_type}/{mobj.group("video_id")}'

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

        if 'Debido a tu ubicación no puedes ver el contenido' in webpage:
            self.raise_geo_restricted()

        player_config = self._search_json(r'window.MDSTRM.OPTIONS\s*=', webpage, 'metadata', video_id)

        formats, subtitles = [], {}
        for video_format in player_config['src']:
            if video_format == 'hls':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(player_config['src'][video_format], video_id)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            elif video_format == 'mpd':
                fmts, subs = self._extract_mpd_formats_and_subtitles(player_config['src'][video_format], video_id)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append({
                    'url': player_config['src'][video_format],
                })

        return {
            'id': video_id,
            'title': self._og_search_title(webpage) or player_config.get('title'),
            'description': self._og_search_description(webpage),