Add javascript interpreter API
Lua website parser scripts sometimes need to parse or interpret javascript from web platforms in order to interoperate and play videos. The main use case is youtube.lua
parameter descrambling, but soundcloud.lua
currently fetches a client_id
parameter from javascript as well. And there are other potential uses and cases where, if not a requirement, this possibility would still be helpful.
I'm not conclusively advocating for this, but it would be responsible to discuss and explore this long term perspective. Especially considering that if we ever get to the point that there is no way around this approach, it's not something we can simply build, backport and ship into a stable VLC version overnight to fix things after deciding so.
For reference, youtube-dl uses a built-in javascript interpreter implementation written in Python, like the rest of the project. No, it's not full-featured, and yes, it required updating and additional developments for YouTube's new "n" parameter descrambling, because it didn't support switch/case statements or whatever other non-trivial language feature.
If we find a third-party javascript interpreter written in Lua, we can just ship it as a Lua module and call it from youtube.lua
. Otherwise if it's available as a dynamic library, we can add it to contribs, and then either link the lua module against it and export the feature through the lua API; or do like XML parsing and add it as a core facility, with a core API, new module class, new javascript interpreter module... and lua binding.
Anyone wants to suggest good candidate javascript engines? Isn't there a market for simple, lightweight standalone tools to complete obfuscated javascript challenges?