mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-08 16:31:26 +01:00
Compare commits
3 Commits
2fecc5c4f3
...
f0208dc966
Author | SHA1 | Date | |
---|---|---|---|
|
f0208dc966 | ||
|
afb1b5afa2 | ||
|
93a59a7ac2 |
|
@ -3,13 +3,14 @@ import re
|
|||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
clean_html,
|
||||
filter_dict,
|
||||
parse_qs,
|
||||
remove_end,
|
||||
traverse_obj,
|
||||
update_url_query,
|
||||
urljoin,
|
||||
)
|
||||
|
||||
from urllib.parse import urlparse, urlencode, parse_qs
|
||||
|
||||
|
||||
class MediaStreamBaseIE(InfoExtractor):
|
||||
_EMBED_BASE_URL = 'https://mdstrm.com/embed'
|
||||
|
@ -122,36 +123,16 @@ class MediaStreamIE(MediaStreamBaseIE):
|
|||
formats, subtitles = [], {}
|
||||
for video_format in player_config['src']:
|
||||
if video_format == 'hls':
|
||||
src = player_config['src'][video_format]
|
||||
params = {}
|
||||
params = {
|
||||
'at': 'web-app',
|
||||
'access_token': traverse_obj(parse_qs(url), ('access_token', 0)),
|
||||
}
|
||||
for name, key in (('MDSTRMUID', 'uid'), ('MDSTRMSID', 'sid'), ('MDSTRMPID', 'pid'), ('VERSION', 'av')):
|
||||
params[key] = self._search_regex(
|
||||
rf'window\.{name}\s*=\s*["\']([^"\']+)["\'];', webpage, key, default=None)
|
||||
|
||||
uid = self._search_regex(r'window\.MDSTRMUID\s*=\s*["\']([^"\']+)["\'];', webpage, 'uid', fatal=False, default=None)
|
||||
if uid:
|
||||
params['uid'] = uid
|
||||
|
||||
sid = self._search_regex(r'window\.MDSTRMSID\s*=\s*["\']([^"\']+)["\'];', webpage, 'sid', fatal=False, default=None)
|
||||
if sid:
|
||||
params['sid'] = sid
|
||||
|
||||
pid = self._search_regex(r'window\.MDSTRMPID\s*=\s*["\']([^"\']+)["\'];', webpage, 'pid', fatal=False, default=None)
|
||||
if pid:
|
||||
params['pid'] = pid
|
||||
|
||||
version = self._search_regex(r'window\.VERSION\s*=\s*["\']([^"\']+)["\'];', webpage, 'version', fatal=False, default=None)
|
||||
if version:
|
||||
params['at'] = 'web-app'
|
||||
params['av'] = version
|
||||
|
||||
parsed = urlparse(url)
|
||||
if len(parsed.query) > 0:
|
||||
qs = parse_qs(parsed.query)
|
||||
if 'access_token' in qs and len(qs['access_token']) > 0:
|
||||
params['access_token'] = qs['access_token'][0]
|
||||
|
||||
if len(params):
|
||||
src = f'{src}?{urlencode(params)}'
|
||||
|
||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(src, video_id)
|
||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||
update_url_query(player_config['src'][video_format], filter_dict(params)), video_id)
|
||||
formats.extend(fmts)
|
||||
self._merge_subtitles(subs, target=subtitles)
|
||||
elif video_format == 'mpd':
|
||||
|
|
Loading…
Reference in New Issue
Block a user