3 from .common
import InfoExtractor
15 class MediaStreamBaseIE(InfoExtractor
):
16 _EMBED_BASE_URL
= 'https://mdstrm.com/embed'
17 _BASE_URL_RE
= r
'https?://mdstrm\.com/(?:embed|live-stream)'
19 def _extract_mediastream_urls(self
, webpage
):
20 yield from traverse_obj(list(self
._yield
_json
_ld
(webpage
, None, default
={})), (
21 lambda _
, v
: v
['@type'] == 'VideoObject', ('embedUrl', 'contentUrl'),
22 {lambda x
: x
if re
.match(rf
'{self._BASE_URL_RE}/\w+', x
) else None}))
24 for mobj
in re
.finditer(r
'<script[^>]+>[^>]*playerMdStream\.mdstreamVideo\(\s*[\'"](?P<video_id>\w+)', webpage):
25 yield f'{self._EMBED_BASE_URL}/{mobj.group("video_id
")}'
27 yield from re.findall(
28 rf'<iframe[^>]+\bsrc="({self
._BASE
_URL
_RE
}/\w
+)', webpage)
30 for mobj in re.finditer(
32 <(?:div|ps-mediastream)[^>]+
33 (class="[^"]*MediaStreamVideoPlayer)[^"]*"[^>]+
34 data-video-id="(?P<video_id>\w+)"
35 (?:\s*data-video-type="(?P<video_type>[^"]+))?
36 (?:[^>]*>\s*<div[^>]+\1[^"]*"[^>]+data-mediastream=["\'][^>]+
37 https://mdstrm\.com/(?P<live>live-stream))?
40 video_type = 'live
-stream
' if mobj.group('video_type
') == 'live
' or mobj.group('live
') else 'embed
'
41 yield f'https
://mdstrm
.com
/{video_type}
/{mobj
.group("video_id")}'
44 class MediaStreamIE(MediaStreamBaseIE):
45 _VALID_URL = MediaStreamBaseIE._BASE_URL_RE + r'/(?P
<id>\w
+)'
48 'url
': 'https
://mdstrm
.com
/embed
/6318e3f1d1d316083ae48831
',
49 'md5
': '97b4f2634b8e8612cc574dfcd504df05
',
51 'id': '6318e3f1d1d316083ae48831
',
52 'title
': 'Video
: Así fue el despido de Thomas Tuchel
del Chelsea
',
53 'description
': 'md5
:358ce1e1396010d50a1ece1be3633c95
',
54 'thumbnail
': r're
:^https?
://[^?
#]+6318e3f1d1d316083ae48831',
57 'params': {'skip_download': 'm3u8'},
61 'url': 'https://www.multimedios.com/video/costa-rica-tv-en-vivo/v2616',
63 'id': '5a7b1e63a8da282c34d65445',
64 'title': 're:mmtv-costarica',
65 'description': 'mmtv-costarica',
66 'thumbnail': 're:^https?://[^?#]+5a7b1e63a8da282c34d65445',
68 'live_status': 'is_live',
70 'params': {'skip_download': 'Livestream'},
72 'url': 'https://www.multimedios.com/television/clases-de-llaves-y-castigos-quien-sabe-mas',
73 'md5': 'de31f0b1ecc321fb35bf22d58734ea40',
75 'id': '63731bab8ec9b308a2c9ed28',
76 'title': 'Clases de llaves y castigos ¿Quién sabe más?',
77 'description': 'md5:1b49aa1ee5a4b32fbd66104b2d629e9d',
78 'thumbnail': 're:^https?://[^?#]+63731bab8ec9b308a2c9ed28',
81 'params': {'skip_download': 'm3u8'},
83 'url': 'https://www.americatv.com.pe/videos/esto-es-guerra/facundo-gonzalez-sufrio-fuerte-golpe-durante-competencia-frente-hugo-garcia-eeg-noticia-139120',
85 'id': '63756df1c638b008a5659dec',
86 'title': 'Facundo González sufrió fuerte golpe durante competencia frente a Hugo García en EEG',
87 'description': 'md5:9490c034264afd756eef7b2c3adee69e',
88 'thumbnail': 're:^https?://[^?#]+63756df1c638b008a5659dec',
91 'params': {'skip_download': 'm3u8'},
93 'url': 'https://www.americatv.com.pe/videos/al-fondo-hay-sitio/nuevas-lomas-town-bernardo-mata-se-enfrento-sujeto-luchar-amor-macarena-noticia-139083',
95 'id': '637307669609130f74cd3a6e',
96 'title': 'Las Nuevas Lomas Town: Bernardo De La Mata se enfrentó a sujeto para luchar por el amor de Macarena',
97 'description': 'md5:60d71772f1e1496923539ae58aa17124',
98 'thumbnail': 're:^https?://[^?#]+637307669609130f74cd3a6e',
101 'params': {'skip_download': 'm3u8'},
104 def _extract_from_webpage(self
, url
, webpage
):
105 for embed_url
in self
._extract
_mediastream
_urls
(webpage
):
106 yield self
.url_result(embed_url
, MediaStreamIE
, None)
108 def _real_extract(self
, url
):
109 video_id
= self
._match
_id
(url
)
110 webpage
= self
._download
_webpage
(url
, video_id
)
113 'Debido a tu ubicación no puedes ver el contenido',
114 'You are not allowed to watch this video: Geo Fencing Restriction',
115 'Este contenido no está disponible en tu zona geográfica.',
116 'El contenido sólo está disponible dentro de',
118 if message
in webpage
:
119 self
.raise_geo_restricted()
121 player_config
= self
._search
_json
(r
'window\.MDSTRM\.OPTIONS\s*=', webpage
, 'metadata', video_id
)
123 formats
, subtitles
= [], {}
124 for video_format
in player_config
['src']:
125 if video_format
== 'hls':
128 'access_token': traverse_obj(parse_qs(url
), ('access_token', 0)),
130 for name
, key
in (('MDSTRMUID', 'uid'), ('MDSTRMSID', 'sid'), ('MDSTRMPID', 'pid'), ('VERSION', 'av')):
131 params
[key
] = self
._search
_regex
(
132 rf
'window\.{name}\s*=\s*["\']([^"\']+)["\'];', webpage
, key
, default
=None)
134 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
135 update_url_query(player_config
['src'][video_format
], filter_dict(params
)), video_id
)
137 self
._merge
_subtitles
(subs
, target
=subtitles
)
138 elif video_format
== 'mpd':
139 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(player_config
['src'][video_format
], video_id
)
141 self
._merge
_subtitles
(subs
, target
=subtitles
)
144 'url': player_config
['src'][video_format
],
149 'title': self
._og
_search
_title
(webpage
) or player_config
.get('title'),
150 'description': self
._og
_search
_description
(webpage
),
152 'subtitles': subtitles
,
153 'is_live': player_config
.get('type') == 'live',
154 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
158 class WinSportsVideoIE(MediaStreamBaseIE
):
159 _VALID_URL
= r
'https?://www\.winsports\.co/videos/(?P<id>[\w-]+)'
162 'url': 'https://www.winsports.co/videos/siempre-castellanos-gran-atajada-del-portero-cardenal-para-evitar-la-caida-de-su-arco-60536',
164 'id': '62dc8357162c4b0821fcfb3c',
165 'display_id': 'siempre-castellanos-gran-atajada-del-portero-cardenal-para-evitar-la-caida-de-su-arco-60536',
166 'title': '¡Siempre Castellanos! Gran atajada del portero \'cardenal\' para evitar la caída de su arco',
167 'description': 'md5:eb811b2b2882bdc59431732c06b905f2',
168 'thumbnail': r
're:^https?://[^?#]+62dc8357162c4b0821fcfb3c',
171 'params': {'skip_download': 'm3u8'},
173 'url': 'https://www.winsports.co/videos/observa-aqui-los-goles-del-empate-entre-tolima-y-nacional-60548',
175 'id': '62dcb875ef12a5526790b552',
176 'display_id': 'observa-aqui-los-goles-del-empate-entre-tolima-y-nacional-60548',
177 'title': 'Observa aquí los goles del empate entre Tolima y Nacional',
178 'description': 'md5:b19402ba6e46558b93fd24b873eea9c9',
179 'thumbnail': r
're:^https?://[^?#]+62dcb875ef12a5526790b552',
182 'params': {'skip_download': 'm3u8'},
184 'url': 'https://www.winsports.co/videos/equidad-vuelve-defender-su-arco-de-remates-de-junior',
186 'id': '63fa7eca72f1741ad3a4d515',
187 'display_id': 'equidad-vuelve-defender-su-arco-de-remates-de-junior',
188 'title': '⚽ Equidad vuelve a defender su arco de remates de Junior',
189 'description': 'Remate de Sierra',
190 'thumbnail': r
're:^https?://[^?#]+63fa7eca72f1741ad3a4d515',
193 'params': {'skip_download': 'm3u8'},
195 'url': 'https://www.winsports.co/videos/bucaramanga-se-quedo-con-el-grito-de-gol-en-la-garganta',
197 'id': '6402adb62bbf3b18d454e1b0',
198 'display_id': 'bucaramanga-se-quedo-con-el-grito-de-gol-en-la-garganta',
199 'title': '⚽Bucaramanga se quedó con el grito de gol en la garganta',
200 'description': 'Gol anulado Bucaramanga',
201 'thumbnail': r
're:^https?://[^?#]+6402adb62bbf3b18d454e1b0',
204 'params': {'skip_download': 'm3u8'},
207 def _real_extract(self
, url
):
208 display_id
= self
._match
_id
(url
)
209 webpage
= self
._download
_webpage
(url
, display_id
)
210 data
= self
._search
_json
(
211 r
'<script\s*[^>]+data-drupal-selector="drupal-settings-json">', webpage
, 'data', display_id
)
213 mediastream_url
= urljoin(f
'{self._EMBED_BASE_URL}/', (
215 (('settings', 'mediastream_formatter', ..., 'mediastream_id'), 'url'), {str}
), get_all
=False)
216 or next(self
._extract
_mediastream
_urls
(webpage
), None)))
218 if not mediastream_url
:
219 self
.raise_no_formats('No MediaStream embed found in webpage')
221 title
= clean_html(remove_end(
222 self
._search
_json
_ld
(webpage
, display_id
, expected_type
='VideoObject', default
={}).get('title')
223 or self
._og
_search
_title
(webpage
), '| Win Sports'))
225 return self
.url_result(
226 mediastream_url
, MediaStreamIE
, display_id
, url_transparent
=True, display_id
=display_id
, video_title
=title
)