Skip to content
emirhan-karacaPublic

About

High-performance multi-segment download accelerator, stream grabber, and Chrome MV3 extension

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

FetchFile — Smart Multi-Stream Download Accelerator

FetchFile is a high-performance Windows download accelerator and Chrome Manifest V3 browser integration suite built around the HyperStream Dynamic Segmentation Engine.


Highlights & Architecture

  • HyperStream Dynamic In-Half Division Engine (1–32 Parallel Streams)
    • Dynamically divides active byte ranges in half (mid = current_byte + remaining / 2) whenever a worker finishes its assigned slice, keeping all parallel connections saturated until the final byte without re-running probe/handshake stages.
  • NTFS Sparse Pre-Allocation (FSCTL_SET_SPARSE) & Lock-Free Positional I/O (seek_write)
    • Marks .fetchpart files as sparse on NTFS volumes so multi-gigabyte allocations (10 GB+ ISOs and archives) complete in O(1) time without zero-fill disk stalls, while all workers write concurrently through a single shared OS file handle via FileExt::seek_write.
  • Adaptive Stalled Segment Recycling
    • Continuously monitors per-segment throughput relative to peer streams; automatically recycles throttled or stalled TCP sockets (< 15 KB/s for 3s while peer streams run fast, or 0 B for 5s) to eliminate tail latency in the last 5% of downloads.
  • Refresh Expired Download Address & Multi-Mirror Acceleration
    • Refresh Download Address (POST /api/v1/downloads/:id/refresh-url): Seamlessly swaps expired pre-signed URLs (S3, Cloudflare R2, Google Drive, CDN tokens) while verifying byte-length consistency and preserving .fetchpart progress without resetting to 0%.
    • Multi-Mirror Pool: Distributes segments across multiple mirror URLs in round-robin order with automatic mirror failover on error.
  • Real-Time 8K / 4K60 HDR Video Probing, Playlist Selector & Clip Trimming
    • Live Format & Size Probing (GET /api/v1/video-formats): Queries real resolutions (4320p 8K, 2160p60 4K HDR, 1440p60 2K, 1080p60 HD, Audio M4A/MP3), codecs (AV1, VP9, H.264), and estimated file sizes.
    • Playlist Inspector (POST /api/v1/playlist-inspect): Parses full YouTube playlists in seconds with a selectable checklist for one-click batch queueing.
    • Clip Trimming & Mastering: Supports time-range clipping (--download-sections "*start-end" with keyframe cuts), automatic TR/EN subtitle muxing (--embed-subs), and chapter/metadata embedding (--embed-chapters).
  • Zero-Polling Server-Sent Events (/api/v1/events) & Windows System Tray
    • Pushes real-time segment and speed telemetry over SSE (EventSource) to both the desktop UI and Chrome extension popup, with native Windows System Tray (Shell_NotifyIconW) background operation, Toast completion notifications, and automatic Dark/Light theme sync.
  • Download Library & Accessible Controls
    • Live activity summaries, searchable and sortable files, category/queue navigation, and a per-connection progress inspector in coordinated dark and light themes.
    • Ctrl+N adds a link, Ctrl+K focuses search, and Escape closes dialogs. Failed submissions preserve entered values and display the service error.

Repository Structure

fetchfile/
├── fetchfile-desktop/            # Native Rust desktop application & HTTP/SSE bridge (:46890)
│   ├── src/
│   │   ├── main.rs               # Window lifecycle, WebView host & System Tray event loop
│   │   ├── engine.rs             # HyperStream multi-segment core, multi-mirror & video/playlist engine
│   │   ├── server.rs             # Axum HTTP REST API & SSE real-time push server
│   │   ├── scheduler.rs          # Concurrent download queue & time-window scheduler
│   │   ├── models.rs             # Data structures, checkpoint schema & category rules
│   │   └── win_platform.rs       # Win32 sparse file I/O, ShellExecuteW & System Tray API
│   ├── ui/                       # Desktop interface (HTML5, CSS3 Dark/Light themes, SSE client)
│   └── scripts/
│       └── live-bridge.mjs       # Standalone Node.js HyperStream bridge & UI server
├── fetchfile-chrome-extension/   # Chrome Manifest V3 extension ("FetchFile Fetcher")
│   ├── manifest.json
│   ├── background.js             # Download interception, network stream sniffer & context menus
│   ├── content.js                # Selection batch link pill & page media inspector
│   ├── popup.html / popup.js     # Live 4K format picker, clip trimmer & playlist selector
├── start-fetchfile.ps1           # One-command launcher script
└── LICENSE                       # MIT License

Quick Start

1. Launch FetchFile Desktop / Bridge Server

Run the included PowerShell launcher from the repository root:

.\start-fetchfile.ps1

Or build and run the native Rust desktop binary directly:

cd .\fetchfile-desktop
cargo run --release

The FetchFile UI and local extension bridge listen on http://127.0.0.1:46890.

2. Load the Chrome Extension (FetchFile Fetcher)

  1. Open chrome://extensions in Google Chrome, Brave, or Edge.
  2. Enable Developer mode (top-right toggle).
  3. Click Load unpacked and select the fetchfile-chrome-extension folder.
  4. Hold the Alt key while clicking any link in the browser to temporarily bypass automatic FetchFile interception.

Local HTTP / SSE API (http://127.0.0.1:46890/api/v1)

Method Endpoint Description
GET /api/v1/health Bridge health, version, and browser interception rules
GET /api/v1/state Full snapshot of downloads, segments, scheduler, and settings
GET /api/v1/events Real-time Server-Sent Events (SSE) telemetry stream
GET /api/v1/video-formats?url=... Probe real video resolutions, codecs, HDR flags, and sizes
POST /api/v1/playlist-inspect Inspect YouTube playlist entries (title, duration, url)
POST /api/v1/downloads Create a single download (supports mirrors, clip_start, clip_end, embed_subs, embed_chapters)
POST /api/v1/downloads/batch Queue or start a batch of downloads
POST /api/v1/downloads/:id/refresh-url Refresh expired download URL & mirrors without losing .fetchpart progress
POST /api/v1/downloads/:id/start Start or resume a download
POST /api/v1/downloads/:id/pause Pause an active download
POST /api/v1/downloads/:id/open-file Open completed file via Win32 ShellExecuteW
POST /api/v1/downloads/:id/show-in-folder Reveal file or .fetchpart in Windows Explorer (/select,)

Development checks

From the repository root (Node.js 18+ and a Rust toolchain):

cargo check --manifest-path .\fetchfile-desktop\Cargo.toml
cargo test --manifest-path .\fetchfile-desktop\Cargo.toml
node --test .\fetchfile-desktop\scripts\live-bridge.test.mjs .\fetchfile-desktop\ui\app.test.mjs .\fetchfile-chrome-extension\background.test.mjs

Bridge integration tests use temporary state/download directories, a local fixture server, and an ephemeral port. Extension tests mock Chrome APIs to exercise successful and rejected desktop handoffs without changing installed browser settings.

After changing embedded desktop UI assets, rebuild with cargo build --release --manifest-path .\fetchfile-desktop\Cargo.toml. Restart the desktop app and reload the unpacked extension in chrome://extensions to use the updated versions.


License

Released under the MIT License.

About

High-performance multi-segment download accelerator, stream grabber, and Chrome MV3 extension

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages