happydownload 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- happydownload-2.0.0/LICENSE +21 -0
- happydownload-2.0.0/PKG-INFO +174 -0
- happydownload-2.0.0/README.md +145 -0
- happydownload-2.0.0/build_exe.py +224 -0
- happydownload-2.0.0/happydownload/__init__.py +6 -0
- happydownload-2.0.0/happydownload/adaptive.py +297 -0
- happydownload-2.0.0/happydownload/engine.py +2428 -0
- happydownload-2.0.0/happydownload/extractor.py +911 -0
- happydownload-2.0.0/happydownload/hls.py +195 -0
- happydownload-2.0.0/happydownload/models.py +181 -0
- happydownload-2.0.0/happydownload/network.py +486 -0
- happydownload-2.0.0/happydownload/power.py +175 -0
- happydownload-2.0.0/happydownload/server.py +540 -0
- happydownload-2.0.0/happydownload/static/app.js +1196 -0
- happydownload-2.0.0/happydownload/static/banner.png +0 -0
- happydownload-2.0.0/happydownload/static/favicon.ico +0 -0
- happydownload-2.0.0/happydownload/static/index.html +282 -0
- happydownload-2.0.0/happydownload/static/logo.png +0 -0
- happydownload-2.0.0/happydownload/static/manifest.json +22 -0
- happydownload-2.0.0/happydownload/static/styles.css +907 -0
- happydownload-2.0.0/happydownload/storage.py +799 -0
- happydownload-2.0.0/happydownload/tray.py +208 -0
- happydownload-2.0.0/happydownload.egg-info/PKG-INFO +174 -0
- happydownload-2.0.0/happydownload.egg-info/SOURCES.txt +30 -0
- happydownload-2.0.0/happydownload.egg-info/dependency_links.txt +1 -0
- happydownload-2.0.0/happydownload.egg-info/entry_points.txt +2 -0
- happydownload-2.0.0/happydownload.egg-info/requires.txt +1 -0
- happydownload-2.0.0/happydownload.egg-info/top_level.txt +3 -0
- happydownload-2.0.0/main.py +226 -0
- happydownload-2.0.0/pyproject.toml +49 -0
- happydownload-2.0.0/setup.cfg +4 -0
- happydownload-2.0.0/tests/test_happydownload.py +936 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aswin Lal S Y
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: happydownload
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Adaptive multi-stream 50+ GB file & 4K web video downloader with NTFS sparse I/O and SQLite WAL resilience.
|
|
5
|
+
Author: Aswin Lal S Y
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/aswinlal1904/Happydownload
|
|
8
|
+
Project-URL: Repository, https://github.com/aswinlal1904/Happydownload
|
|
9
|
+
Project-URL: Releases, https://github.com/aswinlal1904/Happydownload/releases
|
|
10
|
+
Keywords: downloader,multi-stream,adaptive,hls,yt-dlp,sparse-file,video-downloader
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
|
+
Classifier: Topic :: Multimedia :: Video
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: yt-dlp>=2024.10.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Happydownload v2.0.0
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="LOGO/Happydownload%20Neon%20Open-Source%20Banner.png" alt="Happydownload v2.0.0 — Adaptive Multi-Stream 50+ GB & 4K Video Engine • Developed by Aswin Lal S Y" width="100%" />
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="LOGO/Neon%20Glass%20Download%20Orbit%20Icon.png" alt="Happydownload Logo" width="88" />
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
**Adaptive Multi-Stream 50+ GB File & 4K Web Video Download Engine**
|
|
41
|
+
*Architected & Developed by **Aswin Lal S Y***
|
|
42
|
+
|
|
43
|
+
[](https://github.com/aswinlal1904/Happydownload/releases)
|
|
44
|
+
[](https://pypi.org/project/happydownload/)
|
|
45
|
+
[](https://www.python.org/)
|
|
46
|
+
[](LICENSE)
|
|
47
|
+
|
|
48
|
+
Happydownload is a crash-proof, adaptive multi-connection download engine engineered to download **massive 50+ GB movie/archive files**, **HLS (`.m3u8`) streams**, and **web videos from 1,500+ platforms** (YouTube, Instagram Reels/Posts, TikTok, X/Twitter, Vimeo, Dailymotion, Reddit, and generic HTML5 video pages) at maximum possible bandwidth without data loss.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Key Highlights
|
|
53
|
+
|
|
54
|
+
- **Adaptive Hill-Climbing Concurrency Engine:** Continuously measures EWMA throughput every 2.5s and dynamically scales parallel connections (`1..64`) up while bandwidth increases, or backs off automatically on HTTP `429`/`503` throttling and high-latency stalls.
|
|
55
|
+
- **Instant 50+ GB NTFS Sparse File I/O (`FSCTL_SET_SPARSE`):** Starts writing multi-gigabyte segments at millisecond zero without freezing the disk with synchronous zero-fill allocation, while pre-validating free space and `FAT32` 4 GB limits.
|
|
56
|
+
- **Crash-Proof SQLite WAL Byte-Level Checkpointing:** Every segment's exact byte offset is persisted in an atomic Write-Ahead Log database (`data/segments/<id>.db`). Survives power loss, Wi-Fi drops, expired CDN tokens, and OS restarts with **zero lost bytes**.
|
|
57
|
+
- **Dynamic Tail Work-Stealing:** Fast idle worker threads automatically split the remaining tail of slow segments (`>= 4 MiB` remaining) so the final 1% of a 60 GB download never bottlenecks on a single slow TCP socket.
|
|
58
|
+
- **Universal Web Video & Social Media Extractor:**
|
|
59
|
+
- **1080p / 2K / 4K DASH Video + Audio Muxing:** Automatically pairs high-resolution video-only streams with the highest-bitrate audio track and losslessly merges them into fast-start `.mp4` via FFmpeg.
|
|
60
|
+
- **YouTube, Instagram Reels/Posts, TikTok, X/Twitter, Facebook, Vimeo:** Built-in `yt-dlp` integration + browser session cookie authentication (`Edge`, `Chrome`, `Firefox`, `Brave`) + public Instagram embed fallback + native `yt-dlp` chunked stream fallback.
|
|
61
|
+
- **Parallel Adaptive HLS (`.m3u8`) Engine:** Parses master/media playlists, downloads `.ts`/`fMP4` segments in parallel with adaptive scaling, assembles contiguously, and remuxes to `.mp4`.
|
|
62
|
+
- **Search Wrapper Unwrapping:** Automatically unwraps Bing Video Search (`relatedvideo` / `vrhm` / `mid`) and redirect wrappers into their underlying source video URLs.
|
|
63
|
+
- **Hybrid Desktop & Web UI + Win32 System Tray + CLI:**
|
|
64
|
+
- **Standalone Desktop App Mode (`--desktop`):** Launches a dedicated chromeless desktop application window paired with a pure-Win32 System Tray icon.
|
|
65
|
+
- **Local Web UI:** Real-time Server-Sent Events (`/api/events`) telemetry dashboard with live speed chart, 80-bucket Segment Integrity Map, batch multi-link downloader, playlist quality presets, overnight bandwidth scheduler, clipboard link detector, and orphan `.part` cleaner.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## How It Works (Architecture)
|
|
70
|
+
|
|
71
|
+
```mermaid
|
|
72
|
+
flowchart TD
|
|
73
|
+
U["User Input: Direct 50+ GB URL / YouTube / Instagram / .m3u8 / Web Page"] --> I["Unified Inspector (extractor.py)"]
|
|
74
|
+
I -->|"Binary / Range File"| R["Multi-Segment HTTP Range Engine (engine.py)"]
|
|
75
|
+
I -->|"Web Video / Social / Search Wrapper"| Y["yt-dlp + HTML5/Embed + Browser Cookies"]
|
|
76
|
+
I -->|"HLS Stream (.m3u8)"| H["Parallel Adaptive HLS Engine (hls.py)"]
|
|
77
|
+
Y -->|"1080p/4K Split DASH"| R
|
|
78
|
+
Y -->|"HLS Variant"| H
|
|
79
|
+
R --> A["Adaptive Hill-Climbing Controller (1..64 Workers)"]
|
|
80
|
+
A --> P["NTFS Sparse .part File Pool + HTTP Keep-Alive Sockets"]
|
|
81
|
+
P --> S["SQLite WAL Segment Store (Zero-Loss Resume)"]
|
|
82
|
+
R -->|"If Companion Audio"| M["FFmpeg Lossless MP4 FastStart Muxer"]
|
|
83
|
+
H --> M
|
|
84
|
+
M --> V["Streaming SHA-256 Verifier & Atomic File Finalizer"]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Standalone Desktop App vs. Web UI — Which Is Better?
|
|
90
|
+
|
|
91
|
+
Happydownload uses a **Hybrid Local Engine Architecture** so you get the advantages of both:
|
|
92
|
+
|
|
93
|
+
| Deployment Mode | Command | Best For | Why It Excels |
|
|
94
|
+
| :--- | :--- | :--- | :--- |
|
|
95
|
+
| **Standalone Desktop App (Recommended)** | `python main.py --desktop` *(or double-click `launch_desktop.bat`)* | Everyday Windows desktop use | Opens a dedicated, chromeless native application window + Windows System Tray icon while keeping direct OS filesystem (`FSCTL_SET_SPARSE`), sleep-prevention, and native folder picker access. |
|
|
96
|
+
| **Local Web UI** | `python main.py` | Browser workflow or remote LAN control (`--host 0.0.0.0`) | Zero heavy GUI framework bloat (no 200 MB Electron bundle); accessible from any browser tab at `http://127.0.0.1:8765`. |
|
|
97
|
+
| **Background System Tray** | `python main.py --tray --no-browser` | Overnight 50+ GB downloads | Runs silently in the Windows notification area with right-click *Pause All / Resume All / Open UI*. |
|
|
98
|
+
| **Command-Line (CLI)** | `python main.py download <URL>` | Automation, scripts & headless servers | Live terminal progress bar with full adaptive multi-connection acceleration. |
|
|
99
|
+
|
|
100
|
+
> **Why not a pure cloud-hosted web app?** A remote cloud web server downloads files to the *server's* disk first and still forces your browser to download the 50+ GB file over a single browser stream. Running the Happydownload engine locally gives you **raw multi-socket TCP concurrency, NTFS sparse disk writes, local FFmpeg 4K muxing, and Windows power management** right on your machine.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Installation & Quick Start
|
|
105
|
+
|
|
106
|
+
### 1. Prerequisites
|
|
107
|
+
- **Python 3.10+** (zero third-party libraries required for the core 50+ GB HTTP Range & HLS downloader).
|
|
108
|
+
- **yt-dlp** *(recommended for YouTube, Instagram, TikTok, and 1,500+ video sites)*:
|
|
109
|
+
```bash
|
|
110
|
+
pip install -r requirements.txt
|
|
111
|
+
```
|
|
112
|
+
- **FFmpeg** *(recommended for 1080p/4K video+audio merging and HLS `.ts` → `.mp4` remuxing)*:
|
|
113
|
+
```powershell
|
|
114
|
+
winget install --id Gyan.FFmpeg -e
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 2. Run Happydownload
|
|
118
|
+
|
|
119
|
+
- **Double-Click Windows `.exe` (No terminal required):**
|
|
120
|
+
- Double-click **`Happydownload.exe`** in the project folder (or distribute the self-contained standalone **`dist\Happydownload.exe`** to any Windows PC, even without Python installed).
|
|
121
|
+
- **Automatic FFmpeg Handling for End-Users:** When another user runs `Happydownload.exe` on a PC without FFmpeg installed, Happydownload checks portable folders (`./ffmpeg.exe`, `./bin/ffmpeg.exe`, `./data/bin/ffmpeg.exe`), system `PATH`, WinGet, Scoop, and Chocolatey—and if FFmpeg is not present, provides a **1-click Auto-Install Portable FFmpeg** button in the UI (and automatically provisions portable `ffmpeg.exe` into `data/bin/ffmpeg.exe` on-demand when merging 1080p/4K video+audio).
|
|
122
|
+
|
|
123
|
+
- **Build Standalone `.exe` From Source:**
|
|
124
|
+
```bash
|
|
125
|
+
python build_exe.py
|
|
126
|
+
# Or to embed ffmpeg.exe directly inside the single-file .exe:
|
|
127
|
+
python build_exe.py --bundle-ffmpeg
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- **Launch From Python (Standalone Desktop Window + System Tray by default):**
|
|
131
|
+
```bash
|
|
132
|
+
python main.py
|
|
133
|
+
```
|
|
134
|
+
*(To open in a standard web browser tab instead of the standalone desktop window, pass `python main.py --web`.)*
|
|
135
|
+
|
|
136
|
+
- **Download via CLI:**
|
|
137
|
+
```bash
|
|
138
|
+
python main.py download "https://example.com/movie-60gb.mkv" --max-connections 16
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## How To Use
|
|
144
|
+
|
|
145
|
+
1. **Downloading 50+ GB Movies & Archives:**
|
|
146
|
+
- Paste the direct file link into the URL bar and click **Download** (or **Inspect Link** first to verify size, `Accept-Ranges` support, and NTFS free disk space).
|
|
147
|
+
- Monitor the **Live Engine Telemetry** panel on the right for real-time speed, active/target connections, HTTP Keep-Alive socket reuses, and the 80-cell **Segment Integrity Map**.
|
|
148
|
+
2. **Downloading YouTube, Instagram Reels/Posts, TikTok & Web Videos:**
|
|
149
|
+
- Paste any video or playlist page URL.
|
|
150
|
+
- Click **Inspect Link** to preview all discovered videos on the page, choose a quality preset (**Best 4K/1080p**, **1080p Full HD**, **720p HD**, **480p**, or **Audio Only**), and click **Download Selected**.
|
|
151
|
+
- **For Instagram or Age-Restricted Videos:** Click **Engine Settings** in the top bar and set **Browser Cookies** to your logged-in browser (`Microsoft Edge`, `Google Chrome`, `Mozilla Firefox`, or `Brave`).
|
|
152
|
+
3. **Batch Multi-Link Downloading:**
|
|
153
|
+
- Click **Batch Links** next to the URL input, paste multiple file or video page URLs (one per line), and click **Download**.
|
|
154
|
+
4. **Recovering an Expired Link at 90% on a 50+ GB File:**
|
|
155
|
+
- Select the paused/failed download, paste the newly generated CDN link into the **Replace Link / Add Mirror** box in the Telemetry panel, and click **Replace Link** → **Resume**. All previously saved segments remain intact.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Running the Test Suite
|
|
160
|
+
|
|
161
|
+
Happydownload includes a 20-test unit and end-to-end integration test suite covering multi-segment SHA-256 byte accuracy, flaky drop/429 recovery, crash/restart zero-loss resume, work-stealing, expiring link refresh, mirror failover, HLS master playlist download, 4K split video+audio pairing, and search-wrapper unwrapping:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
python -m unittest discover -s tests -v
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Project Metadata & Credits
|
|
170
|
+
|
|
171
|
+
- **Project:** Happydownload
|
|
172
|
+
- **Version:** `v2.0.0`
|
|
173
|
+
- **Architect & Developer:** **Aswin Lal S Y**
|
|
174
|
+
- **License:** [MIT License](LICENSE)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Happydownload v2.0.0
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="LOGO/Happydownload%20Neon%20Open-Source%20Banner.png" alt="Happydownload v2.0.0 — Adaptive Multi-Stream 50+ GB & 4K Video Engine • Developed by Aswin Lal S Y" width="100%" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="LOGO/Neon%20Glass%20Download%20Orbit%20Icon.png" alt="Happydownload Logo" width="88" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
**Adaptive Multi-Stream 50+ GB File & 4K Web Video Download Engine**
|
|
12
|
+
*Architected & Developed by **Aswin Lal S Y***
|
|
13
|
+
|
|
14
|
+
[](https://github.com/aswinlal1904/Happydownload/releases)
|
|
15
|
+
[](https://pypi.org/project/happydownload/)
|
|
16
|
+
[](https://www.python.org/)
|
|
17
|
+
[](LICENSE)
|
|
18
|
+
|
|
19
|
+
Happydownload is a crash-proof, adaptive multi-connection download engine engineered to download **massive 50+ GB movie/archive files**, **HLS (`.m3u8`) streams**, and **web videos from 1,500+ platforms** (YouTube, Instagram Reels/Posts, TikTok, X/Twitter, Vimeo, Dailymotion, Reddit, and generic HTML5 video pages) at maximum possible bandwidth without data loss.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Key Highlights
|
|
24
|
+
|
|
25
|
+
- **Adaptive Hill-Climbing Concurrency Engine:** Continuously measures EWMA throughput every 2.5s and dynamically scales parallel connections (`1..64`) up while bandwidth increases, or backs off automatically on HTTP `429`/`503` throttling and high-latency stalls.
|
|
26
|
+
- **Instant 50+ GB NTFS Sparse File I/O (`FSCTL_SET_SPARSE`):** Starts writing multi-gigabyte segments at millisecond zero without freezing the disk with synchronous zero-fill allocation, while pre-validating free space and `FAT32` 4 GB limits.
|
|
27
|
+
- **Crash-Proof SQLite WAL Byte-Level Checkpointing:** Every segment's exact byte offset is persisted in an atomic Write-Ahead Log database (`data/segments/<id>.db`). Survives power loss, Wi-Fi drops, expired CDN tokens, and OS restarts with **zero lost bytes**.
|
|
28
|
+
- **Dynamic Tail Work-Stealing:** Fast idle worker threads automatically split the remaining tail of slow segments (`>= 4 MiB` remaining) so the final 1% of a 60 GB download never bottlenecks on a single slow TCP socket.
|
|
29
|
+
- **Universal Web Video & Social Media Extractor:**
|
|
30
|
+
- **1080p / 2K / 4K DASH Video + Audio Muxing:** Automatically pairs high-resolution video-only streams with the highest-bitrate audio track and losslessly merges them into fast-start `.mp4` via FFmpeg.
|
|
31
|
+
- **YouTube, Instagram Reels/Posts, TikTok, X/Twitter, Facebook, Vimeo:** Built-in `yt-dlp` integration + browser session cookie authentication (`Edge`, `Chrome`, `Firefox`, `Brave`) + public Instagram embed fallback + native `yt-dlp` chunked stream fallback.
|
|
32
|
+
- **Parallel Adaptive HLS (`.m3u8`) Engine:** Parses master/media playlists, downloads `.ts`/`fMP4` segments in parallel with adaptive scaling, assembles contiguously, and remuxes to `.mp4`.
|
|
33
|
+
- **Search Wrapper Unwrapping:** Automatically unwraps Bing Video Search (`relatedvideo` / `vrhm` / `mid`) and redirect wrappers into their underlying source video URLs.
|
|
34
|
+
- **Hybrid Desktop & Web UI + Win32 System Tray + CLI:**
|
|
35
|
+
- **Standalone Desktop App Mode (`--desktop`):** Launches a dedicated chromeless desktop application window paired with a pure-Win32 System Tray icon.
|
|
36
|
+
- **Local Web UI:** Real-time Server-Sent Events (`/api/events`) telemetry dashboard with live speed chart, 80-bucket Segment Integrity Map, batch multi-link downloader, playlist quality presets, overnight bandwidth scheduler, clipboard link detector, and orphan `.part` cleaner.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## How It Works (Architecture)
|
|
41
|
+
|
|
42
|
+
```mermaid
|
|
43
|
+
flowchart TD
|
|
44
|
+
U["User Input: Direct 50+ GB URL / YouTube / Instagram / .m3u8 / Web Page"] --> I["Unified Inspector (extractor.py)"]
|
|
45
|
+
I -->|"Binary / Range File"| R["Multi-Segment HTTP Range Engine (engine.py)"]
|
|
46
|
+
I -->|"Web Video / Social / Search Wrapper"| Y["yt-dlp + HTML5/Embed + Browser Cookies"]
|
|
47
|
+
I -->|"HLS Stream (.m3u8)"| H["Parallel Adaptive HLS Engine (hls.py)"]
|
|
48
|
+
Y -->|"1080p/4K Split DASH"| R
|
|
49
|
+
Y -->|"HLS Variant"| H
|
|
50
|
+
R --> A["Adaptive Hill-Climbing Controller (1..64 Workers)"]
|
|
51
|
+
A --> P["NTFS Sparse .part File Pool + HTTP Keep-Alive Sockets"]
|
|
52
|
+
P --> S["SQLite WAL Segment Store (Zero-Loss Resume)"]
|
|
53
|
+
R -->|"If Companion Audio"| M["FFmpeg Lossless MP4 FastStart Muxer"]
|
|
54
|
+
H --> M
|
|
55
|
+
M --> V["Streaming SHA-256 Verifier & Atomic File Finalizer"]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Standalone Desktop App vs. Web UI — Which Is Better?
|
|
61
|
+
|
|
62
|
+
Happydownload uses a **Hybrid Local Engine Architecture** so you get the advantages of both:
|
|
63
|
+
|
|
64
|
+
| Deployment Mode | Command | Best For | Why It Excels |
|
|
65
|
+
| :--- | :--- | :--- | :--- |
|
|
66
|
+
| **Standalone Desktop App (Recommended)** | `python main.py --desktop` *(or double-click `launch_desktop.bat`)* | Everyday Windows desktop use | Opens a dedicated, chromeless native application window + Windows System Tray icon while keeping direct OS filesystem (`FSCTL_SET_SPARSE`), sleep-prevention, and native folder picker access. |
|
|
67
|
+
| **Local Web UI** | `python main.py` | Browser workflow or remote LAN control (`--host 0.0.0.0`) | Zero heavy GUI framework bloat (no 200 MB Electron bundle); accessible from any browser tab at `http://127.0.0.1:8765`. |
|
|
68
|
+
| **Background System Tray** | `python main.py --tray --no-browser` | Overnight 50+ GB downloads | Runs silently in the Windows notification area with right-click *Pause All / Resume All / Open UI*. |
|
|
69
|
+
| **Command-Line (CLI)** | `python main.py download <URL>` | Automation, scripts & headless servers | Live terminal progress bar with full adaptive multi-connection acceleration. |
|
|
70
|
+
|
|
71
|
+
> **Why not a pure cloud-hosted web app?** A remote cloud web server downloads files to the *server's* disk first and still forces your browser to download the 50+ GB file over a single browser stream. Running the Happydownload engine locally gives you **raw multi-socket TCP concurrency, NTFS sparse disk writes, local FFmpeg 4K muxing, and Windows power management** right on your machine.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Installation & Quick Start
|
|
76
|
+
|
|
77
|
+
### 1. Prerequisites
|
|
78
|
+
- **Python 3.10+** (zero third-party libraries required for the core 50+ GB HTTP Range & HLS downloader).
|
|
79
|
+
- **yt-dlp** *(recommended for YouTube, Instagram, TikTok, and 1,500+ video sites)*:
|
|
80
|
+
```bash
|
|
81
|
+
pip install -r requirements.txt
|
|
82
|
+
```
|
|
83
|
+
- **FFmpeg** *(recommended for 1080p/4K video+audio merging and HLS `.ts` → `.mp4` remuxing)*:
|
|
84
|
+
```powershell
|
|
85
|
+
winget install --id Gyan.FFmpeg -e
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2. Run Happydownload
|
|
89
|
+
|
|
90
|
+
- **Double-Click Windows `.exe` (No terminal required):**
|
|
91
|
+
- Double-click **`Happydownload.exe`** in the project folder (or distribute the self-contained standalone **`dist\Happydownload.exe`** to any Windows PC, even without Python installed).
|
|
92
|
+
- **Automatic FFmpeg Handling for End-Users:** When another user runs `Happydownload.exe` on a PC without FFmpeg installed, Happydownload checks portable folders (`./ffmpeg.exe`, `./bin/ffmpeg.exe`, `./data/bin/ffmpeg.exe`), system `PATH`, WinGet, Scoop, and Chocolatey—and if FFmpeg is not present, provides a **1-click Auto-Install Portable FFmpeg** button in the UI (and automatically provisions portable `ffmpeg.exe` into `data/bin/ffmpeg.exe` on-demand when merging 1080p/4K video+audio).
|
|
93
|
+
|
|
94
|
+
- **Build Standalone `.exe` From Source:**
|
|
95
|
+
```bash
|
|
96
|
+
python build_exe.py
|
|
97
|
+
# Or to embed ffmpeg.exe directly inside the single-file .exe:
|
|
98
|
+
python build_exe.py --bundle-ffmpeg
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- **Launch From Python (Standalone Desktop Window + System Tray by default):**
|
|
102
|
+
```bash
|
|
103
|
+
python main.py
|
|
104
|
+
```
|
|
105
|
+
*(To open in a standard web browser tab instead of the standalone desktop window, pass `python main.py --web`.)*
|
|
106
|
+
|
|
107
|
+
- **Download via CLI:**
|
|
108
|
+
```bash
|
|
109
|
+
python main.py download "https://example.com/movie-60gb.mkv" --max-connections 16
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## How To Use
|
|
115
|
+
|
|
116
|
+
1. **Downloading 50+ GB Movies & Archives:**
|
|
117
|
+
- Paste the direct file link into the URL bar and click **Download** (or **Inspect Link** first to verify size, `Accept-Ranges` support, and NTFS free disk space).
|
|
118
|
+
- Monitor the **Live Engine Telemetry** panel on the right for real-time speed, active/target connections, HTTP Keep-Alive socket reuses, and the 80-cell **Segment Integrity Map**.
|
|
119
|
+
2. **Downloading YouTube, Instagram Reels/Posts, TikTok & Web Videos:**
|
|
120
|
+
- Paste any video or playlist page URL.
|
|
121
|
+
- Click **Inspect Link** to preview all discovered videos on the page, choose a quality preset (**Best 4K/1080p**, **1080p Full HD**, **720p HD**, **480p**, or **Audio Only**), and click **Download Selected**.
|
|
122
|
+
- **For Instagram or Age-Restricted Videos:** Click **Engine Settings** in the top bar and set **Browser Cookies** to your logged-in browser (`Microsoft Edge`, `Google Chrome`, `Mozilla Firefox`, or `Brave`).
|
|
123
|
+
3. **Batch Multi-Link Downloading:**
|
|
124
|
+
- Click **Batch Links** next to the URL input, paste multiple file or video page URLs (one per line), and click **Download**.
|
|
125
|
+
4. **Recovering an Expired Link at 90% on a 50+ GB File:**
|
|
126
|
+
- Select the paused/failed download, paste the newly generated CDN link into the **Replace Link / Add Mirror** box in the Telemetry panel, and click **Replace Link** → **Resume**. All previously saved segments remain intact.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Running the Test Suite
|
|
131
|
+
|
|
132
|
+
Happydownload includes a 20-test unit and end-to-end integration test suite covering multi-segment SHA-256 byte accuracy, flaky drop/429 recovery, crash/restart zero-loss resume, work-stealing, expiring link refresh, mirror failover, HLS master playlist download, 4K split video+audio pairing, and search-wrapper unwrapping:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
python -m unittest discover -s tests -v
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Project Metadata & Credits
|
|
141
|
+
|
|
142
|
+
- **Project:** Happydownload
|
|
143
|
+
- **Version:** `v2.0.0`
|
|
144
|
+
- **Architect & Developer:** **Aswin Lal S Y**
|
|
145
|
+
- **License:** [MIT License](LICENSE)
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"""Build script to compile Happydownload v2.0.0 into standalone Windows .exe executables.
|
|
2
|
+
|
|
3
|
+
Produces:
|
|
4
|
+
1. `Happydownload.exe` (in project root): Fast native Win32 GUI launcher with custom icon & version metadata.
|
|
5
|
+
2. `dist/Happydownload.exe` (via PyInstaller): Self-contained single-file portable Windows executable
|
|
6
|
+
bundling Python, yt-dlp, and the Happydownload UI/engine for distribution to PCs without Python.
|
|
7
|
+
Pass `--bundle-ffmpeg` to also embed `ffmpeg.exe` directly inside the PyInstaller single-file `.exe`
|
|
8
|
+
(by default, `Happydownload.exe` stays lightweight for GitHub's <100 MB limit and automatically
|
|
9
|
+
discovers or auto-installs portable `ffmpeg.exe` into `data/bin/ffmpeg.exe` on other users' PCs).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import os
|
|
16
|
+
import shutil
|
|
17
|
+
import subprocess
|
|
18
|
+
import sys
|
|
19
|
+
|
|
20
|
+
from happydownload import __author__, __version__
|
|
21
|
+
from happydownload.extractor import find_ffmpeg
|
|
22
|
+
|
|
23
|
+
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
24
|
+
ICON_PATH = os.path.join(ROOT_DIR, "happydownload", "static", "favicon.ico")
|
|
25
|
+
STATIC_DIR = os.path.join(ROOT_DIR, "happydownload", "static")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def build_native_root_launcher() -> str:
|
|
29
|
+
"""Compile a zero-console native Win32 GUI launcher `Happydownload.exe` in the project root."""
|
|
30
|
+
csc_candidates = [
|
|
31
|
+
shutil.which("csc"),
|
|
32
|
+
r"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe",
|
|
33
|
+
r"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe",
|
|
34
|
+
]
|
|
35
|
+
csc_bin = next((c for c in csc_candidates if c and os.path.isfile(c)), None)
|
|
36
|
+
out_exe = os.path.join(ROOT_DIR, "Happydownload.exe")
|
|
37
|
+
if not csc_bin:
|
|
38
|
+
print("csc.exe not found; skipping root launcher build.")
|
|
39
|
+
return out_exe
|
|
40
|
+
|
|
41
|
+
cs_source = rf'''using System;
|
|
42
|
+
using System.Diagnostics;
|
|
43
|
+
using System.IO;
|
|
44
|
+
using System.Reflection;
|
|
45
|
+
using System.Windows.Forms;
|
|
46
|
+
|
|
47
|
+
[assembly: AssemblyTitle("Happydownload")]
|
|
48
|
+
[assembly: AssemblyDescription("Adaptive Multi-Stream 50+ GB & 4K Video Download Engine")]
|
|
49
|
+
[assembly: AssemblyCompany("{__author__}")]
|
|
50
|
+
[assembly: AssemblyProduct("Happydownload v{__version__}")]
|
|
51
|
+
[assembly: AssemblyCopyright("Copyright (c) 2026 {__author__}")]
|
|
52
|
+
[assembly: AssemblyVersion("{__version__}.0")]
|
|
53
|
+
[assembly: AssemblyFileVersion("{__version__}.0")]
|
|
54
|
+
|
|
55
|
+
namespace HappydownloadLauncher {{
|
|
56
|
+
static class Program {{
|
|
57
|
+
[STAThread]
|
|
58
|
+
static int Main(string[] args) {{
|
|
59
|
+
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
|
|
60
|
+
string distExe = Path.Combine(baseDir, "dist", "Happydownload.exe");
|
|
61
|
+
string mainPy = Path.Combine(baseDir, "main.py");
|
|
62
|
+
string joinedArgs = args.Length > 0 ? string.Join(" ", args) : "--desktop";
|
|
63
|
+
|
|
64
|
+
try {{
|
|
65
|
+
if (File.Exists(mainPy)) {{
|
|
66
|
+
ProcessStartInfo psi = new ProcessStartInfo();
|
|
67
|
+
psi.FileName = "pythonw.exe";
|
|
68
|
+
psi.Arguments = "\"" + mainPy + "\" " + joinedArgs;
|
|
69
|
+
psi.WorkingDirectory = baseDir;
|
|
70
|
+
psi.UseShellExecute = false;
|
|
71
|
+
psi.CreateNoWindow = true;
|
|
72
|
+
try {{
|
|
73
|
+
Process.Start(psi);
|
|
74
|
+
return 0;
|
|
75
|
+
}} catch {{
|
|
76
|
+
psi.FileName = "python.exe";
|
|
77
|
+
Process.Start(psi);
|
|
78
|
+
return 0;
|
|
79
|
+
}}
|
|
80
|
+
}} else if (File.Exists(distExe)) {{
|
|
81
|
+
ProcessStartInfo psi = new ProcessStartInfo(distExe, joinedArgs);
|
|
82
|
+
psi.WorkingDirectory = baseDir;
|
|
83
|
+
psi.UseShellExecute = false;
|
|
84
|
+
Process.Start(psi);
|
|
85
|
+
return 0;
|
|
86
|
+
}} else {{
|
|
87
|
+
MessageBox.Show(
|
|
88
|
+
"Could not locate main.py or dist\\Happydownload.exe in " + baseDir,
|
|
89
|
+
"Happydownload v{__version__}",
|
|
90
|
+
MessageBoxButtons.OK,
|
|
91
|
+
MessageBoxIcon.Error
|
|
92
|
+
);
|
|
93
|
+
return 1;
|
|
94
|
+
}}
|
|
95
|
+
}} catch (Exception ex) {{
|
|
96
|
+
MessageBox.Show(
|
|
97
|
+
"Failed to launch Happydownload: " + ex.Message,
|
|
98
|
+
"Happydownload v{__version__}",
|
|
99
|
+
MessageBoxButtons.OK,
|
|
100
|
+
MessageBoxIcon.Error
|
|
101
|
+
);
|
|
102
|
+
return 1;
|
|
103
|
+
}}
|
|
104
|
+
}}
|
|
105
|
+
}}
|
|
106
|
+
}}
|
|
107
|
+
'''
|
|
108
|
+
cs_file = os.path.join(ROOT_DIR, "_launcher_build.cs")
|
|
109
|
+
try:
|
|
110
|
+
with open(cs_file, "w", encoding="utf-8") as f:
|
|
111
|
+
f.write(cs_source)
|
|
112
|
+
cmd = [
|
|
113
|
+
csc_bin,
|
|
114
|
+
"/nologo",
|
|
115
|
+
"/target:winexe",
|
|
116
|
+
"/optimize+",
|
|
117
|
+
f"/out:{out_exe}",
|
|
118
|
+
f"/win32icon:{ICON_PATH}",
|
|
119
|
+
"/reference:System.Windows.Forms.dll",
|
|
120
|
+
cs_file,
|
|
121
|
+
]
|
|
122
|
+
subprocess.run(cmd, check=True)
|
|
123
|
+
print(f"[OK] Built root Win32 launcher: {out_exe}")
|
|
124
|
+
finally:
|
|
125
|
+
if os.path.exists(cs_file):
|
|
126
|
+
os.remove(cs_file)
|
|
127
|
+
return out_exe
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def build_pyinstaller_standalone(bundle_ffmpeg: bool = False) -> str:
|
|
131
|
+
"""Build self-contained standalone `dist/Happydownload.exe` using PyInstaller."""
|
|
132
|
+
version_file = os.path.join(ROOT_DIR, "_pyi_version_info.txt")
|
|
133
|
+
v_parts = (__version__.split(".") + ["0", "0", "0"])[:4]
|
|
134
|
+
v_tuple = ", ".join(str(int(x)) for x in v_parts)
|
|
135
|
+
version_info_txt = f"""VSVersionInfo(
|
|
136
|
+
ffi=FixedFileInfo(
|
|
137
|
+
filevers=({v_tuple}),
|
|
138
|
+
prodvers=({v_tuple}),
|
|
139
|
+
mask=0x3f,
|
|
140
|
+
flags=0x0,
|
|
141
|
+
OS=0x40004,
|
|
142
|
+
fileType=0x1,
|
|
143
|
+
subtype=0x0,
|
|
144
|
+
date=(0, 0)
|
|
145
|
+
),
|
|
146
|
+
kids=[
|
|
147
|
+
StringFileInfo([
|
|
148
|
+
StringTable(
|
|
149
|
+
'040904B0',
|
|
150
|
+
[
|
|
151
|
+
StringStruct('CompanyName', '{__author__}'),
|
|
152
|
+
StringStruct('FileDescription', 'Happydownload v{__version__} — Adaptive 50+ GB & 4K Video Downloader'),
|
|
153
|
+
StringStruct('FileVersion', '{__version__}.0'),
|
|
154
|
+
StringStruct('InternalName', 'Happydownload'),
|
|
155
|
+
StringStruct('LegalCopyright', 'Copyright (c) 2026 {__author__}'),
|
|
156
|
+
StringStruct('OriginalFilename', 'Happydownload.exe'),
|
|
157
|
+
StringStruct('ProductName', 'Happydownload'),
|
|
158
|
+
StringStruct('ProductVersion', '{__version__}.0')
|
|
159
|
+
]
|
|
160
|
+
)
|
|
161
|
+
]),
|
|
162
|
+
VarFileInfo([VarStruct('Translation', [1033, 1200])])
|
|
163
|
+
]
|
|
164
|
+
)
|
|
165
|
+
"""
|
|
166
|
+
with open(version_file, "w", encoding="utf-8") as vf:
|
|
167
|
+
vf.write(version_info_txt)
|
|
168
|
+
|
|
169
|
+
cmd = [
|
|
170
|
+
sys.executable, "-m", "PyInstaller",
|
|
171
|
+
"--noconfirm",
|
|
172
|
+
"--clean",
|
|
173
|
+
"--onefile",
|
|
174
|
+
"--noconsole",
|
|
175
|
+
"--name", "Happydownload",
|
|
176
|
+
"--icon", ICON_PATH,
|
|
177
|
+
"--version-file", version_file,
|
|
178
|
+
"--add-data", f"{STATIC_DIR};happydownload/static",
|
|
179
|
+
"--collect-all", "yt_dlp",
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
if bundle_ffmpeg:
|
|
183
|
+
ff = find_ffmpeg()
|
|
184
|
+
if ff and os.path.isfile(ff):
|
|
185
|
+
print(f"Bundling ffmpeg.exe from: {ff}")
|
|
186
|
+
cmd.extend(["--add-binary", f"{ff};bin"])
|
|
187
|
+
|
|
188
|
+
cmd.append(os.path.join(ROOT_DIR, "main.py"))
|
|
189
|
+
try:
|
|
190
|
+
subprocess.run(cmd, cwd=ROOT_DIR, check=True)
|
|
191
|
+
finally:
|
|
192
|
+
if os.path.exists(version_file):
|
|
193
|
+
os.remove(version_file)
|
|
194
|
+
spec_file = os.path.join(ROOT_DIR, "Happydownload.spec")
|
|
195
|
+
if os.path.exists(spec_file):
|
|
196
|
+
os.remove(spec_file)
|
|
197
|
+
|
|
198
|
+
dist_exe = os.path.join(ROOT_DIR, "dist", "Happydownload.exe")
|
|
199
|
+
print(f"[OK] Built standalone PyInstaller executable: {dist_exe}")
|
|
200
|
+
return dist_exe
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def main() -> int:
|
|
204
|
+
parser = argparse.ArgumentParser(description="Build Happydownload .exe executables.")
|
|
205
|
+
parser.add_argument(
|
|
206
|
+
"--bundle-ffmpeg",
|
|
207
|
+
action="store_true",
|
|
208
|
+
help="Bundle ffmpeg.exe inside dist/Happydownload.exe (increases exe size above 100 MB).",
|
|
209
|
+
)
|
|
210
|
+
parser.add_argument(
|
|
211
|
+
"--launcher-only",
|
|
212
|
+
action="store_true",
|
|
213
|
+
help="Only build the lightweight root Happydownload.exe launcher.",
|
|
214
|
+
)
|
|
215
|
+
args = parser.parse_args()
|
|
216
|
+
|
|
217
|
+
build_native_root_launcher()
|
|
218
|
+
if not args.launcher_only:
|
|
219
|
+
build_pyinstaller_standalone(bundle_ffmpeg=args.bundle_ffmpeg)
|
|
220
|
+
return 0
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
if __name__ == "__main__":
|
|
224
|
+
sys.exit(main())
|