-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YouTube] Refactor JavaScript usage and fix extraction of obfuscated signature deobfuscation function #1108
Commits on Sep 21, 2023
-
[YouTube] Add utility class around signatures and fix signature deobf…
…uscation function extraction The goal of this class is to decouple the extraction of signature timestamp and signature deobfuscation function from YoutubeStreamExtractor. The extraction of the signature deobfuscation function has been also adapted to support the latest YouTube player versions. This new class, YoutubeSignatureUtils, doens't store anything temporary such as a copy of the player code, which has to be passed where required. It is not public, as it will be used by a JavaScript player manager class in the future, in order to handle in a better way fetching, caching and resetting cache of the player code.
Configuration menu - View commit details
-
Copy full SHA for 6884d19 - Browse repository at this point
Copy the full SHA 6884d19View commit details -
[YouTube] Refactor JavaScript player management API
This commit is introducing breaking changes. For clients, everything is managed in a new class called YoutubeJavaScriptPlayerManager: - caching JavaScript base player code and its extracted code (functions and variables); - getting player signature timestamp; - getting deobfuscated signatures of streaming URLs; - getting streaming URLs with a throttling parameter deobfuscated, if applicable. The class delegates the extraction parts to external package-private classes: - YoutubeJavaScriptExtractor, to extract and download YouTube's JavaScript base player code: it always already present before and has been edited to mainly remove the previous caching system and made it package-private; - YoutubeSignatureUtils, for player signature timestamp and signature deobfuscation function of streaming URLs, added in a recent commit; - YoutubeThrottlingParameterUtils, which was originally YoutubeThrottlingDecrypter, for throttling parameter of streaming URLs deobfuscation function and checking whether this parameter is in a streaming URL. YoutubeJavaScriptPlayerManager caches and then runs the extracted code if it has been executed successfully. The cache system of throttling parameters deobfuscated values has been kept, its size can be get using the getThrottlingParametersCacheSize method and can be cleared independently using the clearThrottlingParametersCache method. If an exception occurs during the extraction or the parsing of a function property which is not related to JavaScript base player code fetching, it is stored until caches are cleared, making subsequent failing extraction calls of the requested function or property faster and consuming less resources, as the result should be the same until the base player code changes. All caches can be reset using the clearAllCaches method of YoutubeJavaScriptPlayerManager. Classes using JavaScript base player code and utilities directly (in the code and its tests) have been also updated in this commit.
Configuration menu - View commit details
-
Copy full SHA for 7de3753 - Browse repository at this point
Copy the full SHA 7de3753View commit details -
[YouTube] Convert signature timestamp to integer
The signature timestamp is used as a number by HTML5 clients, so it should be used in the same way by the extractor too instead of being a string. As the timestamp doesn't seem to exceed 5 digits, an integer is used to store its value.
Configuration menu - View commit details
-
Copy full SHA for a04bc32 - Browse repository at this point
Copy the full SHA a04bc32View commit details -
[YouTube] Add tests for signature timestamp extraction and signature …
…deobfuscation function extraction and execution
Configuration menu - View commit details
-
Copy full SHA for 1fa85ec - Browse repository at this point
Copy the full SHA 1fa85ecView commit details -
[YouTube] Quote signature deobfuscation function name and add semicol…
…on only where needed
Configuration menu - View commit details
-
Copy full SHA for 588c6a8 - Browse repository at this point
Copy the full SHA 588c6a8View commit details -
[YouTube] Catch any exception when extracting something from JavaScri…
…pt's base player
Configuration menu - View commit details
-
Copy full SHA for 714b141 - Browse repository at this point
Copy the full SHA 714b141View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ed2209 - Browse repository at this point
Copy the full SHA 6ed2209View commit details