yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader
https://discord.gg/H5MNcFW63r
The Unlicense
82.83k stars 6.46k forks source link

[Feature Request] Implement JavaScript interpreter (or find a better dependency than PhantomJS) #923

Closed sulyi closed 2 years ago

sulyi commented 3 years ago

Checklist

Description

Implementing a JavaScript interpreter based on ECMA-262, 12th edition, ECMAScript® 2021 Language Specification.

sulyi commented 3 years ago

I still have the codebase of ytdl-org/youtube-dl#11272, but I'm happy to start from scratch. I'm very excited by the prospect of collaboration @fstirlitz has shown.

sulyi commented 3 years ago

Originally I started to implement Standard ECMA 5.1. Lexer uses regular expressions and have a close to complete grammar. A missing feature is handling white characters. Parser is able to generate AST, but missing features like hoisting, semicolon insertion. Interpreter is already able to execute several expressions including unary, binary, bit-wise and logical operators. Missing i.g. method call, built-ins, conditional and loop statements, just that I'm able to recall.

I've already got overwhelmed once. I'm looking for help, someone who can and willing to work on this.

ghost commented 2 years ago

I might be interested in this. I have made an interpreter for a different language before.

sulyi commented 2 years ago

DOA

sheerluck commented 2 years ago

What about https://duktape.org

sheerluck commented 2 years ago

phantomjs-bin Total size : 64.9 MiB duktape Total size : 1.5 MiB

sulyi commented 2 years ago

duktap is written in C and published under MIT license, but it's maintained. Making a python wrapper for it could work.

Lesmiscore commented 2 years ago

It doesn't have DOM though? I think iqiyi requires DOM as well as interpreter to work

MinePlayersPE commented 2 years ago

plus the only other usage of PhantomJS is to bypass PornHub's browser verification, so we'd need to implement browser APIs anyways

pukkandan commented 2 years ago

Don't keep closing and reopening this. I originally marked https://github.com/yt-dlp/yt-dlp/issues/1354 as a dup of this, but now that is the main thread because you closed this!