GitHub - thegrims/newpipe-extractor-wasm

GitHub

2 min read Original article ↗

Experiment: compiling NewPipeExtractor to WebAssembly via TeaVM, so it can run in a browser.

See PLAN.md for the full plan and a running status log of what's actually been verified so far.

Layout

extractor/         unmodified clone of TeamNewPipe/NewPipeExtractor (git submodule)
browser-wrapper/    Gradle project wrapping the extractor for the browser (TeaVM/wasm-gc)
cors-proxy/         Cloudflare Worker relaying requests around the browser's CORS wall

extractor/ is kept untouched to make pulling upstream changes easy — all browser/WASM-specific work happens in browser-wrapper/, including a handful of classes that shadow parts of the extractor's dependency tree that don't compile under TeaVM's wasm-gc backend (Rhino, jsoup's re2j detection, a protobuf message) — see PLAN.md's Step 8 entry for the full list and why.

Current status

A real end-to-end extraction works, in an actual browser. getStreamInfo() pulls live title/duration/uploader data for a real YouTube URL, through cors-proxy, compiled to WebAssembly, running in Chrome. See PLAN.md's status log for the full story — what broke, why, and how each was fixed.

browser-wrapper/webdemo/ has test.mjs (Node-runnable checks for the network-free milestones) and index.html (the full demo, including the real extraction — needs cors-proxy running via wrangler dev alongside it, see below).

Building

Requires JDK 11, 17, and 21 available to Gradle's toolchain resolution (the extractor needs 11, checkstyle needs 21; 17 was used to run Gradle itself).

# extractor (unmodified upstream)
cd extractor
./gradlew build

# browser-wrapper (WASM build)
cd ../browser-wrapper
./gradlew buildWasmGC
cp build/generated/teavm/wasm-gc/browser-wrapper.wasm* webdemo/
cd webdemo && node --experimental-wasm-exnref test.mjs

To try the full demo (including the real extraction) in a browser, run the proxy locally alongside a static server for webdemo/:

cd cors-proxy && npx wrangler dev --port 8787   # no Cloudflare account needed
cd browser-wrapper/webdemo && python3 -m http.server 8934
# open http://localhost:8934/index.html

License

GPL-3.0-or-later — see LICENSE.

NewPipeExtractor (the extractor/ submodule) is itself licensed under GPL-3.0-or-later by NewPipe e.V. This project's compiled WebAssembly output links against and incorporates extractor code, so this repo is licensed under the same terms — that's both a compliance requirement (GPL's copyleft covers combined/derivative works distributed in binary form, and browser-wrapper.wasm is committed here) and the natural choice for a project built directly on top of it.