+class MediaStreamBaseIE(InfoExtractor):
+ _EMBED_BASE_URL = 'https://mdstrm.com/embed'
+ _BASE_URL_RE = r'https?://mdstrm\.com/(?:embed|live-stream)'
+
+ def _extract_mediastream_urls(self, webpage):
+ yield from traverse_obj(list(self._yield_json_ld(webpage, None, fatal=False)), (
+ lambda _, v: v['@type'] == 'VideoObject', ('embedUrl', 'contentUrl'),
+ {lambda x: x if re.match(rf'{self._BASE_URL_RE}/\w+', x) else None}))
+
+ for mobj in re.finditer(r'<script[^>]+>[^>]*playerMdStream\.mdstreamVideo\(\s*[\'"](?P<video_id>\w+)', webpage):
+ yield f'{self._EMBED_BASE_URL}/{mobj.group("video_id")}'
+
+ yield from re.findall(
+ rf'<iframe[^>]+\bsrc="({self._BASE_URL_RE}/\w+)', webpage)
+
+ for mobj in re.finditer(
+ r'''(?x)
+ <(?:div|ps-mediastream)[^>]+
+ (class="[^"]*MediaStreamVideoPlayer)[^"]*"[^>]+
+ data-video-id="(?P<video_id>\w+)"
+ (?:\s*data-video-type="(?P<video_type>[^"]+))?
+ (?:[^>]*>\s*<div[^>]+\1[^"]*"[^>]+data-mediastream=["\'][^>]+
+ https://mdstrm\.com/(?P<live>live-stream))?
+ ''', webpage):
+
+ video_type = 'live-stream' if mobj.group('video_type') == 'live' or mobj.group('live') else 'embed'
+ yield f'https://mdstrm.com/{video_type}/{mobj.group("video_id")}'
+
+
+class MediaStreamIE(MediaStreamBaseIE):
+ _VALID_URL = MediaStreamBaseIE._BASE_URL_RE + r'/(?P<id>\w+)'