diff options
author | dirkf <fieldhouse@gmx.net> | 2025-03-21 16:26:25 +0000 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2025-03-21 16:26:25 +0000 |
commit | da7223d4aa42ff9fc680b0951d043dd03cec2d30 (patch) | |
tree | a974845aae4fa84ba37697ac65519156999a92a8 | |
parent | 37c2440d6a9a2a7226f6548ebc2b59160408e79a (diff) |
[YouTube] Improve support for tce-style player JS
* improve extraction of global "useful data" Array from player JS
* also handle tv-player and add tests: thx seproDev (yt-dlp/yt-dlp#12684)
Co-Authored-By: sepro <sepro@sepr0.com>
-rw-r--r-- | test/test_youtube_signature.py | 28 | ||||
-rw-r--r-- | youtube_dl/extractor/youtube.py | 4 |
2 files changed, 28 insertions, 4 deletions
diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py index 166614e62..7726b1943 100644 --- a/test/test_youtube_signature.py +++ b/test/test_youtube_signature.py @@ -232,8 +232,32 @@ _NSIG_TESTS = [ 'W9HJZKktxuYoDTqW', 'jHbbkcaxm54', ), ( - 'https://www.youtube.com/s/player/91201489/player_ias_tce.vflset/en_US/base.js', - 'W9HJZKktxuYoDTqW', 'U48vOZHaeYS6vO', + 'https://www.youtube.com/s/player/643afba4/player_ias.vflset/en_US/base.js', + 'W9HJZKktxuYoDTqW', 'larxUlagTRAcSw', + ), + ( + 'https://www.youtube.com/s/player/e7567ecf/player_ias_tce.vflset/en_US/base.js', + 'Sy4aDGc0VpYRR9ew_', '5UPOT1VhoZxNLQ', + ), + ( + 'https://www.youtube.com/s/player/d50f54ef/player_ias_tce.vflset/en_US/base.js', + 'Ha7507LzRmH3Utygtj', 'XFTb2HoeOE5MHg', + ), + ( + 'https://www.youtube.com/s/player/074a8365/player_ias_tce.vflset/en_US/base.js', + 'Ha7507LzRmH3Utygtj', 'ufTsrE0IVYrkl8v', + ), + ( + 'https://www.youtube.com/s/player/643afba4/player_ias.vflset/en_US/base.js', + 'N5uAlLqm0eg1GyHO', 'dCBQOejdq5s-ww', + ), + ( + 'https://www.youtube.com/s/player/69f581a5/tv-player-ias.vflset/tv-player-ias.js', + '-qIP447rVlTTwaZjY', 'KNcGOksBAvwqQg', + ), + ( + 'https://www.youtube.com/s/player/643afba4/tv-player-ias.vflset/tv-player-ias.js', + 'ir9-V6cdbCiyKxhr', '2PL7ZDYAALMfmA', ), ] diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index e58b48abc..415354811 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -692,7 +692,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'invidious': '|'.join(_INVIDIOUS_SITES), } _PLAYER_INFO_RE = ( - r'/s/player/(?P<id>[a-zA-Z0-9_-]{8,})/player', + r'/s/player/(?P<id>[a-zA-Z0-9_-]{8,})//(?:tv-)?player', r'/(?P<id>[a-zA-Z0-9_-]{8,})/player(?:_ias\.vflset(?:/[a-zA-Z]{2,3}_[a-zA-Z]{2,3})?|-plasma-ias-(?:phone|tablet)-[a-z]{2}_[A-Z]{2}\.vflset)/base\.js$', r'\b(?P<id>vfl[a-zA-Z0-9_-]+)\b.*?\.js$', ) @@ -1857,7 +1857,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): def _extract_n_function_code_jsi(self, video_id, jsi, player_id=None): var_ay = self._search_regex( - r'(?:[;\s]|^)\s*(var\s*[\w$]+\s*=\s*"[^"]+"\s*\.\s*split\("\{"\))(?=\s*[,;])', + r'(?:[;\s]|^)\s*(var\s*[\w$]+\s*=\s*"(?:\\"|[^"])+"\s*\.\s*split\("\W+"\))(?=\s*[,;])', jsi.code, 'useful values', default='') func_name = self._extract_n_function_name(jsi.code) |