Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed mediastream when hls uses extra arguments #8657

Merged
merged 6 commits into from Dec 6, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 28 additions & 2 deletions yt_dlp/extractor/mediastream.py
Expand Up @@ -6,6 +6,8 @@
remove_end,
traverse_obj,
urljoin,
parse_qs,
update_url_query
pukkandan marked this conversation as resolved.
Show resolved Hide resolved
)


Expand Down Expand Up @@ -108,7 +110,9 @@ def _real_extract(self, url):

for message in [
'Debido a tu ubicación no puedes ver el contenido',
'You are not allowed to watch this video: Geo Fencing Restriction'
'You are not allowed to watch this video: Geo Fencing Restriction',
'Este contenido no está disponible en tu zona geográfica.',
'El contenido sólo está disponible dentro de',
]:
if message in webpage:
self.raise_geo_restricted()
Expand All @@ -118,7 +122,29 @@ def _real_extract(self, url):
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)
params = {}

uid = self._search_regex(r'window\.MDSTRMUID\s*=\s*["\']([^"\']+)["\'];', webpage, 'uid', default=None)
if uid:
params['uid'] = uid

sid = self._search_regex(r'window\.MDSTRMSID\s*=\s*["\']([^"\']+)["\'];', webpage, 'sid', default=None)
if sid:
params['sid'] = sid

pid = self._search_regex(r'window\.MDSTRMPID\s*=\s*["\']([^"\']+)["\'];', webpage, 'pid', default=None)
if pid:
params['pid'] = pid

version = self._search_regex(r'window\.VERSION\s*=\s*["\']([^"\']+)["\'];', webpage, 'version', default=None)
if version:
params['at'] = 'web-app'
params['av'] = version
NickCis marked this conversation as resolved.
Show resolved Hide resolved

if access_token := parse_qs(url).get('access_token', [None])[0]:
params['access_token'] = access_token

fmts, subs = self._extract_m3u8_formats_and_subtitles(update_url_query(player_config['src'][video_format], params), video_id)
NickCis marked this conversation as resolved.
Show resolved Hide resolved
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
elif video_format == 'mpd':
Expand Down