Comment by lolinder
3 years ago
To be clear, this is an extremely tiny subset of JS. It looks like they only implemented the features needed to run a very specific function. For example, the only symbol allowed after "new" is "Date", everything else throws an exception.
It's still fun that it's there, but it's not as big a deal as it sounds from the tweet.
It will only grow - as new scripts will need to be interpreted, new features will be added.
I would be horrified if this grew much further. It's perfectly fine for its current scope, but the architecture would not scale at all to a full interpreter without essentially starting from scratch.
Yeah, at some point you have to question if it's worth spending time maintaining a quirky, error-prone, ever-growing mini-JS interpreter, or just adding a dependency on v8 or node or something. And then you don't have to worry about supporting new scripts, as they'll just always work.
2 replies →
How much does it need to "scale"? It just has to be fast and correct enough for the a CLI to work.
1 reply →
Yeah, it's essentially used as a javascript expression solver. You can see the full extent of its capabilities in the testsuite: https://github.com/ytdl-org/youtube-dl/blob/master/test/test...
The specific site modules in youtube-dl will take care to extract the bare minimum necessary to solve whatever challenge.
if it's going to need much more than that then it probably would make more sense to port the whole application to javascript instead.
but then this could be turned into a commandline browser that is able to interpret a whole web-page and save the resulting html structure instead of the source as curl/wget would do.
Eventually, YouTube-dl might have to simulate an entire browser and human user to fool Google. Until then, the usefulness of YouTube-dl is that it's less heavy than a full browser.
I bet someone's already started a YouTube downloader that uses a headless browser