Skip to content

Commit

Permalink
Correct primary video server url anxdpanic#1040
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Dec 29, 2024
1 parent 2d5539e commit bc2cfdf
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions resources/lib/youtube_plugin/youtube/helper/stream_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,8 @@ def _process_url_params(self, url, digits_re=re_compile(r'\d+')):
parts = urlsplit(url)
params = parse_qs(parts.query)
new_params = {}
update_url = None
primary_update_url = None
secondary_update_url = None

if self._calculate_n and 'n' in params:
if self._player_js is None:
Expand All @@ -1372,9 +1373,15 @@ def _process_url_params(self, url, digits_re=re_compile(r'\d+')):
fvip = params['fvip'][0]
primary, _, secondary = params['mn'][0].partition(',')
prefix, separator, server = parts.netloc.partition('---')
new_prefix = digits_re.sub(fvip, prefix)
if new_prefix != prefix:
primary_update_url = separator.join((
new_prefix,
server,
))
if primary and secondary:
update_url = separator.join((
digits_re.sub(fvip, prefix),
secondary_update_url = separator.join((
new_prefix,
server.replace(primary, secondary),
))

Expand All @@ -1390,15 +1397,19 @@ def _process_url_params(self, url, digits_re=re_compile(r'\d+')):
if new_params:
params.update(new_params)
query_str = urlencode(params, doseq=True)
elif update_url:
elif primary_update_url or secondary_update_url:
query_str = parts.query
else:
return url, None

parts._replace(query=query_str)
return (
parts._replace(netloc=primary_update_url).geturl()
if primary_update_url else
parts.geturl(),
parts._replace(netloc=update_url).geturl() if update_url else None,
parts._replace(netloc=secondary_update_url).geturl()
if secondary_update_url else
None,
)

def _get_error_details(self, playability_status, details=None):
Expand Down

0 comments on commit bc2cfdf

Please sign in to comment.