aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoletdev <coletdjnz@protonmail.com>2022-02-13 21:36:01 +0000
committerGitHub <noreply@github.com>2022-02-13 13:36:01 -0800
commit60f393e48bb694f7efd6edd8f7136885f32d07e7 (patch)
tree809dc006e7db842dad81ef8fe15fc3620fe47bfd
parent88afe05695464e4242933b9474eaf2b15f8b55bb (diff)
downloadhypervideo-pre-60f393e48bb694f7efd6edd8f7136885f32d07e7.tar.lz
hypervideo-pre-60f393e48bb694f7efd6edd8f7136885f32d07e7.tar.xz
hypervideo-pre-60f393e48bb694f7efd6edd8f7136885f32d07e7.zip
[youtube] Ensure subtitle urls are absolute (#2765)
Closes #2755 Authored by: coletdjnz
-rw-r--r--yt_dlp/extractor/youtube.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 5750e75d7..d5f9b6962 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -2245,12 +2245,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
get_all=False, expected_type=compat_str)
if not player_url:
return
- if player_url.startswith('//'):
- player_url = 'https:' + player_url
- elif not re.match(r'https?://', player_url):
- player_url = compat_urlparse.urljoin(
- 'https://www.youtube.com', player_url)
- return player_url
+ return urljoin('https://www.youtube.com', player_url)
def _download_player_url(self, video_id, fatal=False):
res = self._download_webpage(
@@ -2399,11 +2394,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
"""Turn the encrypted n field into a working signature"""
if player_url is None:
raise ExtractorError('Cannot decrypt nsig without player_url')
- if player_url.startswith('//'):
- player_url = 'https:' + player_url
- elif not re.match(r'https?://', player_url):
- player_url = compat_urlparse.urljoin(
- 'https://www.youtube.com', player_url)
+ player_url = urljoin('https://www.youtube.com', player_url)
sig_id = ('nsig_value', s)
if sig_id in self._player_cache:
@@ -3388,7 +3379,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
})
lang_subs.append({
'ext': fmt,
- 'url': update_url_query(base_url, query),
+ 'url': urljoin('https://www.youtube.com', update_url_query(base_url, query)),
'name': sub_name,
})