mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-26 19:05:13 +00:00
Compare commits
3
Commits
415a195957
...
5.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0576d9d03c | ||
|
|
9a2f7a6661 | ||
|
|
e1fbd11678 |
+13
-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).
|
||||||
|
|
||||||
## [Unreleased]
|
## [5.4.0] - 2026-08-15
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
@@ -44,6 +44,10 @@ This changelog is automatically generated using [git-cliff](https://git-cliff.or
|
|||||||
- *metadata*: [**breaking**] Replace animeapi with a first-class anilist provider
|
- *metadata*: [**breaking**] Replace animeapi with a first-class anilist provider
|
||||||
- *dl*: Add absolute episode numbers filled from tvdb absolute order
|
- *dl*: Add absolute episode numbers filled from tvdb absolute order
|
||||||
- *dl*: Add daily date-based episodes with tvdb air-date fill
|
- *dl*: Add daily date-based episodes with tvdb air-date fill
|
||||||
|
- *api*: Stream download job progress over server-sent events
|
||||||
|
- *remote*: Accept serve.users keys in api-only mode and add client auth-header fallback
|
||||||
|
- *serve*: Gate server CDM licensing behind a per-key server_cdm opt-in
|
||||||
|
- *cli*: Add named color themes and rich-formatted help
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
@@ -84,11 +88,17 @@ This changelog is automatically generated using [git-cliff](https://git-cliff.or
|
|||||||
- *api*: Carry air_date, absolute, anime and daily across the title wire
|
- *api*: Carry air_date, absolute, anime and daily across the title wire
|
||||||
- *dl*: Treat audio muxed into the video as an available language
|
- *dl*: Treat audio muxed into the video as an available language
|
||||||
- *hls*: Take the key id from EXT-X-KEY when the PSSH carries none
|
- *hls*: Take the key id from EXT-X-KEY when the PSSH carries none
|
||||||
|
- *dl*: Reset per-title language and range selection each iteration
|
||||||
|
- *subtitle*: Keep cue-less webvtt instead of failing the download
|
||||||
|
- *services*: Re-raise ClickException for better error handling in remote services cache
|
||||||
|
- *dash*: Resolve representations by adaptation set, not id alone
|
||||||
|
- *kv*: Search remote vaults that cannot list their tables
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
- Restructure documentation into MkDocs Material site
|
- Restructure documentation into MkDocs Material site
|
||||||
- Expand config reference and genericize service names
|
- Expand config reference and genericize service names
|
||||||
|
- *changelog*: Regenerate with git-cliff
|
||||||
- Correct DRM, muxing, and proxy references (+ case-insensitive proxy prefix fix)
|
- Correct DRM, muxing, and proxy references (+ case-insensitive proxy prefix fix)
|
||||||
- Cleanup and correct documentation
|
- Cleanup and correct documentation
|
||||||
- *core*: Drop service tags from framework comments
|
- *core*: Drop service tags from framework comments
|
||||||
@@ -112,6 +122,7 @@ This changelog is automatically generated using [git-cliff](https://git-cliff.or
|
|||||||
|
|
||||||
- *changelog*: Update entries for new features and bug fixes
|
- *changelog*: Update entries for new features and bug fixes
|
||||||
- *env*: Drop ML-Worker from the dependency check
|
- *env*: Drop ML-Worker from the dependency check
|
||||||
|
- *changelog*: Update changelog
|
||||||
|
|
||||||
### Builds
|
### Builds
|
||||||
|
|
||||||
@@ -882,7 +893,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
|
||||||
|
|
||||||
[unreleased]: https://github.com/unshackle-dl/unshackle/compare/5.3.0..HEAD
|
[5.4.0]: https://github.com/unshackle-dl/unshackle/compare/5.3.0..5.4.0
|
||||||
[5.3.0]: https://github.com/unshackle-dl/unshackle/compare/5.2.0..5.3.0
|
[5.3.0]: https://github.com/unshackle-dl/unshackle/compare/5.2.0..5.3.0
|
||||||
[5.2.0]: https://github.com/unshackle-dl/unshackle/compare/5.1.0..5.2.0
|
[5.2.0]: https://github.com/unshackle-dl/unshackle/compare/5.1.0..5.2.0
|
||||||
[5.1.0]: https://github.com/unshackle-dl/unshackle/compare/5.0.0..5.1.0
|
[5.1.0]: https://github.com/unshackle-dl/unshackle/compare/5.0.0..5.1.0
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "unshackle"
|
name = "unshackle"
|
||||||
version = "5.3.0"
|
version = "5.4.0"
|
||||||
description = "Modular Movie, TV, and Music Archival Software."
|
description = "Modular Movie, TV, and Music Archival Software."
|
||||||
authors = [{ name = "unshackle team" }]
|
authors = [{ name = "unshackle team" }]
|
||||||
requires-python = ">=3.11,<3.15"
|
requires-python = ">=3.11,<3.15"
|
||||||
|
|||||||
+53
-22
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@@ -243,6 +244,36 @@ def add(file: Path, service: str, vaults: list[str]) -> None:
|
|||||||
log.info("Done!")
|
log.info("Done!")
|
||||||
|
|
||||||
|
|
||||||
|
def search_vault(vault: Vault, kid: str, services: list[str], log: logging.Logger) -> Optional[tuple[str, str]]:
|
||||||
|
"""Return the (service, key) of the first service table in a vault holding the KID."""
|
||||||
|
|
||||||
|
def probe(svc: str) -> Optional[tuple[str, str]]:
|
||||||
|
try:
|
||||||
|
key = vault.get_key(kid, svc)
|
||||||
|
except Exception as e:
|
||||||
|
log.debug(f"{vault} [{svc}]: lookup error ({e})")
|
||||||
|
return None
|
||||||
|
if key and key.count("0") != len(key):
|
||||||
|
return svc, key
|
||||||
|
return None
|
||||||
|
|
||||||
|
if len(services) == 1:
|
||||||
|
return probe(services[0])
|
||||||
|
|
||||||
|
with ThreadPoolExecutor(max_workers=8) as pool:
|
||||||
|
futures = [pool.submit(probe, svc) for svc in services]
|
||||||
|
try:
|
||||||
|
for future in as_completed(futures):
|
||||||
|
found = future.result()
|
||||||
|
if found:
|
||||||
|
return found
|
||||||
|
finally:
|
||||||
|
for future in futures:
|
||||||
|
future.cancel()
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@kv.command()
|
@kv.command()
|
||||||
@click.argument("kid", type=str)
|
@click.argument("kid", type=str)
|
||||||
@click.option("-s", "--service", type=str, default=None, help="Limit search to a specific service tag.")
|
@click.option("-s", "--service", type=str, default=None, help="Limit search to a specific service tag.")
|
||||||
@@ -254,8 +285,10 @@ def search(kid: str, service: Optional[str], vault_name: Optional[str]) -> None:
|
|||||||
Search configured Key Vault(s) for a KID and report any matching KEY.
|
Search configured Key Vault(s) for a KID and report any matching KEY.
|
||||||
|
|
||||||
KID must be 32 hex characters (no dashes). If --service is omitted, every
|
KID must be 32 hex characters (no dashes). If --service is omitted, every
|
||||||
service table in each vault is scanned. If --vault is omitted, every
|
service table in each vault is scanned; vaults that cannot list their
|
||||||
vault in the config is searched.
|
tables are probed with every locally installed service tag instead, so
|
||||||
|
passing --service is much faster. If --vault is omitted, every vault in
|
||||||
|
the config is searched.
|
||||||
"""
|
"""
|
||||||
log = logging.getLogger("kv")
|
log = logging.getLogger("kv")
|
||||||
|
|
||||||
@@ -274,8 +307,9 @@ def search(kid: str, service: Optional[str], vault_name: Optional[str]) -> None:
|
|||||||
|
|
||||||
service_tag = Services.get_tag(service) if service else None
|
service_tag = Services.get_tag(service) if service else None
|
||||||
|
|
||||||
hit: Optional[tuple[str, str, str]] = None
|
hits: list[tuple[str, str, str]] = []
|
||||||
for vault in vaults_:
|
for vault in vaults_:
|
||||||
|
probed = False
|
||||||
if service_tag:
|
if service_tag:
|
||||||
services_to_check: list[str] = [service_tag]
|
services_to_check: list[str] = [service_tag]
|
||||||
else:
|
else:
|
||||||
@@ -285,28 +319,25 @@ def search(kid: str, service: Optional[str], vault_name: Optional[str]) -> None:
|
|||||||
log.debug(f"{vault}: get_services() failed ({e})")
|
log.debug(f"{vault}: get_services() failed ({e})")
|
||||||
services_to_check = []
|
services_to_check = []
|
||||||
if not services_to_check:
|
if not services_to_check:
|
||||||
log.warning(f"{vault}: cannot search without a service (remote vault requires --service). Skipping.")
|
services_to_check = list(Services.get_tags())
|
||||||
continue
|
probed = True
|
||||||
|
log.debug(f"{vault}: cannot list tables, probing {len(services_to_check)} local service tag(s)")
|
||||||
|
|
||||||
for svc in services_to_check:
|
found = search_vault(vault, kid_norm, services_to_check, log)
|
||||||
try:
|
if found:
|
||||||
key = vault.get_key(kid_norm, svc)
|
svc_hit, key_hit = found
|
||||||
except Exception as e:
|
hits.append((vault.name, f"{svc_hit}?" if probed else svc_hit, key_hit))
|
||||||
log.debug(f"{vault} [{svc}]: lookup error ({e})")
|
|
||||||
continue
|
|
||||||
if key and key.count("0") != len(key):
|
|
||||||
hit = (vault.name, svc, key)
|
|
||||||
break
|
|
||||||
if hit:
|
|
||||||
break
|
|
||||||
|
|
||||||
if hit:
|
if not hits:
|
||||||
vname, svc, key = hit
|
|
||||||
tree = Tree(Text.assemble((svc, "cyan"), (f"({vname})", "text"), overflow="fold"))
|
|
||||||
tree.add(f"[text2]{kid_norm}:{key}")
|
|
||||||
console.print(Padding(tree, (1, 5)))
|
|
||||||
else:
|
|
||||||
log.info(f"KID {kid_norm} not found in {len(vaults_)} vault(s).")
|
log.info(f"KID {kid_norm} not found in {len(vaults_)} vault(s).")
|
||||||
|
return
|
||||||
|
|
||||||
|
for svc in dict.fromkeys(svc for _, svc, _ in hits):
|
||||||
|
tree = Tree(Text.assemble((svc, "cyan"), overflow="fold"))
|
||||||
|
for vname, hit_svc, key in hits:
|
||||||
|
if hit_svc == svc:
|
||||||
|
tree.add(f"[text2]{kid_norm}:{key} from {vname}")
|
||||||
|
console.print(Padding(tree, (1, 5)))
|
||||||
|
|
||||||
|
|
||||||
@kv.command()
|
@kv.command()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from rich_click.patch import patch as _patch_click_help
|
|||||||
|
|
||||||
_patch_click_help()
|
_patch_click_help()
|
||||||
|
|
||||||
__version__ = "5.3.0"
|
__version__ = "5.4.0"
|
||||||
|
|
||||||
_PKG = Path(__file__).parent.parent
|
_PKG = Path(__file__).parent.parent
|
||||||
# Framework code only. Services are user-swappable, so they are not part of the identity.
|
# Framework code only. Services are user-swappable, so they are not part of the identity.
|
||||||
|
|||||||
@@ -349,20 +349,16 @@ class DASH:
|
|||||||
if period_count > 1:
|
if period_count > 1:
|
||||||
log.debug(f"Multi-period manifest detected with {period_count} content periods")
|
log.debug(f"Multi-period manifest detected with {period_count} content periods")
|
||||||
|
|
||||||
|
stored_period: Optional[Element] = track.data["dash"].get("period")
|
||||||
|
|
||||||
for period_idx, content_period in enumerate(content_periods):
|
for period_idx, content_period in enumerate(content_periods):
|
||||||
# Find the matching representation in this period
|
if content_period is stored_period:
|
||||||
matched_rep = None
|
matched_as, matched_rep = adaptation_set, representation
|
||||||
matched_as = None
|
else:
|
||||||
for as_ in content_period.findall("AdaptationSet"):
|
matched_as, matched_rep = DASH.resolve_representation(content_period, rep_id, adaptation_set) or (
|
||||||
if DASH.is_trick_mode(as_):
|
None,
|
||||||
continue
|
None,
|
||||||
for rep in as_.findall("Representation"):
|
)
|
||||||
if rep.get("id") == rep_id:
|
|
||||||
matched_rep = rep
|
|
||||||
matched_as = as_
|
|
||||||
break
|
|
||||||
if matched_rep is not None:
|
|
||||||
break
|
|
||||||
|
|
||||||
if matched_rep is None or matched_as is None:
|
if matched_rep is None or matched_as is None:
|
||||||
period_id = content_period.get("id", period_idx)
|
period_id = content_period.get("id", period_idx)
|
||||||
@@ -934,6 +930,54 @@ class DASH:
|
|||||||
for prop in essential_props + supplemental_props
|
for prop in essential_props + supplemental_props
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def adaptation_set_key(adaptation_set: Element) -> tuple[Optional[str], ...]:
|
||||||
|
"""Identity of an AdaptationSet, used to re-find its counterpart in another Period."""
|
||||||
|
return tuple(
|
||||||
|
adaptation_set.get(attr)
|
||||||
|
for attr in ("contentType", "mimeType", "lang", "audioTrackId", "audioTrackSubtype", "id")
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_representation(
|
||||||
|
period: Element, rep_id: Optional[str], adaptation_set: Element
|
||||||
|
) -> Optional[tuple[Element, Element]]:
|
||||||
|
"""
|
||||||
|
Find the (AdaptationSet, Representation) in another Period matching rep_id.
|
||||||
|
|
||||||
|
Representation ids are only unique within an AdaptationSet, so the set matching
|
||||||
|
`adaptation_set`'s identity wins over an earlier sibling that reuses the same id
|
||||||
|
for different content (e.g. audio description vs dialog).
|
||||||
|
"""
|
||||||
|
as_key = DASH.adaptation_set_key(adaptation_set)
|
||||||
|
|
||||||
|
def candidates(within: Element) -> list[tuple[Element, Element]]:
|
||||||
|
found = []
|
||||||
|
for as_ in within.findall("AdaptationSet"):
|
||||||
|
if DASH.is_trick_mode(as_) or DASH.adaptation_set_key(as_) != as_key:
|
||||||
|
continue
|
||||||
|
for rep in as_.findall("Representation"):
|
||||||
|
if rep.get("id") == rep_id:
|
||||||
|
found.append((as_, rep))
|
||||||
|
break
|
||||||
|
return found
|
||||||
|
|
||||||
|
matches = candidates(period)
|
||||||
|
if matches:
|
||||||
|
parent = adaptation_set.getparent()
|
||||||
|
siblings = [as_ for as_, _ in candidates(parent)] if parent is not None else []
|
||||||
|
ordinal = siblings.index(adaptation_set) if adaptation_set in siblings else 0
|
||||||
|
return matches[min(ordinal, len(matches) - 1)]
|
||||||
|
|
||||||
|
for as_ in period.findall("AdaptationSet"):
|
||||||
|
if DASH.is_trick_mode(as_):
|
||||||
|
continue
|
||||||
|
for rep in as_.findall("Representation"):
|
||||||
|
if rep.get("id") == rep_id:
|
||||||
|
return as_, rep
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_descriptive(adaptation_set: Element) -> bool:
|
def is_descriptive(adaptation_set: Element) -> bool:
|
||||||
"""Check if contents of Adaptation Set is Descriptive."""
|
"""Check if contents of Adaptation Set is Descriptive."""
|
||||||
|
|||||||
@@ -278,24 +278,22 @@ def extract_dash(track: "Track", session: Union[Session, RnetSession]) -> list[S
|
|||||||
|
|
||||||
data = track.data["dash"]
|
data = track.data["dash"]
|
||||||
manifest = data["manifest"]
|
manifest = data["manifest"]
|
||||||
rep_id = data.get("representation_id") or data["representation"].get("id")
|
adaptation_set = data["adaptation_set"]
|
||||||
|
representation = data["representation"]
|
||||||
|
rep_id = data.get("representation_id") or representation.get("id")
|
||||||
filtered_period_ids = data.get("filtered_period_ids", [])
|
filtered_period_ids = data.get("filtered_period_ids", [])
|
||||||
|
stored_period = data.get("period")
|
||||||
track_url = track.url if isinstance(track.url, str) else track.url[0]
|
track_url = track.url if isinstance(track.url, str) else track.url[0]
|
||||||
|
|
||||||
content_periods = [p for p in manifest.findall("Period") if DASH._is_content_period(p, filtered_period_ids)]
|
content_periods = [p for p in manifest.findall("Period") if DASH._is_content_period(p, filtered_period_ids)]
|
||||||
|
|
||||||
raw_segments: list[tuple[str, Optional[str]]] = []
|
raw_segments: list[tuple[str, Optional[str]]] = []
|
||||||
for period in content_periods:
|
for period in content_periods:
|
||||||
matched_rep = matched_as = None
|
# rep ids are only unique within an AdaptationSet, so resolve like DASH.download_track
|
||||||
for as_ in period.findall("AdaptationSet"):
|
if period is stored_period:
|
||||||
if DASH.is_trick_mode(as_):
|
matched_as, matched_rep = adaptation_set, representation
|
||||||
continue
|
else:
|
||||||
for rep in as_.findall("Representation"):
|
matched_as, matched_rep = DASH.resolve_representation(period, rep_id, adaptation_set) or (None, None)
|
||||||
if rep.get("id") == rep_id:
|
|
||||||
matched_rep, matched_as = rep, as_
|
|
||||||
break
|
|
||||||
if matched_rep is not None:
|
|
||||||
break
|
|
||||||
if matched_rep is None or matched_as is None:
|
if matched_rep is None or matched_as is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user