-
Notifications
You must be signed in to change notification settings - Fork 10k
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
[jsinterp] Overhaul JSInterp to handle new YT players 4c3f79c5, 324f67b9 #31170
Conversation
* back-port from yt-dlp 8f53dc4, thanks pukkandan * also support void, improve <</>> precedence, improve expressions in comma-list * add more tests
31421df
to
6bfc29e
Compare
* https://github.com/ytdl-org/youtube-dl: [jsinterp] Overhaul JSInterp to handle new YT players 4c3f79c5, 324f67b9 (ytdl-org#31170)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
if len(sub_expressions) > 1: | ||
for sub_expr in sub_expressions: | ||
ret, should_abort = self.interpret_statement(sub_expr, local_vars, allow_recursion) | ||
if should_abort: | ||
return ret, True | ||
return ret, False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain to me the reasoning behind this change? All your tests pass in yt-dlp without this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, I figured it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...the last item of a multi-item list wasn't fully processed
Before: process list, pop last item, continue processing last item instead of list or processing last item from the beginning (where's the goto
when you need it!).
@classmethod | ||
def build_arglist(cls, arg_text): | ||
if not arg_text: | ||
return [] | ||
return list(filter(None, (x.strip() or None for x in cls._separate(arg_text)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. The filter
doesn't make sense to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing empty items, but there shouldn't be any:
function fred(a,b,c) {
return b;
}
fred(1, ,2);
/*
Exception: SyntaxError: expected expression, got ','
@Scratchpad/1:4
*/
function fred(a,,c) {
return c;
}
/*
Exception: SyntaxError: missing formal parameter
@Scratchpad/1:1
*/
So probably just strip and let it crash elsewhere.
* commit 'e52e8b8111cf7ca27daef184bacd926865e951b1': [postprocessor] Don't replace existing value with null metadata parsed from title [jsinterp] Overhaul JSInterp to handle new YT players 4c3f79c5, 324f67b9 (ytdl-org#31170) [core] Make `--max-downloads ...` stop immediately on reaching the limit [test, etc] Improve download test logs; also clean up some new flake8 issues (ytdl-org#31153) [aenetworks] Update _THEPLATFORM_KEY and _THEPLATFORM_SECRET (ytdl-org#29749) # Conflicts: # test/test_utils.py # youtube_dl/jsinterp.py
…7b9 (ytdl-org#31170) * back-port from yt-dlp 8f53dc4, thanks pukkandan * also support void, improve <</>> precedence, improve expressions in comma-list * add more tests
* commit 'b6bfdb25f200ba63ba1b011a54431cb424be46e9': (23 commits) [jsinterp] Workaround operator associativity issue * temporary fix for player 5a3b6271 [1] [cache] Add cache validation by program version, based on yt-dlp [jsinterp] Handle new YT players 113ca41c, c57c113c * add NaN * allow any white-space character for `after_op` * align with yt-dlp f26af78 (charcodeAt and bitwise overflow) * allow escaping in regex, fixing player c57c113c [options] Document that postprocessing is not forced by --postprocessor-args [compat] Replace deficient ChainMap class in Py3.3 and earlier * fix version check [compat] Replace deficient ChainMap class in Py3.3 and earlier [jsinterp] Improve try/catch/finally support [jsinterp] Fix bug in operator precedence * from yt-dlp/yt-dlp@164b03c * added tests [YouTube] Improve error check for n-sig processing [core] Avoid processing empty format list after removing bad formats * also ensure compat encoding of error strings [utils] Ensure RFC3986 encoding result is unicode [infoq] Avoid crash if the page has no `mp3Form` [uktvplay] Support domain without .uktv [jsinterp] Clean up and pull yt-dlp style * add compat_re_Pattern * improve compat_collections_chain_map * use class JS_Undefined * remove unused code [jsinterp] Handle regexp literals and throw/catch execution (ytdl-org#31182) [jsinterp] Improve JS language support (ytdl-org#31175) [postprocessor] Don't replace existing value with null metadata parsed from title [jsinterp] Overhaul JSInterp to handle new YT players 4c3f79c5, 324f67b9 (ytdl-org#31170) [core] Make `--max-downloads ...` stop immediately on reaching the limit [test, etc] Improve download test logs; also clean up some new flake8 issues (ytdl-org#31153) ...
…7b9 (ytdl-org#31170) * back-port from yt-dlp 8f53dc4, thanks pukkandan * also support void, improve <</>> precedence, improve expressions in comma-list * add more tests
Boilerplate: mixed code, bug fix
## Please follow the guide belowx
into all the boxes [ ] relevant to your pull request (like that [x])Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
Issue #31164 reported errors with new players served by YouTube. More complex JS constructs confused yt-dl's JSInterp mini-JS interpreter.
Thanks mostly to @pukkandan, this PR fixes the problem code by back-porting from pukkandan/yt-dlp-dev@8f53dc4 into the existing previously back-ported framework.
Additionally:
void
used in player 324f67b9<<
/>>
precedence (TODO item in back-ported code), by preventing an operator search for<
/>
from matching the operator with the same first characterlet
,const
in case they should appearnew Date(...)