Compare commits

...
3 Commits
Author SHA1 Message Date
imSp4rky 0576d9d03c chore(release): 5.4.0 2026-08-15 15:54:07 -06:00
imSp4rky 9a2f7a6661 fix(kv): search remote vaults that cannot list their tables
Probe locally installed service tags in parallel when a vault has no table listing, and report every vault holding the KID instead of the first hit.
2026-08-15 15:09:42 -06:00
imSp4rky e1fbd11678 fix(dash): resolve representations by adaptation set, not id alone
Representation ids are only unique within an AdaptationSet, so re-finding a track by id could download a sibling set's stream (audio description in place of dialog). Applies to download_track and extract_dash.
2026-08-15 14:26:45 -06:00
7 changed files with 135 additions and 51 deletions
+13 -2
View File
@@ -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).
## [Unreleased]
## [5.4.0] - 2026-08-15
### 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
- *dl*: Add absolute episode numbers filled from tvdb absolute order
- *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
@@ -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
- *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
- *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
- Restructure documentation into MkDocs Material site
- Expand config reference and genericize service names
- *changelog*: Regenerate with git-cliff
- Correct DRM, muxing, and proxy references (+ case-insensitive proxy prefix fix)
- Cleanup and correct documentation
- *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
- *env*: Drop ML-Worker from the dependency check
- *changelog*: Update changelog
### 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
- 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.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
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "unshackle"
version = "5.3.0"
version = "5.4.0"
description = "Modular Movie, TV, and Music Archival Software."
authors = [{ name = "unshackle team" }]
requires-python = ">=3.11,<3.15"
+53 -22
View File
@@ -1,5 +1,6 @@
import logging
import re
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
from typing import Optional
@@ -243,6 +244,36 @@ def add(file: Path, service: str, vaults: list[str]) -> None:
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()
@click.argument("kid", type=str)
@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.
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
vault in the config is searched.
service table in each vault is scanned; vaults that cannot list their
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")
@@ -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
hit: Optional[tuple[str, str, str]] = None
hits: list[tuple[str, str, str]] = []
for vault in vaults_:
probed = False
if service_tag:
services_to_check: list[str] = [service_tag]
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})")
services_to_check = []
if not services_to_check:
log.warning(f"{vault}: cannot search without a service (remote vault requires --service). Skipping.")
continue
services_to_check = list(Services.get_tags())
probed = True
log.debug(f"{vault}: cannot list tables, probing {len(services_to_check)} local service tag(s)")
for svc in services_to_check:
try:
key = vault.get_key(kid_norm, svc)
except Exception as e:
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
found = search_vault(vault, kid_norm, services_to_check, log)
if found:
svc_hit, key_hit = found
hits.append((vault.name, f"{svc_hit}?" if probed else svc_hit, key_hit))
if hit:
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:
if not hits:
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()
+1 -1
View File
@@ -7,7 +7,7 @@ from rich_click.patch import patch as _patch_click_help
_patch_click_help()
__version__ = "5.3.0"
__version__ = "5.4.0"
_PKG = Path(__file__).parent.parent
# Framework code only. Services are user-swappable, so they are not part of the identity.
+57 -13
View File
@@ -349,20 +349,16 @@ class DASH:
if period_count > 1:
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):
# Find the matching representation in this period
matched_rep = None
matched_as = None
for as_ in content_period.findall("AdaptationSet"):
if DASH.is_trick_mode(as_):
continue
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 content_period is stored_period:
matched_as, matched_rep = adaptation_set, representation
else:
matched_as, matched_rep = DASH.resolve_representation(content_period, rep_id, adaptation_set) or (
None,
None,
)
if matched_rep is None or matched_as is None:
period_id = content_period.get("id", period_idx)
@@ -934,6 +930,54 @@ class DASH:
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
def is_descriptive(adaptation_set: Element) -> bool:
"""Check if contents of Adaptation Set is Descriptive."""
+9 -11
View File
@@ -278,24 +278,22 @@ def extract_dash(track: "Track", session: Union[Session, RnetSession]) -> list[S
data = track.data["dash"]
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", [])
stored_period = data.get("period")
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)]
raw_segments: list[tuple[str, Optional[str]]] = []
for period in content_periods:
matched_rep = matched_as = None
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:
matched_rep, matched_as = rep, as_
break
if matched_rep is not None:
break
# rep ids are only unique within an AdaptationSet, so resolve like DASH.download_track
if period is stored_period:
matched_as, matched_rep = adaptation_set, representation
else:
matched_as, matched_rep = DASH.resolve_representation(period, rep_id, adaptation_set) or (None, None)
if matched_rep is None or matched_as is None:
continue
Generated
+1 -1
View File
@@ -2134,7 +2134,7 @@ wheels = [
[[package]]
name = "unshackle"
version = "5.3.0"
version = "5.4.0"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },