mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-27 19:35:06 +00:00
Compare commits
6
Commits
5899c1eec8
...
5.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3dcc584b2f | ||
|
|
538deac63e | ||
|
|
0561623825 | ||
|
|
4ce0dd5bb9 | ||
|
|
191c4f47e0 | ||
|
|
accfe9cee1 |
+14
-2
@@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
|
|
||||||
This changelog is automatically generated using [git-cliff](https://git-cliff.org).
|
This changelog is automatically generated using [git-cliff](https://git-cliff.org).
|
||||||
|
|
||||||
## [5.1.0] - 2026-05-26
|
## [5.1.0] - 2026-05-29
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
@@ -22,6 +22,8 @@ This changelog is automatically generated using [git-cliff](https://git-cliff.or
|
|||||||
- *dl*: Gate s_lang/a_lang miss behind --best-available
|
- *dl*: Gate s_lang/a_lang miss behind --best-available
|
||||||
- *dl*: Add real bitrate probing (-rvb/-rab)
|
- *dl*: Add real bitrate probing (-rvb/-rab)
|
||||||
- *import*: Reconstruct downloads from an --export sidecar
|
- *import*: Reconstruct downloads from an --export sidecar
|
||||||
|
- *naming*: Per-service title_map remapping
|
||||||
|
- *import*: Include cover-art attachments in --export/--import
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
@@ -41,16 +43,25 @@ This changelog is automatically generated using [git-cliff](https://git-cliff.or
|
|||||||
- *vaults*: Enable WAL on SQLite vault to fix concurrent locks
|
- *vaults*: Enable WAL on SQLite vault to fix concurrent locks
|
||||||
- *hybrid*: Correct static L6 source and reset stale L5 active area
|
- *hybrid*: Correct static L6 source and reset stale L5 active area
|
||||||
- *cli*: Report broken command/service loads once and cleanly
|
- *cli*: Report broken command/service loads once and cleanly
|
||||||
|
- *hls*: Resolve per-rendition KID in no-EXT-X-KEY fallback
|
||||||
|
- *dash*: Inherit SegmentTemplate attributes across AdaptationSet/Representation
|
||||||
|
- *dl*: Mux all requested ranges and select highest DV alongside hybrid
|
||||||
|
- *session*: Proxy auth on http targets and string params support
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
- Update docs to match current codebase
|
- Update docs to match current codebase
|
||||||
- *output*: Document muxing.default_language override
|
- *output*: Document muxing.default_language override
|
||||||
|
- Simplify README with demo and requirements
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
- *routes, subtitle, track*: Improve code readability by formatting list structures
|
- *routes, subtitle, track*: Improve code readability by formatting list structures
|
||||||
- *hybrid*: Extract dovi_tool and run_step helpers
|
- *hybrid*: Extract dovi_tool and run_step helpers
|
||||||
|
- *ip_info*: Simplify lookup and trim cache
|
||||||
|
- *example*: Showcase full unshackle feature surface
|
||||||
|
- *dl*: Declare hybrid_base_only flag and extract standalone mux helper
|
||||||
|
- Remove dead aria2c and n_m3u8dl_re downloader code
|
||||||
|
|
||||||
### Maintenance
|
### Maintenance
|
||||||
|
|
||||||
@@ -123,6 +134,7 @@ This changelog is automatically generated using [git-cliff](https://git-cliff.or
|
|||||||
|
|
||||||
### Maintenance
|
### Maintenance
|
||||||
|
|
||||||
|
- *gitignore*: Ignore binary files in unshackle/binaries/
|
||||||
- Update version to 5.0.0
|
- Update version to 5.0.0
|
||||||
|
|
||||||
## [4.0.0] - 2026-03-17
|
## [4.0.0] - 2026-03-17
|
||||||
@@ -673,7 +685,7 @@ This changelog is automatically generated using [git-cliff](https://git-cliff.or
|
|||||||
- Reorganize Planned Features section in README for clarity
|
- Reorganize Planned Features section in README for clarity
|
||||||
- Improve track selection logic in dl.py
|
- Improve track selection logic in dl.py
|
||||||
|
|
||||||
[5.1.0]: https://github.com/unshackle-dl/unshackle/compare/5.0.0..5.1.0
|
[unreleased]: https://github.com/unshackle-dl/unshackle/compare/5.0.0..HEAD
|
||||||
[5.0.0]: https://github.com/unshackle-dl/unshackle/compare/4.0.0..5.0.0
|
[5.0.0]: https://github.com/unshackle-dl/unshackle/compare/4.0.0..5.0.0
|
||||||
[4.0.0]: https://github.com/unshackle-dl/unshackle/compare/3.0.0..4.0.0
|
[4.0.0]: https://github.com/unshackle-dl/unshackle/compare/3.0.0..4.0.0
|
||||||
[3.0.0]: https://github.com/unshackle-dl/unshackle/compare/2.3.0..3.0.0
|
[3.0.0]: https://github.com/unshackle-dl/unshackle/compare/2.3.0..3.0.0
|
||||||
|
|||||||
@@ -8,102 +8,45 @@
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## What is unshackle?
|
<p align="center">
|
||||||
|
<a href="#install">Install</a> ·
|
||||||
|
<a href="https://github.com/unshackle-dl/unshackle/wiki">Wiki</a> ·
|
||||||
|
<a href="docs/">Docs</a> ·
|
||||||
|
<a href="https://discord.gg/mHYyPaCbFK">Discord</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
unshackle is a fork of [Devine](https://github.com/devine-dl/devine/), a powerful archival tool for downloading movies, TV shows, and music from streaming services. Built with a focus on modularity and extensibility, it provides a robust framework for content acquisition with support for DRM-protected content.
|
---
|
||||||
|
|
||||||
## Key Features
|
A modular archival tool for movies, TV, and music. Fork of [Devine](https://github.com/devine-dl/devine/) with DASH/HLS/ISM parsing, Widevine & PlayReady DRM, and a REST API.
|
||||||
|
|
||||||
- 🚀 **Easy Installation** - Simple UV installation
|
<p align="center">
|
||||||
- 🎥 **Multi-Media Support** - Movies, TV episodes, and music
|
<a href="https://asciinema.org/a/ldMiqYFFTgPAOxW7">
|
||||||
- 🛠️ **Built-in Parsers** - DASH/HLS and ISM manifest support
|
<img src="https://asciinema.org/a/ldMiqYFFTgPAOxW7.svg" alt="unshackle demo" width="700">
|
||||||
- 🔒 **DRM Support** - Widevine and PlayReady integration
|
</a>
|
||||||
- 🌈 **HDR10+DV Hybrid** - Hybrid Dolby Vision injection via [dovi_tool](https://github.com/quietvoid/dovi_tool)
|
</p>
|
||||||
- 💾 **Flexible Storage** - Local and remote key vaults
|
|
||||||
- 👥 **Multi-Profile Auth** - Support for cookies and credentials
|
|
||||||
- 🤖 **Smart Naming** - Automatic P2P-style filename structure
|
|
||||||
- ⚙️ **Configurable** - YAML-based configuration
|
|
||||||
- ❤️ **Open Source** - Fully open-source with community contributions welcome
|
|
||||||
|
|
||||||
## Quick Start
|
## Install
|
||||||
|
|
||||||
### Installation
|
|
||||||
|
|
||||||
This installs the latest version directly from the GitHub repository:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/unshackle-dl/unshackle.git
|
|
||||||
cd unshackle
|
|
||||||
uv sync
|
|
||||||
uv run unshackle --help
|
|
||||||
```
|
|
||||||
|
|
||||||
### Install unshackle as a global (per-user) tool
|
|
||||||
|
|
||||||
```bash
|
|
||||||
uv tool install git+https://github.com/unshackle-dl/unshackle.git
|
uv tool install git+https://github.com/unshackle-dl/unshackle.git
|
||||||
# Then run:
|
unshackle --help
|
||||||
uvx unshackle --help # or just `unshackle` once PATH updated
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> After installation, you may need to add the installation path to your PATH environment variable if prompted.
|
> Prefer `uv run unshackle ...` inside a clone to keep the virtual environment active.
|
||||||
|
|
||||||
> **Recommended:** Use `uv run unshackle` instead of direct command execution to ensure proper virtual environment activation.
|
### Requirements
|
||||||
|
|
||||||
## Planned Features
|
External tools on your `PATH` (recommended versions):
|
||||||
|
|
||||||
- 🖥️ **Web UI Access & Control** - Manage and control unshackle from a modern web interface.
|
- [Python](https://www.python.org/) - 3.10 - 3.12
|
||||||
- 🔄 **Sonarr/Radarr Interactivity** - Direct integration for automated personal downloads.
|
- [uv](https://docs.astral.sh/uv/) - ≥ 0.5
|
||||||
- ⚙️ **Better ISM Support** - Improve on ISM support for multiple services
|
- [FFmpeg](https://ffmpeg.org/) - ≥ 6.0
|
||||||
- 🔉 **ATMOS** - Better Atmos Support/Selection
|
- [MKVToolNix](https://mkvtoolnix.download/) - ≥ 80
|
||||||
- 🎵 **Music** - Cleanup Audio Tagging using the [tags.py](unshackle/core/utils/tags.py) for artist/track name etc.
|
- [shaka-packager](https://github.com/shaka-project/shaka-packager/releases/tag/v2.6.1) - 2.6.1
|
||||||
|
- [Bento4](https://github.com/axiomatic-systems/Bento4) - ≥ 1.6.0-639
|
||||||
|
- [dovi_tool](https://github.com/quietvoid/dovi_tool) - ≥ 2.1
|
||||||
|
|
||||||
### Basic Usage
|
## License
|
||||||
|
|
||||||
```shell
|
[GPL-3.0](LICENSE). Do not use unshackle for content you lack the rights to. Keep the core free and open; keep service code private. Be kind.
|
||||||
# Check available commands
|
|
||||||
uv run unshackle --help
|
|
||||||
|
|
||||||
# Configure your settings
|
|
||||||
git clone https://github.com/unshackle-dl/unshackle.git
|
|
||||||
cd unshackle
|
|
||||||
uv sync
|
|
||||||
uv run unshackle --help
|
|
||||||
|
|
||||||
# Download content (requires configured services)
|
|
||||||
uv run unshackle dl SERVICE_NAME CONTENT_ID
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
For comprehensive setup guides, configuration options, and advanced usage:
|
|
||||||
|
|
||||||
📖 **[Visit our WIKI](https://github.com/unshackle-dl/unshackle/wiki)**
|
|
||||||
|
|
||||||
The WIKI contains detailed information on:
|
|
||||||
|
|
||||||
- Service configuration
|
|
||||||
- DRM configuration
|
|
||||||
- Advanced features and troubleshooting
|
|
||||||
|
|
||||||
For guidance on creating services, see our [WIKI documentation](https://github.com/unshackle-dl/unshackle/wiki).
|
|
||||||
|
|
||||||
## End User License Agreement
|
|
||||||
|
|
||||||
unshackle and it's community pages should be treated with the same kindness as other projects.
|
|
||||||
Please refrain from spam or asking for questions that infringe upon a Service's End User License Agreement.
|
|
||||||
|
|
||||||
1. Do not use unshackle for any purposes of which you do not have the rights to do so.
|
|
||||||
2. Do not share or request infringing content; this includes widevine Provision Keys, Content Encryption Keys,
|
|
||||||
or Service API Calls or Code.
|
|
||||||
3. The Core codebase is meant to stay Free and Open-Source while the Service code should be kept private.
|
|
||||||
4. Do not sell any part of this project, neither alone nor as part of a bundle.
|
|
||||||
If you paid for this software or received it as part of a bundle following payment, you should demand your money
|
|
||||||
back immediately.
|
|
||||||
5. Be kind to one another and do not single anyone out.
|
|
||||||
|
|
||||||
## Licensing
|
|
||||||
|
|
||||||
This software is licensed under the terms of [GNU General Public License, Version 3.0](LICENSE).
|
|
||||||
You can find a copy of the license in the LICENSE file in the root folder.
|
|
||||||
|
|||||||
+22
-39
@@ -718,7 +718,6 @@ class dl:
|
|||||||
for name, binary in [
|
for name, binary in [
|
||||||
("shaka_packager", binaries.ShakaPackager),
|
("shaka_packager", binaries.ShakaPackager),
|
||||||
("mp4decrypt", binaries.Mp4decrypt),
|
("mp4decrypt", binaries.Mp4decrypt),
|
||||||
("n_m3u8dl_re", binaries.N_m3u8DL_RE),
|
|
||||||
("mkvmerge", binaries.MKVToolNix),
|
("mkvmerge", binaries.MKVToolNix),
|
||||||
("ffmpeg", binaries.FFMPEG),
|
("ffmpeg", binaries.FFMPEG),
|
||||||
("ffprobe", binaries.FFProbe),
|
("ffprobe", binaries.FFProbe),
|
||||||
@@ -744,11 +743,6 @@ class dl:
|
|||||||
output = (r.stdout or "") + (r.stderr or "")
|
output = (r.stdout or "") + (r.stderr or "")
|
||||||
lines = [line.strip() for line in output.split("\n") if line.strip()]
|
lines = [line.strip() for line in output.split("\n") if line.strip()]
|
||||||
version = " | ".join(lines[:2]) if lines else None
|
version = " | ".join(lines[:2]) if lines else None
|
||||||
elif name == "n_m3u8dl_re":
|
|
||||||
r = subprocess.run(
|
|
||||||
[str(binary), "--version"], capture_output=True, text=True, timeout=5
|
|
||||||
)
|
|
||||||
version = (r.stdout or r.stderr or "").strip().split("\n")[0]
|
|
||||||
except Exception:
|
except Exception:
|
||||||
version = "<error getting version>"
|
version = "<error getting version>"
|
||||||
binary_versions[name] = {"path": str(binary), "version": version}
|
binary_versions[name] = {"path": str(binary), "version": version}
|
||||||
@@ -2484,6 +2478,25 @@ class dl:
|
|||||||
task_tracks = clone_tracks_for_audio(base_tracks, codec_audio_tracks)
|
task_tracks = clone_tracks_for_audio(base_tracks, codec_audio_tracks)
|
||||||
multiplex_tasks.append((task_id, task_tracks, audio_codec))
|
multiplex_tasks.append((task_id, task_tracks, audio_codec))
|
||||||
|
|
||||||
|
def mux_video_standalone(video_track: Optional[Video]) -> None:
|
||||||
|
if video_track and video_track.dv_compatible_bitstream:
|
||||||
|
apply_dv_fixup(video_track)
|
||||||
|
|
||||||
|
task_description = "Multiplexing"
|
||||||
|
if video_track:
|
||||||
|
if len(quality) > 1:
|
||||||
|
task_description += f" {video_track.height}p"
|
||||||
|
if len(range_) > 1:
|
||||||
|
task_description += f" {video_track.range.name}"
|
||||||
|
if len(vcodec) > 1:
|
||||||
|
task_description += f" {video_track.codec.name}"
|
||||||
|
|
||||||
|
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
||||||
|
if video_track:
|
||||||
|
task_tracks.videos = [video_track]
|
||||||
|
|
||||||
|
enqueue_mux_tasks(task_description, task_tracks)
|
||||||
|
|
||||||
if any(r == Video.Range.HYBRID for r in range_) and title.tracks.videos:
|
if any(r == Video.Range.HYBRID for r in range_) and title.tracks.videos:
|
||||||
self.log.info("Processing Hybrid HDR10+DV tracks...")
|
self.log.info("Processing Hybrid HDR10+DV tracks...")
|
||||||
|
|
||||||
@@ -2541,45 +2554,15 @@ class dl:
|
|||||||
|
|
||||||
# Mux every requested range standalone, skipping the ingredient-only DV.
|
# Mux every requested range standalone, skipping the ingredient-only DV.
|
||||||
for video_track in original_videos:
|
for video_track in original_videos:
|
||||||
if getattr(video_track, "hybrid_base_only", False):
|
if video_track.hybrid_base_only:
|
||||||
continue
|
continue
|
||||||
if getattr(video_track, "dv_compatible_bitstream", False):
|
mux_video_standalone(video_track)
|
||||||
apply_dv_fixup(video_track)
|
|
||||||
|
|
||||||
task_description = "Multiplexing"
|
|
||||||
if len(quality) > 1:
|
|
||||||
task_description += f" {video_track.height}p"
|
|
||||||
if len(range_) > 1:
|
|
||||||
task_description += f" {video_track.range.name}"
|
|
||||||
if len(vcodec) > 1:
|
|
||||||
task_description += f" {video_track.codec.name}"
|
|
||||||
|
|
||||||
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
|
||||||
task_tracks.videos = [video_track]
|
|
||||||
|
|
||||||
enqueue_mux_tasks(task_description, task_tracks)
|
|
||||||
|
|
||||||
console.print()
|
console.print()
|
||||||
else:
|
else:
|
||||||
# Normal mode: process each video track separately
|
# Normal mode: process each video track separately
|
||||||
for video_track in title.tracks.videos or [None]:
|
for video_track in title.tracks.videos or [None]:
|
||||||
if video_track and getattr(video_track, "dv_compatible_bitstream", False):
|
mux_video_standalone(video_track)
|
||||||
apply_dv_fixup(video_track)
|
|
||||||
|
|
||||||
task_description = "Multiplexing"
|
|
||||||
if video_track:
|
|
||||||
if len(quality) > 1:
|
|
||||||
task_description += f" {video_track.height}p"
|
|
||||||
if len(range_) > 1:
|
|
||||||
task_description += f" {video_track.range.name}"
|
|
||||||
if len(vcodec) > 1:
|
|
||||||
task_description += f" {video_track.codec.name}"
|
|
||||||
|
|
||||||
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
|
||||||
if video_track:
|
|
||||||
task_tracks.videos = [video_track]
|
|
||||||
|
|
||||||
enqueue_mux_tasks(task_description, task_tracks)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with Live(Padding(progress, (0, 5, 1, 5)), console=console):
|
with Live(Padding(progress, (0, 5, 1, 5)), console=console):
|
||||||
|
|||||||
@@ -68,15 +68,6 @@ def check() -> None:
|
|||||||
"desc": "HDR10+ metadata",
|
"desc": "HDR10+ metadata",
|
||||||
"cat": "HDR",
|
"cat": "HDR",
|
||||||
},
|
},
|
||||||
# Downloaders
|
|
||||||
{"name": "aria2c", "binary": binaries.Aria2, "required": False, "desc": "Multi-thread DL", "cat": "Download"},
|
|
||||||
{
|
|
||||||
"name": "N_m3u8DL-RE",
|
|
||||||
"binary": binaries.N_m3u8DL_RE,
|
|
||||||
"required": False,
|
|
||||||
"desc": "HLS/DASH/ISM",
|
|
||||||
"cat": "Download",
|
|
||||||
},
|
|
||||||
# Subtitle Tools
|
# Subtitle Tools
|
||||||
{
|
{
|
||||||
"name": "SubtitleEdit",
|
"name": "SubtitleEdit",
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ def serialize_video_track(track: Video, include_url: bool = False) -> Dict[str,
|
|||||||
codec_name = track.codec.name if hasattr(track.codec, "name") else str(track.codec)
|
codec_name = track.codec.name if hasattr(track.codec, "name") else str(track.codec)
|
||||||
range_name = track.range.name if hasattr(track.range, "name") else str(track.range)
|
range_name = track.range.name if hasattr(track.range, "name") else str(track.range)
|
||||||
|
|
||||||
# Get descriptor for N_m3u8DL-RE compatibility (HLS, DASH, URL, etc.)
|
# Serialize the manifest descriptor (HLS, DASH, URL, etc.)
|
||||||
descriptor_name = None
|
descriptor_name = None
|
||||||
if hasattr(track, "descriptor") and track.descriptor:
|
if hasattr(track, "descriptor") and track.descriptor:
|
||||||
descriptor_name = track.descriptor.name if hasattr(track.descriptor, "name") else str(track.descriptor)
|
descriptor_name = track.descriptor.name if hasattr(track.descriptor, "name") else str(track.descriptor)
|
||||||
@@ -442,7 +442,7 @@ def serialize_audio_track(track: Audio, include_url: bool = False) -> Dict[str,
|
|||||||
"""Convert audio track to JSON-serializable dict."""
|
"""Convert audio track to JSON-serializable dict."""
|
||||||
codec_name = track.codec.name if hasattr(track.codec, "name") else str(track.codec)
|
codec_name = track.codec.name if hasattr(track.codec, "name") else str(track.codec)
|
||||||
|
|
||||||
# Get descriptor for N_m3u8DL-RE compatibility
|
# Serialize the manifest descriptor (HLS, DASH, URL, etc.)
|
||||||
descriptor_name = None
|
descriptor_name = None
|
||||||
if hasattr(track, "descriptor") and track.descriptor:
|
if hasattr(track, "descriptor") and track.descriptor:
|
||||||
descriptor_name = track.descriptor.name if hasattr(track.descriptor, "name") else str(track.descriptor)
|
descriptor_name = track.descriptor.name if hasattr(track.descriptor, "name") else str(track.descriptor)
|
||||||
|
|||||||
@@ -45,12 +45,10 @@ ShakaPackager = find(
|
|||||||
f"packager-{__shaka_platform}-arm64",
|
f"packager-{__shaka_platform}-arm64",
|
||||||
f"packager-{__shaka_platform}-x64",
|
f"packager-{__shaka_platform}-x64",
|
||||||
)
|
)
|
||||||
Aria2 = find("aria2c", "aria2")
|
|
||||||
CCExtractor = find("ccextractor", "ccextractorwin", "ccextractorwinfull")
|
CCExtractor = find("ccextractor", "ccextractorwin", "ccextractorwinfull")
|
||||||
HolaProxy = find("hola-proxy")
|
HolaProxy = find("hola-proxy")
|
||||||
MPV = find("mpv")
|
MPV = find("mpv")
|
||||||
Caddy = find("caddy")
|
Caddy = find("caddy")
|
||||||
N_m3u8DL_RE = find("N_m3u8DL-RE", "n-m3u8dl-re")
|
|
||||||
MKVToolNix = find("mkvmerge")
|
MKVToolNix = find("mkvmerge")
|
||||||
Mkvpropedit = find("mkvpropedit")
|
Mkvpropedit = find("mkvpropedit")
|
||||||
DoviTool = find("dovi_tool")
|
DoviTool = find("dovi_tool")
|
||||||
@@ -66,12 +64,10 @@ __all__ = (
|
|||||||
"FFPlay",
|
"FFPlay",
|
||||||
"SubtitleEdit",
|
"SubtitleEdit",
|
||||||
"ShakaPackager",
|
"ShakaPackager",
|
||||||
"Aria2",
|
|
||||||
"CCExtractor",
|
"CCExtractor",
|
||||||
"HolaProxy",
|
"HolaProxy",
|
||||||
"MPV",
|
"MPV",
|
||||||
"Caddy",
|
"Caddy",
|
||||||
"N_m3u8DL_RE",
|
|
||||||
"MKVToolNix",
|
"MKVToolNix",
|
||||||
"Mkvpropedit",
|
"Mkvpropedit",
|
||||||
"DoviTool",
|
"DoviTool",
|
||||||
|
|||||||
@@ -490,39 +490,6 @@ class HLS:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _finalize_n_m3u8dl_re_output(*, track: AnyTrack, save_dir: Path, save_path: Path) -> Path:
|
|
||||||
"""
|
|
||||||
Finalize output from N_m3u8DL-RE.
|
|
||||||
|
|
||||||
We call N_m3u8DL-RE with `--save-name track.id`, so the final file should be `{track.id}.*` under `save_dir`.
|
|
||||||
This moves that output to `save_path` (preserving the real suffix) and, for subtitles, updates `track.codec`
|
|
||||||
to match the produced file extension.
|
|
||||||
"""
|
|
||||||
matches = [p for p in save_dir.rglob(f"{track.id}.*") if p.is_file()]
|
|
||||||
if not matches:
|
|
||||||
raise FileNotFoundError(f"No output files produced by N_m3u8DL-RE for save-name={track.id} in: {save_dir}")
|
|
||||||
|
|
||||||
primary = max(matches, key=lambda p: p.stat().st_size)
|
|
||||||
|
|
||||||
final_save_path = save_path.with_suffix(primary.suffix) if primary.suffix else save_path
|
|
||||||
|
|
||||||
final_save_path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
if primary.absolute() != final_save_path.absolute():
|
|
||||||
final_save_path.unlink(missing_ok=True)
|
|
||||||
shutil.move(str(primary), str(final_save_path))
|
|
||||||
|
|
||||||
if isinstance(track, Subtitle):
|
|
||||||
ext = final_save_path.suffix.lower().lstrip(".")
|
|
||||||
try:
|
|
||||||
track.codec = Subtitle.Codec.from_mime(ext)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
shutil.rmtree(save_dir, ignore_errors=True)
|
|
||||||
|
|
||||||
return final_save_path
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def download_track(
|
def download_track(
|
||||||
track: AnyTrack,
|
track: AnyTrack,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import base64
|
|
||||||
import logging
|
import logging
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from collections.abc import Callable, Generator
|
from collections.abc import Callable, Generator
|
||||||
@@ -213,15 +212,10 @@ class Service(metaclass=ABCMeta):
|
|||||||
|
|
||||||
if proxy:
|
if proxy:
|
||||||
self.session.proxies.update({"all": proxy})
|
self.session.proxies.update({"all": proxy})
|
||||||
proxy_parse = urlparse(proxy)
|
# Don't set Proxy-Authorization manually: both rnet (Proxy.all) and
|
||||||
if proxy_parse.username and proxy_parse.password:
|
# requests authenticate from the credentials embedded in the proxy URL.
|
||||||
self.session.headers.update(
|
# A manual header here was malformed (no "Basic " scheme) and broke
|
||||||
{
|
# plaintext-http forward-proxy requests with HTTP 407.
|
||||||
"Proxy-Authorization": base64.b64encode(
|
|
||||||
f"{proxy_parse.username}:{proxy_parse.password}".encode("utf8")
|
|
||||||
).decode()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# Always verify proxy IP - proxies can change exit nodes
|
# Always verify proxy IP - proxies can change exit nodes
|
||||||
try:
|
try:
|
||||||
proxy_ip_info = get_ip_info(self.session)
|
proxy_ip_info = get_ip_info(self.session)
|
||||||
|
|||||||
@@ -523,15 +523,24 @@ class RnetSession:
|
|||||||
self.cookies._flush_to_client()
|
self.cookies._flush_to_client()
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
def _build_url(self, url: str, params: Optional[dict] = None) -> str:
|
def _build_url(self, url: str, params: Optional[Any] = None) -> str:
|
||||||
"""URL-encode params dict into the URL (rnet ignores params kwarg)."""
|
"""Encode params into the URL (rnet ignores the params kwarg).
|
||||||
|
|
||||||
|
Accepts the same shapes as requests: a mapping, a sequence of pairs, or a
|
||||||
|
pre-built query string/bytes. A string is appended verbatim (already encoded);
|
||||||
|
urlencode() would raise TypeError on it.
|
||||||
|
"""
|
||||||
if not params:
|
if not params:
|
||||||
return url
|
return url
|
||||||
|
if isinstance(params, bytes):
|
||||||
|
extra = params.decode("utf-8")
|
||||||
|
elif isinstance(params, str):
|
||||||
|
extra = params
|
||||||
|
else:
|
||||||
|
extra = urlencode(params, doseq=True)
|
||||||
parsed = urlparse(url)
|
parsed = urlparse(url)
|
||||||
separator = "&" if parsed.query else ""
|
separator = "&" if parsed.query else ""
|
||||||
query = (
|
query = parsed.query + separator + extra if parsed.query else extra
|
||||||
parsed.query + separator + urlencode(params, doseq=True) if parsed.query else urlencode(params, doseq=True)
|
|
||||||
)
|
|
||||||
return urlunparse(parsed._replace(query=query))
|
return urlunparse(parsed._replace(query=query))
|
||||||
|
|
||||||
def get_sleep_time(self, response: Optional[RnetResponse], attempt: int) -> Optional[float]:
|
def get_sleep_time(self, response: Optional[RnetResponse], attempt: int) -> Optional[float]:
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ class Video(Track):
|
|||||||
self.closed_captions: list[dict[str, Any]] = closed_captions or []
|
self.closed_captions: list[dict[str, Any]] = closed_captions or []
|
||||||
self.needs_duration_fix = False
|
self.needs_duration_fix = False
|
||||||
self.dv_compatible_bitstream = dv_compatible_bitstream
|
self.dv_compatible_bitstream = dv_compatible_bitstream
|
||||||
|
self.hybrid_base_only = False
|
||||||
|
|
||||||
def to_dict(self) -> dict[str, Any]:
|
def to_dict(self) -> dict[str, Any]:
|
||||||
data = super().to_dict()
|
data = super().to_dict()
|
||||||
|
|||||||
@@ -395,29 +395,13 @@ key_vaults:
|
|||||||
# no_push: false # Default behavior - vault both provides and receives keys
|
# no_push: false # Default behavior - vault both provides and receives keys
|
||||||
|
|
||||||
# Choose what software to use to download data
|
# Choose what software to use to download data
|
||||||
downloader: aria2c
|
downloader: requests
|
||||||
# Options: requests | aria2c | curl_impersonate | n_m3u8dl_re
|
# Options: requests
|
||||||
# Can also be a mapping:
|
# Downloading now uses the unified in-process requests/rnet downloader; the legacy
|
||||||
# downloader:
|
# aria2c, curl_impersonate, and n_m3u8dl_re backends have been removed.
|
||||||
# NF: requests
|
|
||||||
# AMZN: n_m3u8dl_re
|
|
||||||
# DSNP: n_m3u8dl_re
|
|
||||||
# default: requests
|
|
||||||
|
|
||||||
# aria2c downloader configuration
|
# rnet TLS impersonation preset (not a downloader). Selects the browser
|
||||||
aria2c:
|
# fingerprint the HTTP session impersonates.
|
||||||
max_concurrent_downloads: 4
|
|
||||||
max_connection_per_server: 3
|
|
||||||
split: 5
|
|
||||||
file_allocation: falloc # none | prealloc | falloc | trunc
|
|
||||||
|
|
||||||
# N_m3u8DL-RE downloader configuration
|
|
||||||
n_m3u8dl_re:
|
|
||||||
thread_count: 16
|
|
||||||
ad_keyword: "advertisement"
|
|
||||||
use_proxy: true
|
|
||||||
|
|
||||||
# curl_impersonate downloader configuration
|
|
||||||
curl_impersonate:
|
curl_impersonate:
|
||||||
browser: chrome120
|
browser: chrome120
|
||||||
|
|
||||||
@@ -555,9 +539,8 @@ remote_services:
|
|||||||
# Per-service overrides for remote services
|
# Per-service overrides for remote services
|
||||||
# Override downloader, decryption tool, or CDM settings per service on the client
|
# Override downloader, decryption tool, or CDM settings per service on the client
|
||||||
services:
|
services:
|
||||||
# Example: Use n_m3u8dl_re for HLS services, mp4decrypt for specific services
|
# Example: Override the decryption tool for specific services
|
||||||
# EXAMPLE_SERVICE:
|
# EXAMPLE_SERVICE:
|
||||||
# downloader: n_m3u8dl_re # Override client downloader (requests, aria2c, n_m3u8dl_re, curl_impersonate)
|
|
||||||
# decryption: mp4decrypt # Override decryption tool (shaka, mp4decrypt)
|
# decryption: mp4decrypt # Override decryption tool (shaka, mp4decrypt)
|
||||||
|
|
||||||
# Example: Multiple servers
|
# Example: Multiple servers
|
||||||
@@ -567,7 +550,6 @@ remote_services:
|
|||||||
# server_cdm: true
|
# server_cdm: true
|
||||||
# services:
|
# services:
|
||||||
# EXAMPLE:
|
# EXAMPLE:
|
||||||
# downloader: n_m3u8dl_re
|
|
||||||
# decryption: mp4decrypt
|
# decryption: mp4decrypt
|
||||||
# eu-server:
|
# eu-server:
|
||||||
# url: "https://eu.example.com:8786"
|
# url: "https://eu.example.com:8786"
|
||||||
@@ -581,7 +563,7 @@ services:
|
|||||||
|
|
||||||
# You can override ANY global configuration option on a per-service basis
|
# You can override ANY global configuration option on a per-service basis
|
||||||
# This allows fine-tuned control for services with special requirements
|
# This allows fine-tuned control for services with special requirements
|
||||||
# Supported overrides: dl, aria2c, n_m3u8dl_re, curl_impersonate, subtitle, muxing, headers, etc.
|
# Supported overrides: dl, curl_impersonate, subtitle, muxing, headers, etc.
|
||||||
|
|
||||||
# Example: Comprehensive service configuration showing all features
|
# Example: Comprehensive service configuration showing all features
|
||||||
EXAMPLE:
|
EXAMPLE:
|
||||||
@@ -627,20 +609,6 @@ services:
|
|||||||
lang: ["en", "es-419"] # Different language priority for this service
|
lang: ["en", "es-419"] # Different language priority for this service
|
||||||
sub_format: srt # Force SRT subtitle format
|
sub_format: srt # Force SRT subtitle format
|
||||||
|
|
||||||
# Override n_m3u8dl_re downloader settings
|
|
||||||
n_m3u8dl_re:
|
|
||||||
thread_count: 8 # Lower thread count for rate-limited service (global default: 16)
|
|
||||||
use_proxy: true # Force proxy usage for this service
|
|
||||||
retry_count: 10 # More retries for unstable connections
|
|
||||||
ad_keyword: "advertisement" # Service-specific ad filtering
|
|
||||||
|
|
||||||
# Override aria2c downloader settings
|
|
||||||
aria2c:
|
|
||||||
max_concurrent_downloads: 2 # Limit concurrent downloads (global default: 4)
|
|
||||||
max_connection_per_server: 1 # Single connection per server
|
|
||||||
split: 3 # Fewer splits (global default: 5)
|
|
||||||
file_allocation: none # Faster allocation for this service
|
|
||||||
|
|
||||||
# Override subtitle processing for this service
|
# Override subtitle processing for this service
|
||||||
subtitle:
|
subtitle:
|
||||||
conversion_method: pycaption # Use specific subtitle converter
|
conversion_method: pycaption # Use specific subtitle converter
|
||||||
@@ -675,18 +643,12 @@ services:
|
|||||||
dl:
|
dl:
|
||||||
downloads: 2 # Limit concurrent downloads
|
downloads: 2 # Limit concurrent downloads
|
||||||
workers: 4 # Reduce workers to avoid rate limits
|
workers: 4 # Reduce workers to avoid rate limits
|
||||||
n_m3u8dl_re:
|
|
||||||
thread_count: 4 # Very low thread count
|
|
||||||
retry_count: 20 # More retries for flaky service
|
|
||||||
aria2c:
|
|
||||||
max_concurrent_downloads: 1 # Download tracks one at a time
|
|
||||||
max_connection_per_server: 1 # Single connection only
|
|
||||||
|
|
||||||
# Notes on service-specific overrides:
|
# Notes on service-specific overrides:
|
||||||
# - Overrides are merged with global config, not replaced
|
# - Overrides are merged with global config, not replaced
|
||||||
# - Only specified keys are overridden, others use global defaults
|
# - Only specified keys are overridden, others use global defaults
|
||||||
# - Reserved keys (profiles, api_key, certificate, etc.) are NOT treated as overrides
|
# - Reserved keys (profiles, api_key, certificate, etc.) are NOT treated as overrides
|
||||||
# - Any dict-type config option can be overridden (dl, aria2c, n_m3u8dl_re, subtitle, etc.)
|
# - Any dict-type config option can be overridden (dl, subtitle, muxing, headers, etc.)
|
||||||
# - CLI arguments always take priority over service-specific config
|
# - CLI arguments always take priority over service-specific config
|
||||||
|
|
||||||
# External proxy provider services
|
# External proxy provider services
|
||||||
|
|||||||
Reference in New Issue
Block a user