3 from .common
import InfoExtractor
12 class MediaStreamBaseIE(InfoExtractor
):
13 _EMBED_BASE_URL
= 'https://mdstrm.com/embed'
14 _BASE_URL_RE
= r
'https?://mdstrm\.com/(?:embed|live-stream)'
16 def _extract_mediastream_urls(self
, webpage
):
17 yield from traverse_obj(list(self
._yield
_json
_ld
(webpage
, None)), (
18 lambda _
, v
: v
['@type'] == 'VideoObject', ('embedUrl', 'contentUrl'),
19 {lambda x
: x
if re
.match(rf
'{self._BASE_URL_RE}/\w+', x
) else None}))
21 for mobj
in re
.finditer(r
'<script[^>]+>[^>]*playerMdStream\.mdstreamVideo\(\s*[\'"](?P<video_id>\w+)', webpage):
22 yield f'{self._EMBED_BASE_URL}/{mobj.group("video_id
")}'
24 yield from re.findall(
25 rf'<iframe[^>]+\bsrc="({self
._BASE
_URL
_RE
}/\w
+)', webpage)
27 for mobj in re.finditer(
29 <(?:div|ps-mediastream)[^>]+
30 (class="[^"]*MediaStreamVideoPlayer)[^"]*"[^>]+
31 data-video-id="(?P<video_id>\w+)"
32 (?:\s*data-video-type="(?P<video_type>[^"]+))?
33 (?:[^>]*>\s*<div[^>]+\1[^"]*"[^>]+data-mediastream=["\'][^>]+
34 https://mdstrm\.com/(?P<live>live-stream))?
37 video_type = 'live
-stream
' if mobj.group('video_type
') == 'live
' or mobj.group('live
') else 'embed
'
38 yield f'https
://mdstrm
.com
/{video_type}
/{mobj
.group("video_id")}'
41 class MediaStreamIE(MediaStreamBaseIE):
42 _VALID_URL = MediaStreamBaseIE._BASE_URL_RE + r'/(?P
<id>\w
+)'
45 'url
': 'https
://mdstrm
.com
/embed
/6318e3f1d1d316083ae48831
',
46 'md5
': '97b4f2634b8e8612cc574dfcd504df05
',
48 'id': '6318e3f1d1d316083ae48831
',
49 'title
': 'Video
: Así fue el despido de Thomas Tuchel
del Chelsea
',
50 'description
': 'md5
:358ce1e1396010d50a1ece1be3633c95
',
51 'thumbnail
': r're
:^https?
://[^?
#]+6318e3f1d1d316083ae48831',
54 'params': {'skip_download': 'm3u8'},
58 'url': 'https://www.multimedios.com/video/costa-rica-tv-en-vivo/v2616',
60 'id': '5a7b1e63a8da282c34d65445',
61 'title': 're:mmtv-costarica',
62 'description': 'mmtv-costarica',
63 'thumbnail': 're:^https?://[^?#]+5a7b1e63a8da282c34d65445',
65 'live_status': 'is_live',
67 'params': {'skip_download': 'Livestream'},
69 'url': 'https://www.multimedios.com/television/clases-de-llaves-y-castigos-quien-sabe-mas',
70 'md5': 'de31f0b1ecc321fb35bf22d58734ea40',
72 'id': '63731bab8ec9b308a2c9ed28',
73 'title': 'Clases de llaves y castigos ¿Quién sabe más?',
74 'description': 'md5:1b49aa1ee5a4b32fbd66104b2d629e9d',
75 'thumbnail': 're:^https?://[^?#]+63731bab8ec9b308a2c9ed28',
78 'params': {'skip_download': 'm3u8'},
80 'url': 'https://www.americatv.com.pe/videos/esto-es-guerra/facundo-gonzalez-sufrio-fuerte-golpe-durante-competencia-frente-hugo-garcia-eeg-noticia-139120',
82 'id': '63756df1c638b008a5659dec',
83 'title': 'Facundo González sufrió fuerte golpe durante competencia frente a Hugo García en EEG',
84 'description': 'md5:9490c034264afd756eef7b2c3adee69e',
85 'thumbnail': 're:^https?://[^?#]+63756df1c638b008a5659dec',
88 'params': {'skip_download': 'm3u8'},
90 'url': 'https://www.americatv.com.pe/videos/al-fondo-hay-sitio/nuevas-lomas-town-bernardo-mata-se-enfrento-sujeto-luchar-amor-macarena-noticia-139083',
92 'id': '637307669609130f74cd3a6e',
93 'title': 'Las Nuevas Lomas Town: Bernardo De La Mata se enfrentó a sujeto para luchar por el amor de Macarena',
94 'description': 'md5:60d71772f1e1496923539ae58aa17124',
95 'thumbnail': 're:^https?://[^?#]+637307669609130f74cd3a6e',
98 'params': {'skip_download': 'm3u8'},
101 def _extract_from_webpage(self
, url
, webpage
):
102 for embed_url
in self
._extract
_mediastream
_urls
(webpage
):
103 yield self
.url_result(embed_url
, MediaStreamIE
, None)
105 def _real_extract(self
, url
):
106 video_id
= self
._match
_id
(url
)
107 webpage
= self
._download
_webpage
(url
, video_id
)
109 if 'Debido a tu ubicación no puedes ver el contenido' in webpage
:
110 self
.raise_geo_restricted()
112 player_config
= self
._search
_json
(r
'window\.MDSTRM\.OPTIONS\s*=', webpage
, 'metadata', video_id
)
114 formats
, subtitles
= [], {}
115 for video_format
in player_config
['src']:
116 if video_format
== 'hls':
117 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(player_config
['src'][video_format
], video_id
)
119 self
._merge
_subtitles
(subs
, target
=subtitles
)
120 elif video_format
== 'mpd':
121 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(player_config
['src'][video_format
], video_id
)
123 self
._merge
_subtitles
(subs
, target
=subtitles
)
126 'url': player_config
['src'][video_format
],
131 'title': self
._og
_search
_title
(webpage
) or player_config
.get('title'),
132 'description': self
._og
_search
_description
(webpage
),
134 'subtitles': subtitles
,
135 'is_live': player_config
.get('type') == 'live',
136 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
140 class WinSportsVideoIE(MediaStreamBaseIE
):
141 _VALID_URL
= r
'https?://www\.winsports\.co/videos/(?P<id>[\w-]+)'
144 'url': 'https://www.winsports.co/videos/siempre-castellanos-gran-atajada-del-portero-cardenal-para-evitar-la-caida-de-su-arco-60536',
146 'id': '62dc8357162c4b0821fcfb3c',
147 'display_id': 'siempre-castellanos-gran-atajada-del-portero-cardenal-para-evitar-la-caida-de-su-arco-60536',
148 'title': '¡Siempre Castellanos! Gran atajada del portero \'cardenal\' para evitar la caída de su arco',
149 'description': 'md5:eb811b2b2882bdc59431732c06b905f2',
150 'thumbnail': r
're:^https?://[^?#]+62dc8357162c4b0821fcfb3c',
153 'params': {'skip_download': 'm3u8'},
155 'url': 'https://www.winsports.co/videos/observa-aqui-los-goles-del-empate-entre-tolima-y-nacional-60548',
157 'id': '62dcb875ef12a5526790b552',
158 'display_id': 'observa-aqui-los-goles-del-empate-entre-tolima-y-nacional-60548',
159 'title': 'Observa aquí los goles del empate entre Tolima y Nacional',
160 'description': 'md5:b19402ba6e46558b93fd24b873eea9c9',
161 'thumbnail': r
're:^https?://[^?#]+62dcb875ef12a5526790b552',
164 'params': {'skip_download': 'm3u8'},
166 'url': 'https://www.winsports.co/videos/equidad-vuelve-defender-su-arco-de-remates-de-junior',
168 'id': '63fa7eca72f1741ad3a4d515',
169 'display_id': 'equidad-vuelve-defender-su-arco-de-remates-de-junior',
170 'title': '⚽ Equidad vuelve a defender su arco de remates de Junior',
171 'description': 'Remate de Sierra',
172 'thumbnail': r
're:^https?://[^?#]+63fa7eca72f1741ad3a4d515',
175 'params': {'skip_download': 'm3u8'},
177 'url': 'https://www.winsports.co/videos/bucaramanga-se-quedo-con-el-grito-de-gol-en-la-garganta',
179 'id': '6402adb62bbf3b18d454e1b0',
180 'display_id': 'bucaramanga-se-quedo-con-el-grito-de-gol-en-la-garganta',
181 'title': '⚽Bucaramanga se quedó con el grito de gol en la garganta',
182 'description': 'Gol anulado Bucaramanga',
183 'thumbnail': r
're:^https?://[^?#]+6402adb62bbf3b18d454e1b0',
186 'params': {'skip_download': 'm3u8'},
189 def _real_extract(self
, url
):
190 display_id
= self
._match
_id
(url
)
191 webpage
= self
._download
_webpage
(url
, display_id
)
192 data
= self
._search
_json
(
193 r
'<script\s*[^>]+data-drupal-selector="drupal-settings-json">', webpage
, 'data', display_id
)
195 mediastream_url
= urljoin(f
'{self._EMBED_BASE_URL}/', (
197 (('settings', 'mediastream_formatter', ..., 'mediastream_id'), 'url'), {str}
), get_all
=False)
198 or next(self
._extract
_mediastream
_urls
(webpage
), None)))
200 if not mediastream_url
:
201 self
.raise_no_formats('No MediaStream embed found in webpage')
203 title
= clean_html(remove_end(
204 self
._search
_json
_ld
(webpage
, display_id
, expected_type
='VideoObject', default
={}).get('title')
205 or self
._og
_search
_title
(webpage
), '| Win Sports'))
207 return self
.url_result(
208 mediastream_url
, MediaStreamIE
, display_id
, url_transparent
=True, display_id
=display_id
, video_title
=title
)