Skip to content
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] Fix fallback throttling decryption function regex #934

Merged

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Sep 24, 2022

This PR fixes the regex used to get the throttling decryption function code, utilized as a fallback when the lexer fails to parse the function (this should not happen). To do so, the following changes have been made to the regex:

  • the function name is now quoted, as it may contain special regex symbols, such as dollar;
  • the support of multiple lines in the function has been added;
  • what looks like the end of the function is used as the end of the regex (this part is inspired from yt-dlp's throttling parameter decryption regex);
  • the throttling function body regex has been moved into a private and static constant, allowing easier modifications in the future.

I also made changes on the function used to get the variable representing an array containing the throttling parameter decryption function, which doesn't rely on a specific letter anymore (b), but on alphanumeric characters instead (+$ and _) (this change has been applied on all the regex).

- Quote the function name, as it may contain special regex symbols, such as
  dollar;
- Support multiple lines;
- Use what looks like the end of the function for the end of the regex (this
  part is inspired from yt-dlp throttling parameter decryption regex);
- Move the throttling function body regex into a private and static constant.
…e pattern

Use the same possible characters for variables everywhere, in order to avoid
potential future throttling parameter decryption function name parsing issues
related to the usage of other letter(s) than b.
@AudricV AudricV added bug Issue is related to a bug enhancement New feature or request youtube service, https://www.youtube.com/ labels Sep 24, 2022
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Both the code and your description look good to me :-)

@Stypox Stypox merged commit 5c710da into TeamNewPipe:dev Sep 25, 2022
@Stypox Stypox changed the title [YouTube] Fix throttling decryption function regex [YouTube] Fix fallback throttling decryption function regex Sep 25, 2022
@AudricV AudricV deleted the fix-yt-throttling-decryption-function-regex branch September 25, 2022 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug enhancement New feature or request youtube service, https://www.youtube.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants