1
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-05-18 17:25:42 -05:00

[ie/youtube] Detect player JS variants for any locale (#13003)

Authored by: bashonly
This commit is contained in:
bashonly 2025-04-26 17:08:34 -05:00 committed by GitHub
parent 26feac3dd1
commit c2d6659d10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1982,7 +1982,9 @@ def _download_player_url(self, video_id, fatal=False):
def _player_js_cache_key(self, player_url):
player_id = self._extract_player_info(player_url)
player_path = remove_start(urllib.parse.urlparse(player_url).path, f'/s/player/{player_id}/')
variant = self._INVERSE_PLAYER_JS_VARIANT_MAP.get(player_path)
variant = self._INVERSE_PLAYER_JS_VARIANT_MAP.get(player_path) or next((
v for k, v in self._INVERSE_PLAYER_JS_VARIANT_MAP.items()
if re.fullmatch(re.escape(k).replace('en_US', r'[a-zA-Z0-9_]+'), player_path)), None)
if not variant:
self.write_debug(
f'Unable to determine player JS variant\n'