Commit Graph

64 Commits (c1a03b1ac3a453508b358b6d1bc5d158cc80a0ce)

Author SHA1 Message Date
dirkf c1a03b1ac3 [jsinterp] Fix and improve loose and strict equality operations
* reimplement loose equality according to MDN (eg, 1 == "1")
* improve strict equality (eg, "abc" === "abc" but 'abc' is not 'abc')
* add tests for above
2 weeks ago
dirkf 118c6d7a17 [jsinterp] Implement `typeof` operator 2 weeks ago
dirkf dbc08fba83 [jsinterp] Improve slice implementation for player b12cc44b
Partly taken from yt-dlp/yt-dlp#10664, thx seproDev
        Fixes #32896
5 months ago
dirkf d35ce6ce95 [jsinterp] Support functionality for player `b22ef6e7`
* support `prototype` for call() and apply() (yt-dlp/yt-dlp#10392, thx Grub4k)
* map JS `Array` to `list`
6 months ago
dirkf 76ac69917e [jsinterp] Further improve expression parsing (fix fd8242e)
Passes tests from yt-dlp
6 months ago
dirkf 756f6b45c7 [jsinterp] Re-align JSInterp and tests (esp.) with yt-dlp
Thx: various yt-dlp authors
6 months ago
dirkf e0094e63c3 [jsinterp] Various tweaks
* treat Infinity like NaN
* cache operator list
6 months ago
dirkf fd8242e3ef [jsinterp] Fix and improve expression parsing
* improve BODMAS (fixes https://github.com/ytdl-org/youtube-dl/issues/32815)
* support more weird expressions with multiple unary ops
6 months ago
dirkf ad01fa6cca [jsinterp] Add Debugger from yt-dlp
* https://github.com/yt-dlp/yt-dlp/commit/8f53dc4
* thx pukkandan
6 months ago
dirkf 1d8d5a93f7 [test] Fixes for old Pythons 1 year ago
dirkf f24bc9272e [Misc] Fixes for 2.6 compatibility 2 years ago
dirkf 07af47960f [YouTube] Improve fix for ae8ba2c
Thx: https://github.com/yt-dlp/yt-dlp/commit/01aba25
2 years ago
dirkf d6433cbb2c [jsinterp] Don't find unrelated objects 2 years ago
dirkf ff75c300f5 [jsinterp] Fix test for failed match in extract_object() 2 years ago
dirkf a2534f7b88 [jsinterp] Fix div bug breaking player 8c7583ff
Thx bashonly: https://github.com/ytdl-org/youtube-dl/issues/32292#issuecomment-1585639223
Fixes #32292
2 years ago
dirkf d89c2137ba [jsinterp] Small updates for a85a875
* update signature tests
* clarify NaN handling
2 years ago
dirkf 6ed3433828 [jsinterp] Add short-cut evaluation for common expression
* special handling for (d%e.length+e.length)%e.length speeds up ~6%
2 years ago
dirkf a85a875fef [jsinterp] Handle NaN in bitwise operators
* also add _NaN
* also pull function naming from yt-dlp
2 years ago
dirkf 211cbfd5d4 [jsinterp] Minimally handle arithmetic operator precedence
Resolves #32066
2 years ago
dirkf 0402710227 [jsinterp] Fix regexp parsing and .replace[All] method
* For performance, make regexp object instantiation lazy
 * Other small performance improvements
2 years ago
pukkandan 3e92c60fcd [jsinterp] Handle `Date` at epoch 0
See yt-dlp/yt_dlp#6400
2 years ago
dirkf 57802e632f [jsinterp] Fix dict comprehension for Py2.6
Resolves #31600
2 years ago
dirkf cd987e6fca [jsinterp] Nits 2 years ago
dirkf 295736c9cb [jsinterp] Improve parsing
* support subset `... else if ...`
* support `while`
* add `RegExp` class
* generalise `new` support
* limited more debug strings
* matching test changes
2 years ago
pukkandan 14ef89a8da Support `if` statements
Fix for yt-dlp/yt_dlp#6131
Closes #31509
2 years ago
dirkf 6e2626f092
[JSInterp] Improve separation logic
Based on 0468a3b325
2 years ago
pukkandan 7009bb9f31 [jsinterp] Workaround operator associativity issue
* temporary fix for player 5a3b6271 [1]

1. https://github.com/yt-dlp/yt-dlp/issues/4635#issuecomment-1235384480
2 years ago
dirkf 55c823634d [jsinterp] Handle new YT players 113ca41c, c57c113c
* add NaN
* allow any white-space character for `after_op`
* align with yt-dlp f26af78a8ac11d9d617ed31ea5282cfaa5bcbcfa (charcodeAt and bitwise overflow)
* allow escaping in regex, fixing player c57c113c
2 years ago
dirkf 4c6fba3765 [jsinterp] Improve try/catch/finally support 2 years ago
dirkf d619dd712f [jsinterp] Fix bug in operator precedence
* from 164b03c486
* added tests
2 years ago
dirkf 46b8ae2f52 [jsinterp] Clean up and pull yt-dlp style
* add compat_re_Pattern
* improve compat_collections_chain_map
* use class JS_Undefined
* remove unused code
2 years ago
dirkf 538ec65ba7
[jsinterp] Handle regexp literals and throw/catch execution (#31182)
* based on f6ca640b12, thanks pukkandan
* adds parse support for regexp flags
2 years ago
dirkf b0a60ce203
[jsinterp] Improve JS language support (#31175)
* operator ??
* operator ?.
* operator **
* accurate operator functions
* `undefined` handling
* object literals {a: 1, "b": expr}
* more tests for weird JS comparisons: see https://github.com/ytdl-org/youtube-dl/issues/31173#issuecomment-1217854397.
2 years ago
dirkf d231b56717
[jsinterp] Overhaul JSInterp to handle new YT players 4c3f79c5, 324f67b9 (#31170)
* back-port from yt-dlp 8f53dc44a0cc1c2d98c35740b9293462c080f5d0, thanks pukkandan
* also support void, improve <</>> precedence, improve expressions in comma-list
* add more tests
2 years ago
dirkf 6ca7b77696 Refactor JSInterpreter._separate
yt-dlp/yt-dlp/@06dfe0a, improve _MATCHING_PARENS
3 years ago
dirkf 9d142109f4 Back-port test_youtube_signature.py from yt-dlp and fix JSInterp accordingly 3 years ago
dirkf 1ca673bd98 Fix splice to handle float
Needed for new youtube js player f1ca6900
Add 57dbe8077f (diff-729b57caa8d006426f6a8960c061f519a8b6658682284015e069745af52ffb07)
3 years ago
df e1eae16b56 Handle default in switch better
Add a1fc7ca074
Thanks coletdjnz
3 years ago
df 96f87aaa3b Back-port JS interpreter upgrade from yt-dlp PR #1437 3 years ago
Sergey M․ 0e2d626ddd
[jsinterp] Fix typo and cleanup regexes (closes #13134) 8 years ago
Sergey M․ 7769f83701
[jsinterp] Add support for quoted names and indexers (closes #13123, closes #13130) 8 years ago
Sergey M․ d1aeacd9bf
[youtube] Fix extraction (closes #11663, #11664) 8 years ago
Kacper Michajłow 189935f159 [jsinterp] Fix function calls without arguments. 8 years ago
Sergey M․ b46eabecd3
[jsinterp] Relax JS function regex (Closes #9863) 9 years ago
Philipp Hagemeister 1f749b6658 Revert "[jsinterp] Avoid double key lookup for setting new key"
This reverts commit 7c05097633.
9 years ago
Lucas Moura 7c05097633
[jsinterp] Avoid double key lookup for setting new key
In order to add a new key to both __objects and __functions dicts on jsinterp.py, it is
necessary to first verify if a key was present and if not, create the key and
assign it to a value.

However, this can be done with a single step using dict setdefault method.
9 years ago
Sergey M․ b95779be21 [jsinterp] Extend function regex (Closes #7900, closes #7901) 9 years ago
Philipp Hagemeister 4c7d816dd7 [jsinterp] Adapt to updated YouTube code generation (Fixes #7623, fixes #7624, fixes #7625, fixes #7626) 9 years ago
Yen Chi Hsuan ff29bf81f8 [jsinterp] Support alternative function definition form 9 years ago
Philipp Hagemeister 3eff81fbf7 [jsinterp] Disable comment support
We need a proper lexer to be able to understand YouTube's code, which contains /* inside of strings.
For now it's sufficient to just disable comment support altogether.

Fixes #4976, fixes #4979, fixes #4980, fixes #4981, fixes #4982.
Closes #4977.
10 years ago