Async video downloader with Cloudflare bypass, parallel chunked transfers, and multi-source HTML extraction. Termux / ARMv7 optimised.
Project description
java2-extention
Async video downloader with Cloudflare bypass, parallel chunked transfers,
and multi-source HTML extraction.
Optimised for Termux / ARMv7 / 2 GB RAM.
Install
pip install java2-extention
With faster optional deps (lxml, aiodns, brotli):
pip install "java2-extention[fast]"
Termux one-liner
pkg update && pkg install python python-pip
pip install java2-extention
CLI usage
# Download from a video page (auto-extracts best quality)
java2dl "https://example.com/some-video-page" ./downloads/
# Download a known direct URL
java2dl "https://cdn.example.com/video.mp4" ./video.mp4
# Skip Cloudflare warmup (clean CDN, no challenge)
java2dl "https://cdn.example.com/video.mp4" . --no-warm
# Verbose debug output
java2dl "https://example.com/page" . --debug
Python API
import asyncio
from java2_extention import (
VideoExtractor,
pick_best,
rank_qualities,
fetch_html,
warm_download_url,
download_to_file,
ProgressTracker,
)
from java2_extention.downloader import make_session
async def main():
page_url = "https://example.com/video-page"
# 1. Fetch the page HTML (Cloudflare-aware, sync → thread)
html = await asyncio.to_thread(fetch_html, page_url)
# 2. Extract all video URLs from the page
extractor = VideoExtractor(base_url=page_url)
entries = extractor.extract(html)
# 3. Pick the best direct download
pick = pick_best(entries)
if not pick:
print("No downloadable video found")
return
print(f"Best: {pick.url} quality={pick.quality}")
# 4. Warm the CDN (solve Cloudflare, harvest cookies)
final_url, cookies = await warm_download_url(pick.url, page_url)
# 5. Download with a progress callback
async def on_progress(downloaded: int, total):
if total:
print(f"\r{downloaded/total*100:.1f}%", end="", flush=True)
tracker = ProgressTracker(callback=on_progress)
async with make_session(cookies) as session:
size = await download_to_file(
session,
final_url,
dest=__import__("pathlib").Path("video.mp4"),
progress=tracker,
referer=page_url,
warm=False, # already warmed above
)
print(f"\nDone — {size / 1024 / 1024:.1f} MB")
asyncio.run(main())
How it works
| Step | What happens |
|---|---|
| Extract | VideoExtractor tries 5 strategies in order: OG video meta, Twitter player meta, <video>/<source> tags, inline <script> JSON scan, <link rel> tags. |
| Rank | Each URL is scored by format (mp4 > webm > m3u8), resolution label, and penalises preview/thumbnail URLs. |
| Warm | warm_download_url runs cloudscraper (HEAD then range probe) to solve Cloudflare challenges and harvest cookies. |
| Download | If the server supports byte ranges and the file is > 2 MB, splits into N parallel chunks. Worker count is capped by available RAM. Falls back to streaming if ranges are unsupported. |
Environment variables
| Variable | Default | Purpose |
|---|---|---|
J2_CHUNK_SIZE |
524288 (512 KB) |
Bytes per read chunk |
J2_DL_WORKERS |
8 |
Max parallel range workers |
J2_PROGRESS_SEC |
2 |
Progress callback interval (seconds) |
Lower J2_DL_WORKERS to 2–4 on a 2 GB ARMv7 device if you see OOM.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file java2_extention-1.0.7.tar.gz.
File metadata
- Download URL: java2_extention-1.0.7.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6991fbc55589c19575a8720975b3d85ad49533d190bfe46ca84014da5e86f17d
|
|
| MD5 |
2af65870610a692e3ec5a7b4fbe8fc19
|
|
| BLAKE2b-256 |
ffd645cb08ba7ff64fad1abc2e09be6e15f15a46bbf28e71f5e3c1e8d5a778f2
|
File details
Details for the file java2_extention-1.0.7-py3-none-any.whl.
File metadata
- Download URL: java2_extention-1.0.7-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2115ad3d1f0fbec8fe2e676776f590ddabcb4cf496b29d927409f03e8fce2956
|
|
| MD5 |
22bc39e7bee29bce59d381cc8383ffaf
|
|
| BLAKE2b-256 |
4ef244cf7348294f7b6637c51b177dffc2680e35d183400ccaa5bf1b3fb9e5a4
|