|
3 | 3 | > **The World's First Pure-Dart, Zero-FFmpeg Media Engine for 8K Performance & 1,000+ Site Scalability.** |
4 | 4 |
|
5 | 5 | [](https://dart.dev) |
| 6 | +[](https://kotlinlang.org) |
| 7 | +[](https://developer.apple.com/swift) |
6 | 8 | [](https://github.com/hamas/dart_dlp) |
7 | 9 | [](LICENSE) |
8 | 10 |
|
9 | 11 | --- |
10 | 12 |
|
11 | 13 | ## 📖 Introduction |
12 | 14 |
|
13 | | -**dart_dlp** is a revolutionary media extraction engine designed to liberate Dart and Flutter developers from the constraints of heavy external binaries. Unlike traditional solutions that wrap `yt-dlp` (Python) or require massive `ffmpeg` bundles, `dart_dlp` is built from the ground up in **100% Pure Dart**. |
| 15 | +**dart_dlp** is a revolutionary media extraction engine designed to liberate Dart and Flutter developers from the constraints of heavy external binaries. Unlike traditional solutions that wrap `yt-dlp` (Python) or require massive `ffmpeg` bundles, `dart_dlp` is built from the ground up to be **Lightweight and Invincible**. |
14 | 16 |
|
15 | | -It is engineered for **Hyper-Scale** and **Stealth**, capable of navigating complex anti-bot protections, executing rolling cipher decryption natively, and delivering 8K video streams without a single byte of compiled native code. |
| 17 | +It combines a **Pure Dart** extraction core with a **Native (Kotlin/Swift)** muxing bridge, delivering 8K video streams without a single byte of compiled FFmpeg or Python code. |
16 | 18 |
|
17 | | -### Why dart_dlp? |
18 | | - |
19 | | -1. **Zero Dependencies**: No Python, no node.js, no FFMPEG binaries required to *run*. |
20 | | -2. **Native Performance**: Everything happens in the Dart VM. |
21 | | -3. **HamasDownloader™**: A proprietary, multi-threaded chunked downloader that saturates your bandwidth by opening parallel connections. |
22 | | -4. **Stealth Mode**: Rotates between 50+ real-world User-Agents and injects human-like HTTP headers (`Sec-Fetch-*`) to evade IP blocking. |
23 | | -5. **Architecture**: Decoupled design allows you to run this on a server, in a CLI, or embedded directly in a Flutter app. |
24 | | - |
25 | | ---- |
26 | | - |
27 | | -## ✅ Supported Platforms |
28 | | - |
29 | | -The engine comes pre-loaded with highly optimized extractors for the "Major 5" social giants, plus generic extendability. |
30 | | - |
31 | | -| Platform | Features | Stealth Level | |
32 | | -| :--- | :--- | :--- | |
33 | | -| **YouTube** | 8K/4K/1080p, Rolling Cipher Decryption (JS), Separate Audio/Video Streams | 🛡️ High | |
34 | | -| **TikTok** | Watermark-free Video, JSON Rehydration parsing | 🛡️ Medium | |
35 | | -| **Instagram** | `window._sharedData` parsing, Reels & Posts | 🛡️ High | |
36 | | -| **Facebook** | SD/HD Source Extraction, Regex-based parsing | 🛡️ Medium | |
37 | | -| **X (Twitter)** | `__NEXT_DATA__` Traversal | 🛡️ High | |
38 | | -| **Reddit** | Native JSON API (`.json`) extraction | 🛡️ Low | |
39 | | -| **Pinterest** | `__PWS_DATA__` extraction | 🛡️ Medium | |
| 19 | +It is engineered for **Hyper-Scale** and **Stealth**, capable of navigating complex anti-bot protections and executing rolling cipher decryption. |
40 | 20 |
|
41 | 21 | --- |
42 | 22 |
|
43 | | -## 📦 Installation |
44 | | - |
45 | | -Since `dart_dlp` is a premium, high-performance engine, it is distributed via Git to ensure you always have the latest anti-censorship patches. |
46 | | - |
47 | | -Add this to your `pubspec.yaml`: |
48 | | - |
49 | | -```yaml |
50 | | -dependencies: |
51 | | - dart_dlp: |
52 | | - git: |
53 | | - url: https://github.com/hamas/dart_dlp.git |
54 | | - ref: main |
55 | | -``` |
56 | | -
|
57 | | -Run the installation: |
| 23 | +### Why dart_dlp? |
58 | 24 |
|
59 | | -```bash |
60 | | -dart pub get |
61 | | -``` |
| 25 | +1. **Zero External Binaries**: No Python, no node.js. |
| 26 | +2. **Native Muxing**: Uses Android's `MediaMuxer` and iOS's `AVAssetExportSession` to merge 4K video+audio instantly (Zero-Encoding). |
| 27 | +3. **HamasDownloader™**: A proprietary, multi-threaded chunked downloader that saturates your bandwidth by opening parallel connections. |
| 28 | +4. **Stealth Mode**: Rotates between 50+ real-world User-Agents and injects human-like HTTP headers (`Sec-Fetch-*`) to evade IP blocking. |
| 29 | +5. **Architecture**: Decoupled design allows for pure Dart usage (extraction only) or full Flutter Plugin power (muxing enabled). |
62 | 30 |
|
63 | 31 | --- |
64 | 32 |
|
65 | | -## 🛠️ Usage & Architecture |
66 | | - |
67 | | -The system is composed of three core pillars: **The Engine**, **The Extractor**, and **The Downloader**. |
68 | | - |
69 | | -### 1. The DlpEngine (The Brain) |
70 | | - |
71 | | -The `DlpEngine` is the central command dispatcher. It accepts a raw URL, identifies the correct registered extractor, and routes the request. |
72 | | - |
73 | | -**Initialization:** |
74 | | - |
75 | | -```dart |
76 | | -import 'package:dart_dlp/dart_dlp.dart'; |
77 | | -
|
78 | | -// Create the engine |
79 | | -final engine = DlpEngine(); |
80 | | -``` |
81 | | - |
82 | | -**Stealth Configuration:** |
83 | | -To avoid IP bans when scraping thousands of urls, pass a proxy: |
84 | | - |
85 | | -```dart |
86 | | -final engine = DlpEngine(proxy: 'http://user:[email protected]:8080'); |
87 | | -// This proxy is automatically propagated to every extractor. |
88 | | -``` |
89 | | - |
90 | | -### 2. Analysis & Extraction |
91 | | - |
92 | | -Calling `extract` returns a `VideoData` object. This object is a normalized representation of the media, regardless of whether it came from YouTube, TikTok, or Reddit. |
93 | | - |
94 | | -```dart |
95 | | -try { |
96 | | - final url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'; |
97 | | - |
98 | | - // The engine automatically executes JS decryption if needed |
99 | | - final VideoData video = await engine.extract(url); |
100 | | -
|
101 | | - print('Title: ${video.title}'); |
102 | | - print('Duration: ${video.duration}'); |
103 | | - print('Thumbnail: ${video.thumbnail}'); |
104 | | - |
105 | | - // Inspect available qualities |
106 | | - for (var stream in video.streams) { |
107 | | - print('[${stream.quality}] ${stream.format} - ${stream.url}'); |
108 | | - } |
109 | | -} catch (e) { |
110 | | - print('Extraction failed: $e'); |
111 | | -} |
112 | | -``` |
113 | | - |
114 | | -### 3. The HamasDownloader (The Muscle) |
| 33 | +## ⚙️ Advanced Features |
115 | 34 |
|
116 | | -Standard HTTP requests are slow. `dart_dlp` ships with `HamasDownloader`, a specialized tool that uses **HTTP Range Headers** to download file chunks in parallel. |
| 35 | +### ⚡ HD Download & Native Muxing (The "Super" Pattern) |
| 36 | +YouTube (and others) often serve 1080p+ video as separate Video and Audio tracks. |
| 37 | +`dart_dlp` handles this automatically using its Native Bridge. |
117 | 38 |
|
118 | | -```dart |
119 | | -// 1. Select the best stream (e.g., 1080p video) |
120 | | -final stream = video.streams.firstWhere((s) => s.quality == '1080p'); |
121 | | -
|
122 | | -// 2. Initialize Downloader |
123 | | -final downloader = HamasDownloader(); |
124 | | -
|
125 | | -// 3. Start Download |
126 | | -await downloader.download( |
127 | | - stream.url, |
128 | | - 'path/to/video.mp4', |
129 | | - onProgress: (DownloadProgress progress) { |
130 | | - // Real-time stats |
131 | | - final percent = (progress.progress * 100).toStringAsFixed(1); |
132 | | - final speed = progress.speedMBps.toStringAsFixed(2); |
133 | | - final eta = progress.etaSeconds; |
134 | | - |
135 | | - print('$percent% downloaded | Speed: $speed MB/s | ETA: ${eta}s'); |
136 | | - } |
137 | | -); |
138 | | -``` |
| 39 | +**Zero-FFmpeg Requirement:** |
| 40 | +We utilize the device's native APIs (`MediaMuxer` on Android, `AVAssetExportSession` on iOS) to merge streams instantly without re-encoding. This keeps the app size tiny only adding ~20KB to your bundle, compared to FFmpeg's ~50MB. |
139 | 41 |
|
140 | | -### 4. DlpController (State Management) |
141 | | -For Flutter apps usage, `DlpController` provides a reactive stream of state changes (`analyzing`, `downloading`, `merging`, `completed`, `error`). |
| 42 | +**How it works:** |
| 43 | +1. **Detects** if a video is split (e.g., 4K stream). |
| 44 | +2. **Downloads** video and audio tracks concurrently. |
| 45 | +3. **Invokes** the Native Bridge to merge them in seconds. |
| 46 | +4. **Cleans up** temporary files. |
142 | 47 |
|
143 | 48 | ```dart |
144 | 49 | final controller = DlpController(); |
145 | | -controller.stateStream.listen((state) { |
146 | | - if (state.status == DlpStatus.downloading) { |
147 | | - print('Downloading... ${state.progress}%'); |
148 | | - } else if (state.status == DlpStatus.completed) { |
149 | | - print('Done! File at: ${state.message}'); |
| 50 | +
|
| 51 | +// Listen to status updates (Extracting -> Downloading -> Merging -> Completed) |
| 52 | +controller.state.listen((state) { |
| 53 | + print('[${state.status}] ${state.message}'); |
| 54 | + if (state.status == DlpStatus.merging) { |
| 55 | + print('Merging Video & Audio streams...'); |
150 | 56 | } |
151 | 57 | }); |
152 | 58 |
|
153 | | -// One-liner execution |
154 | | -controller.process('https://tiktok.com/...', '/downloads/'); |
155 | | -``` |
156 | | - |
157 | | ---- |
158 | | - |
159 | | -## ⚙️ Advanced Features |
160 | | - |
161 | | -### Handling Split Streams (The "NativeMuxer" Pattern) |
162 | | -YouTube (and others) often serve 1080p+ video as separate Video and Audio tracks. |
163 | | -`dart_dlp` detects this automatically. |
164 | | - |
165 | | -In **Pure Dart Mode**, the `NativeMuxer` is a no-op interface. The controller will download **both** files and return their paths. |
166 | | - |
167 | | -```text |
168 | | -Result: |
169 | | -- video_1080p.mp4 (Video Only) |
170 | | -- audio_128k.m4a (Audio Only) |
| 59 | +// Start the Magic (Auto-Muxing included) |
| 60 | +final path = await controller.startDownload(videoData, '/storage/emulated/0/Download'); |
| 61 | +print('Saved to: $path'); |
171 | 62 | ``` |
172 | 63 |
|
173 | | -It is up to your application layer (Server or Client) to invoke `ffmpeg` or `mkvmerge` if you wish to combine them. This keeps `dart_dlp` lightweight and portable. |
174 | | - |
175 | | -### Rolling Cipher Decryption |
176 | | -YouTube protects high-value streams with a "Rolling Cipher" in their JavaScript. |
177 | | -`dart_dlp` includes a **JS Execution Engine** (via `flutter_js` or pure Regex parsing) that: |
178 | | -1. Downloads the player JavaScript. |
179 | | -2. Parses the obfuscated decryption functions. |
180 | | -3. Executes the math to solve the signature challenge. |
181 | | -4. Unlocks the 4K stream URL. |
182 | | - |
183 | | -All of this happens transparently inside `YouTubeExtractor`. |
184 | | - |
185 | 64 | --- |
186 | 65 |
|
187 | 66 | ## 🛡️ Stealth Technology |
|
0 commit comments