Skip to content

Commit 0e7e87b

Browse files
author
Hamas
committed
Final Release: Major 5 Extractors, Stealth Mode, and Documentation Overhaul
1 parent 90fa5f6 commit 0e7e87b

14 files changed

+638
-95
lines changed

CONTRIBUTING.md

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,84 @@
11
# Contributing to dart_dlp
22

3-
## 🔒 Security & Access
4-
- **Direct pushes to main are disabled.** All contributions must be made via sub-branches and Pull Requests.
5-
- **Only the repository owner (Hamas) has direct push access to the main branch.**
6-
7-
## Code Standards
8-
- All Pull Requests must pass the `Security Gatekeeper` check (Format & Analyze).
9-
- Code must be properly branded with `/// Developed by Hamas`.
10-
11-
## Workflow
12-
1. Fork the repository.
13-
2. Create a feature branch.
14-
3. Submit a Pull Request.
15-
4. Wait for approval from @Hamas.
3+
> **Strict Security Protocols in Effect**
4+
5+
Thank you for your interest in `dart_dlp`. This is the world's most performant pure-Dart media engine, and we intend to keep it that way. To maintain the integrity, stability, and security of the codebase, we enforce a strict **Zero-Trust** contribution model.
6+
7+
## 🔒 Security Gatekeeper & CI
8+
9+
We use automated pipelines to vet every line of code before it reaches human review.
10+
11+
### 1. The Security Gatekeeper (`security_check.yml`)
12+
Every Pull Request triggers the Gatekeeper. It performs the following inspections:
13+
- **Static Analysis**: Runs `dart analyze` to ensure 0% linting errors.
14+
- **Format Verification**: Runs `dart format --output=none --set-exit-if-changed .` to enforce the Dart style guide.
15+
16+
**If the Gatekeeper fails, your PR is automatically rejected.** Do not waste time asking for a review until the check turns Green.
17+
18+
### 2. The Mass Health Monitor
19+
We maintain a registry of 1,000+ live test URLs (`test/samples.json`).
20+
Before submitting a PR, you **MUST** run the health monitor locally:
21+
22+
```bash
23+
dart run bin/check_health.dart
24+
```
25+
26+
This script spins up a concurrent engine and tests every single supported site. If your change breaks an unrelated extractor (e.g., your Reddit fix broke YouTube), the monitor will scream in **RED**.
27+
28+
**Do not submit broken code.**
29+
30+
---
31+
32+
## 🚫 Restricted Zones
33+
34+
### The Core (`lib/src/core/`)
35+
**Status: LOCKED 🔒**
36+
37+
- **Owner**: @Hamas
38+
- **Policy**: No external modifications allowed.
39+
40+
This directory contains the `DlpEngine`, `HamasDownloader`, and `DlpController`. These are finely tuned, high-performance components. Drive-by refactors or "adjustments" to this folder will be closed immediately. If you believe there is a critical bug in the core, open an Issue first.
41+
42+
**Code Owners (`.github/CODEOWNERS`) is configured to enforce this.**
43+
44+
---
45+
46+
## ✅ How to Contribute New Sites
47+
48+
We love new extractors! But you must follow our procedure.
49+
50+
### 1. Use the Factory
51+
Do not manually copy-paste files. Use our generator tool to create a compliant starting point:
52+
53+
```bash
54+
dart run bin/hamas_factory.dart <site_name>
55+
```
56+
57+
This ensures:
58+
- Correct File Header (`/// Developed by Hamas`)
59+
- Proper Class Naming
60+
- Integration with `UserAgentManager`
61+
- Inheritance from `BaseExtractor`
62+
63+
### 2. Implementation Rules
64+
- **Parsing**: Prefer `JsonScraper` (Regex/JSON) over HTML DOM parsing where possible. DOM parsing is slow and brittle.
65+
- **Network**: Always use `headers: {'User-Agent': UserAgentManager.random}` for every request.
66+
- **Errors**: Throw clear exceptions (e.g., `SiteNotSupportedException`, `AccountPrivateException`).
67+
68+
### 3. Register It
69+
- Add your new extractor export to `lib/dart_dlp.dart`.
70+
- Add a test URL to `test/samples.json`.
71+
72+
---
73+
74+
## 📜 Branch Policy
75+
76+
**Direct pushes to `main` are disabled for everyone.**
77+
78+
1. **Fork** the repository.
79+
2. Create a **Feature Branch** (e.g., `feat/add-vimeo`).
80+
3. **Commit** your changes.
81+
4. Open a **Pull Request**.
82+
83+
Your code belongs to us now.
84+
/// Developed by Hamas | dart_dlp Engine

GITHUB_SETUP.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 197 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,222 @@
1-
# dart_dlp
1+
# dart_dlp 🚀
22

3-
> [!WARNING]
4-
> **RESTRICTED EDITING**
5-
> This file is maintained solely by the project owner. **DO NOT EDIT THIS FILE.**
6-
> Unauthorized changes will be reverted.
3+
> **The World's First Pure-Dart, Zero-FFmpeg Media Engine for 8K Performance & 1,000+ Site Scalability.**
74
8-
**dart_dlp** is a high-performance, pure Dart media extraction engine. It is designed to be a lightweight, dependency-free (mostly) alternative to other media extractors, built specifically for the Dart ecosystem.
5+
[![Pure Dart](https://img.shields.io/badge/Pure-Dart-blue?logo=dart)](https://dart.dev)
6+
[![Zero FFmpeg](https://img.shields.io/badge/Zero-FFmpeg-green)](https://github.com/hamas/dart_dlp)
7+
[![License](https://img.shields.io/badge/License-MIT-purple)](LICENSE)
98

10-
## Features
9+
---
10+
11+
## 📖 Introduction
12+
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**.
14+
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.
16+
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+
---
1126

12-
- **Pure Dart**: Logic is written in Dart for maximum compatibility with Flutter and specialized Dart environments.
13-
- **Extensible**: Architecture designed for easy addition of new site extractors.
14-
- **Efficient**: Minimal dependencies and optimized for performance.
27+
## ✅ Supported Platforms
1528

16-
## Installation
29+
The engine comes pre-loaded with highly optimized extractors for the "Major 5" social giants, plus generic extendability.
1730

18-
Add this to your package's `pubspec.yaml` file:
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 |
40+
41+
---
42+
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`:
1948

2049
```yaml
2150
dependencies:
2251
dart_dlp:
23-
path: /path/to/dart_dlp
52+
git:
53+
url: https://github.com/hamas/dart_dlp.git
54+
ref: main
55+
```
56+
57+
Run the installation:
58+
59+
```bash
60+
dart pub get
2461
```
2562

26-
## Usage
63+
---
64+
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:**
2774

2875
```dart
2976
import 'package:dart_dlp/dart_dlp.dart';
3077
31-
void main() async {
32-
// Example usage
33-
// final extractor = YoutubeExtractor();
34-
// if (extractor.canHandle(url)) {
35-
// final videoData = await extractor.extract(url);
36-
// print(videoData.title);
37-
// }
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');
38111
}
39112
```
40113

41-
## Architecture
114+
### 3. The HamasDownloader (The Muscle)
42115

43-
The project is structured to separate concerns:
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.
44117

45-
- `lib/src/extractors/`: Contains site-specific extraction logic. All extractors extend `BaseExtractor`.
46-
- `lib/src/models/`: Data models like `VideoData` and `StreamInfo`.
47-
- `lib/src/core/`: Application logic and dispatching.
48-
- `lib/src/muxer/`: Handling media merging and processing.
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+
```
139+
140+
### 4. DlpController (State Management)
141+
For Flutter apps usage, `DlpController` provides a reactive stream of state changes (`analyzing`, `downloading`, `merging`, `completed`, `error`).
142+
143+
```dart
144+
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}');
150+
}
151+
});
152+
153+
// One-liner execution
154+
controller.process('https://tiktok.com/...', '/downloads/');
155+
```
156+
157+
---
158+
159+
## ⚙️ Advanced Features
49160

50-
## 👨‍💻 Author
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.
51164

52-
**Built by Hamas**
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)
171+
```
172+
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`.
53184

54185
---
55-
© 2026 Hamas. All Rights Reserved.
186+
187+
## 🛡️ Stealth Technology
188+
189+
To ensure longevity, `dart_dlp` mimics human behavior.
190+
191+
1. **User-Agent Rotation**: Every request pulls from a library of 50+ modern User-Agents (Chrome, Firefox, Safari on Windows, Mac, Linux).
192+
2. **Request Factory**: We inject trusted headers (`Sec-Fetch-Mode: navigate`, `Sec-Fetch-Site: none`) to bypass "naive" bot filters.
193+
3. **Proxy Injection**: Support for residential proxies via the `proxy` parameter allows for massive scraping operations (100k+ requests/day).
194+
195+
---
196+
197+
## 🔮 Extending dart_dlp
198+
199+
We built a factory tool so you can add support for new sites in seconds.
200+
201+
### The Hamas Factory
202+
Use the CLI tool to generate a new extractor template. This ensures your code complies with our strict architectural standards.
203+
204+
```bash
205+
dart run bin/hamas_factory.dart my_new_site
206+
```
207+
208+
**Output:** `lib/src/extractors/my_new_site_extractor.dart`
209+
210+
This file comes pre-loaded with:
211+
- `/// Developed by Hamas` header.
212+
- `JsonScraper` mixin.
213+
- Correct `canHandle` and `extract` signatures.
214+
215+
---
216+
217+
## ⚠️ Disclaimer
218+
**dart_dlp** is an educational tool designed for interoperability and data portability. Use this engine responsibly and respect the Terms of Service of the platforms you interact with.
219+
220+
---
221+
222+
/// Developed by Hamas | dart_dlp Engine

0 commit comments

Comments
 (0)