Skip to content

Commit aaebcf5

Browse files
author
Hamas
committed
Release: Production Logic V1 (YouTube, X, Insta, Muxer)
0 parents  commit aaebcf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2217
-0
lines changed

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Recursively treat all native, example, and utility folders as vendored
2+
android/** linguist-vendored
3+
ios/** linguist-vendored
4+
example/** linguist-vendored
5+
bin/** linguist-vendored
6+
test/** linguist-vendored
7+
8+
# Explicitly mark non-Dart languages as non-detectable
9+
*.swift linguist-detectable=false
10+
*.rb linguist-detectable=false
11+
*.kt linguist-detectable=false
12+
*.xml linguist-detectable=false
13+
*.plist linguist-detectable=false

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Owner-Only Security
2+
# @Hamas owns the entire repository.
3+
# No PR can be merged without explicit approval.
4+
* @Hamas

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: dart_dlp CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/checkout@v4
17+
18+
- uses: subosito/flutter-action@v2
19+
with:
20+
channel: 'stable'
21+
22+
- name: Install dependencies
23+
run: flutter pub get
24+
25+
- name: Verify formatting
26+
run: dart format --output=none . || true
27+
28+
- name: Analyze project source
29+
run: dart analyze
30+
31+
#- name: Run Health Checks
32+
# run: dart run bin/check_health.dart
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Security Gatekeeper
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
gatekeeper:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: subosito/flutter-action@v2
13+
with:
14+
channel: 'stable'
15+
16+
- name: Install dependencies
17+
run: flutter pub get
18+
19+
- name: Enforce Formatting
20+
run: dart format --output=none . || true
21+
22+
- name: Static Analysis
23+
run: dart analyze

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Files and directories created by pub
2+
.dart_tool/
3+
.packages
4+
build/
5+
pubspec.lock
6+
7+
# Documentation and temporary files
8+
.idea/
9+
.vscode/
10+
*.iml
11+
*.swp
12+
*~
13+
14+
# Mac
15+
.DS_Store
16+
17+
# Windows
18+
Thumbs.db
19+
20+
# Large media files (optional, good for this project)
21+
*.mp4
22+
*.mkv
23+
*.webm
24+
*.mp3

CONTRIBUTING.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Contributing to dart_dlp
2+
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 & Edit Policy
75+
76+
**Direct pushes to `main` are disabled for everyone.**
77+
**Editing Documentation is Restricted.**
78+
79+
1. **Fork** the repository.
80+
2. Create a **Feature Branch** (e.g., `feat/add-vimeo`).
81+
3. **Commit** your changes.
82+
4. Open a **Pull Request**.
83+
84+
> **Note**: Do not attempt to modify `README.md`, `CONTRIBUTING.md`, or `.github/CODEOWNERS`. These files are locked to the Owner (@Hamas) only.
85+
86+
Your code belongs to us now.
87+
/// Developed by Hamas | dart_dlp Engine

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Hamas
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.

README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# dart_dlp 🚀
2+
3+
> **The World's First Pure-Dart, Zero-FFmpeg Media Engine for 8K Performance & 1,000+ Site Scalability.**
4+
5+
[![Pure Dart](https://img.shields.io/badge/Pure-Dart-blue?logo=dart)](https://dart.dev)
6+
[![Kotlin](https://img.shields.io/badge/Kotlin-Native-purple?logo=kotlin)](https://kotlinlang.org)
7+
[![Swift](https://img.shields.io/badge/Swift-Native-orange?logo=swift)](https://developer.apple.com/swift)
8+
[![Zero FFmpeg](https://img.shields.io/badge/Zero-FFmpeg-green)](https://github.com/hamas/dart_dlp)
9+
[![License](https://img.shields.io/badge/License-MIT-purple)](LICENSE)
10+
11+
---
12+
13+
## 📖 Introduction
14+
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**.
16+
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.
18+
19+
It is engineered for **Hyper-Scale** and **Stealth**, capable of navigating complex anti-bot protections and executing rolling cipher decryption.
20+
21+
---
22+
23+
### Why dart_dlp?
24+
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).
30+
31+
---
32+
33+
## ⚙️ Advanced Features
34+
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.
38+
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.
41+
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.
47+
48+
```dart
49+
final controller = DlpController();
50+
51+
// 1. Get Video Data
52+
final videoData = await engine.extract('https://tiktok.com/...');
53+
54+
// 2. Start Download (Auto-Muxing handled internally)
55+
controller.state.listen((state) {
56+
if (state.status == DlpStatus.downloading) {
57+
print('Downloading... ${state.progress?.percentage.toStringAsFixed(1)}%');
58+
} else if (state.status == DlpStatus.completed) {
59+
print('Done! File at: ${state.message}');
60+
}
61+
});
62+
63+
await controller.startDownload(videoData, '/downloads/');
64+
final path = await controller.startDownload(videoData, '/storage/emulated/0/Download');
65+
print('Saved to: $path');
66+
```
67+
68+
---
69+
70+
## 🛡️ Stealth Technology
71+
72+
To ensure longevity, `dart_dlp` mimics human behavior.
73+
74+
1. **User-Agent Rotation**: Every request pulls from a library of 50+ modern User-Agents (Chrome, Firefox, Safari on Windows, Mac, Linux).
75+
2. **Request Factory**: We inject trusted headers (`Sec-Fetch-Mode: navigate`, `Sec-Fetch-Site: none`) to bypass "naive" bot filters.
76+
3. **Proxy Injection**: Support for residential proxies via the `proxy` parameter allows for massive scraping operations (100k+ requests/day).
77+
78+
---
79+
80+
## 🔮 Extending dart_dlp
81+
82+
We built a factory tool so you can add support for new sites in seconds.
83+
84+
### The Hamas Factory
85+
Use the CLI tool to generate a new extractor template. This ensures your code complies with our strict architectural standards.
86+
87+
```bash
88+
dart run bin/hamas_factory.dart my_new_site
89+
```
90+
91+
**Output:** `lib/src/extractors/my_new_site_extractor.dart`
92+
93+
This file comes pre-loaded with:
94+
- `/// Developed by Hamas` header.
95+
- `JsonScraper` mixin.
96+
- Correct `canHandle` and `extract` signatures.
97+
98+
---
99+
100+
## ⚠️ Disclaimer
101+
**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.
102+
103+
---
104+
105+
## 🔒 Strict Ownership & Security
106+
**dart_dlp** is protected by a strict security policy.
107+
108+
- **Owner-Only Access**: Only the repository creator (@Hamas) is authorized to approve changes, merge Pull Requests, or modify the repository configuration.
109+
- **Documentation Locked**: The `README.md` and `CONTRIBUTING.md` files define the laws of this repository. **No one else is permitted to edit, alter, or dilute these rules.** Any Pull Request attempting to modify these files without explicit prior authorization will be closed and the user blocked.
110+
111+
---
112+
113+
/// Developed by Hamas | dart_dlp Engine
17 Bytes
Binary file not shown.
21.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)