[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 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
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'