From 6ed040a6dd7aef23e8bf0cc632b306964ca0890b Mon Sep 17 00:00:00 2001 From: <> Date: Sat, 5 Dec 2026 03:00:15 +0000 Subject: [PATCH] Deployed 87b58190 with MkDocs version: 1.6.1 --- 404.html | 327 +- dev/creating-a-service/index.html | 947 +++-- dev/rest-api/authentication/index.html | 1355 ++++--- dev/rest-api/dashboard/index.html | 1375 +++---- dev/rest-api/endpoints/index.html | 1766 +++------ dev/rest-api/errors/index.html | 404 +- dev/rest-api/index.html | 566 +-- dev/rest-api/job-lifecycle/index.html | 368 +- dev/rest-api/quickstart/index.html | 457 +-- dev/rest-api/remote-sessions/index.html | 3466 ++++++++++------- dev/service-architecture/index.html | 697 ++-- getting-started/configuration-file/index.html | 630 ++- getting-started/installation/index.html | 335 +- getting-started/quickstart/index.html | 342 +- guide/cli-reference/index.html | 624 +-- guide/downloading/index.html | 1244 ++---- guide/drm-and-cdm/index.html | 506 +-- guide/output-and-naming/index.html | 1051 ++--- guide/proxies-and-vpn/index.html | 644 ++- guide/remote-sessions/index.html | 2837 ++++++++++++++ guide/subtitles/index.html | 520 ++- guide/troubleshooting/index.html | 413 +- guide/vaults/index.html | 737 ++-- index.html | 335 +- reference/api/config/index.html | 383 +- reference/api/drm/index.html | 383 +- reference/api/service/index.html | 2072 ++++++---- reference/api/titles/index.html | 383 +- reference/api/tracks/index.html | 383 +- .../configuration/directories/index.html | 331 +- reference/configuration/download/index.html | 492 ++- reference/configuration/drm/index.html | 331 +- reference/configuration/example/index.html | 329 +- reference/configuration/index.html | 337 +- reference/configuration/misc/index.html | 335 +- reference/configuration/network/index.html | 885 ++++- reference/configuration/output/index.html | 682 +++- .../configuration/post-scripts/index.html | 339 +- reference/configuration/services/index.html | 353 +- reference/configuration/vaults/index.html | 757 +++- requirements-docs.txt | 1 + search/search_index.json | 2 +- sitemap.xml | 4 + sitemap.xml.gz | Bin 509 -> 513 bytes 44 files changed, 17665 insertions(+), 13063 deletions(-) create mode 100644 guide/remote-sessions/index.html diff --git a/404.html b/404.html index 4a43d350..ff9b8c95 100644 --- a/404.html +++ b/404.html @@ -334,28 +334,6 @@ - - - - - - - -
  • - - - - - - - API Reference - - -
  • - - - - @@ -601,6 +579,8 @@ + + @@ -873,6 +853,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1065,7 +1210,7 @@ - Output & Naming + Output & Naming Options @@ -1149,7 +1294,7 @@ - Key Vaults + Key Vault Options @@ -1269,6 +1414,8 @@ + + @@ -1380,14 +1527,6 @@ - - - - - - - - @@ -1413,9 +1552,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1694,17 +1761,17 @@ - + - + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1948,25 +2015,28 @@ - - - - -
  • - - - - -
  • + + + + + + + -
  • + + + + + + + + @@ -2429,7 +2507,7 @@ URLs, user agents, or certificates. Put them here.

    config.yaml is shared: keep secrets out of it

    Treat config.yaml as a checked-in file of defaults: it belongs in the service repo, and everyone who runs the service shares it. Per-user secrets -(API keys, device IDs, account tokens) must not live here. Those go in the +(API keys, device identifiers, account tokens) must not live here. Those go in the user's own unshackle.yaml under services.<TAG>, which is merged into self.config at runtime. That checked-in-defaults / per-user-overrides split is exactly why every URL lives in config.yaml with {}/{name} @@ -2442,7 +2520,7 @@ read back through the same self.config[...].

    preferences in config.yaml, and read it from self.config["preferences"]. Over --remote, the client's own services.<TAG>.preferences values reach that block on the server with no extra code. See -Your preferences.

    +Your preferences.

    Split across files? Use relative imports

    @@ -2461,75 +2539,10 @@ locally and from a cloned repo.

    Every service subclasses unshackle.core.service.Service. The minimum is a Click cli entry point plus three abstract methods.

    Class variables

    -

    Declared at class level to configure framework behaviour:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    VariableTypePurpose
    ALIASEStuple[str, ...]Extra tags that resolve to this service (e.g. ("EX", "DOMAIN")). Case does not matter. Default ().
    GEOFENCEtuple[str, ...]IP region codes the service requires. Empty = no geofence. unshackle treats the first entry as the main region for auto-proxy.
    GEOBLOCKtuple[str, ...]IP region codes where the service refuses to work. Every other region is allowed. Default ().
    VAULT_TAGOptional[str]Overrides the key-vault namespace so sibling services can share one vault. Default None (use the service's own tag).
    AUTH_METHODSOptional[tuple[str, ...]]Auth methods accepted ("cookies" / "credentials"). When None, the REST /services endpoint infers them from authenticate().
    ANONYMOUS_SEARCHboolSet True when search() needs no login and no state from authenticate(). A search then skips the cookie load, authenticate() and the cookie save. Default False.
    NO_SUBTITLESboolSet True on a service with no subtitle tracks to skip subtitle handling entirely. Default False.
    ANIMEboolSet True when the catalogue is anime, so metadata lookups prefer AniList. A title's own anime flag overrides it.
    METADATA_PROVIDEROptional[str]Set it, such as to "tmdb", when an index keeps your catalogue's titles only in a form your service does not use (romanized, for one), and another provider finds them by the name your service gives. Lookups try that provider first. It only reorders metadata_providers and never adds a provider the user left out. A title's own metadata_provider overrides it.
    DAILYboolSet True when the catalogue is daily/date-based (talk shows, news, sports), so unshackle names episodes by air date. A title's own daily flag overrides it.
    -

    GEOFENCE drives an automatic proxy: on startup, if you did not pass an -explicit --proxy, the base class does a live IP check and, if your region is -blocked, fetches a proxy to GEOFENCE[0] from your configured proxy providers. A -proxy exit outside GEOFENCE logs a warning and the run continues.

    -

    GEOBLOCK is the negative form: the service works everywhere except the listed -regions. With no GEOFENCE to name a main region, a GEOBLOCK hit stops the run -with a "not available in your region" error; pass --proxy yourself.

    +

    Class variables at the top of your class configure framework behaviour. The attributes table of +Service lists each one. +Service Architecture explains the region check +that GEOFENCE and GEOBLOCK drive.

    class EXAMPLE(Service):
         ALIASES = ("EX", "DOMAIN")
         GEOFENCE = ("US", "GB")
    @@ -2541,69 +2554,16 @@ with a "not available in your region" error; pass --proxy yourself.
     

    What Service.__init__ wires up

    When you call super().__init__(ctx), the base class sets up the attributes you -will use throughout the service:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    AttributeWhat it is
    self.configA dict: this service's config.yaml, with the user's services.<TAG> block from unshackle.yaml merged over it. Without a config.yaml, it holds only the user's block. See Services & authentication for the override keys.
    self.logA logging.Logger named after your class.
    self.sessionA prepared requests.Session with config headers and a retry adapter (5 retries, backoff 0.2, retries on 429/500/502/503/504). Send every request through it: with a proxy active, a request from service code that does not go through the proxy logs a warning. A separate HTTP session that goes direct on purpose sets proxy_exempt = True.
    self.cacheA Cacher for arbitrary key/value data, for example authentication tokens.
    self.title_cacheA region/account-aware TitleCacher used by get_titles_cached.
    self.cache_dirconfig.directories.cache / <ClassName>.
    self.track_requestA TrackRequest built from the CLI --vcodec / --range / --best-available flags.
    self.credentialNone until authenticate() runs.
    self.current_regionThe two-letter region resolved from proxy/IP.
    -

    self.track_request is a small dataclass you can read and rewrite before -fetching tracks:

    -
    @dataclass
    -class TrackRequest:
    -    codecs: list[Video.Codec] = []            # empty == accept any codec
    -    ranges: list[Video.Range] = [Video.Range.SDR]
    -    best_available: bool = False
    -    generate_dv: bool = False                 # --generate-dv: make Dolby Vision when a title has no DV track
    -
    -
    -

    generate_dv and a hand-made HYBRID

    -

    A service that fetches the HYBRID variants itself (HDR10 or HDR Vivid, and DV) must also fetch -HDR10P when track_request.generate_dv is set and the title has no DV track. -unshackle prefers an HEVC HDR10+ track as the base, and measures an HDR10 base from the decoded video. -get_tracks_for_variants does this for you.

    -
    +will use throughout the service, such as self.config, self.session, self.cache and +self.track_request. The attributes table of Service lists each one.

    +

    self.track_request is a TrackRequest built from the CLI. +You can read it and rewrite it before you fetch tracks. A service that fetches the HYBRID variants itself reads the +TrackRequest note first.

    Read the request, don't second-guess the user

    Services may narrow track_request for hard technical constraints (e.g. @@ -2626,6 +2586,12 @@ pings and closes the socket. If instead you need specific SSL cipher behaviour, mount unshackle.core.utils.sslciphers.SSLCiphers onto a plain requests.Session.

    +
    +

    Keep requests on the proxy

    +

    unshackle warns about a request from service code that does not use the proxy of the run. +Send requests through self.session. An HTTP session that goes direct on purpose sets +session.proxy_exempt = True.

    +

    The methods you write

    unshackle calls the methods in the order shown. Only the three abstract ones are mandatory.

    @@ -2643,21 +2609,21 @@ only produces confusing --help/usage output that names the wrong co That confusing output is the reason to keep it in sync, not any requirement of the command lookup.

    -
    @staticmethod
    -@click.command(name="EXAMPLE", short_help="https://domain.com", help=__doc__)
    -@click.argument("title", type=str)
    -@click.option("-m", "--movie", is_flag=True, default=False, help="Treat the title as a movie.")
    -@click.option("-d", "--device", type=click.Choice(["android_tv", "web", "ios"]), default="android_tv")
    -@click.pass_context
    -def cli(ctx: click.Context, **kwargs: Any) -> EXAMPLE:
    -    return EXAMPLE(ctx, **kwargs)
    -
    -def __init__(self, ctx: click.Context, title: str, movie: bool, device: str):
    -    self.title = title
    -    self.movie = movie
    -    self.device = device
    -    super().__init__(ctx)  # wires up config, log, session, caches, track_request...
    -    self.cdm = ctx.obj.cdm
    +
    @staticmethod
    +@click.command(name="EXAMPLE", short_help="https://domain.com", help=__doc__)
    +@click.argument("title", type=str)
    +@click.option("-m", "--movie", is_flag=True, default=False, help="Treat the title as a movie.")
    +@click.option("-d", "--device", type=click.Choice(["android_tv", "web", "ios"]), default="android_tv")
    +@click.pass_context
    +def cli(ctx: click.Context, **kwargs: Any) -> EXAMPLE:
    +    return EXAMPLE(ctx, **kwargs)
    +
    +def __init__(self, ctx: click.Context, title: str, movie: bool, device: str):
    +    self.title = title
    +    self.movie = movie
    +    self.device = device
    +    super().__init__(ctx)  # wires up config, log, session, caches, track_request...
    +    self.cdm = ctx.obj.cdm
     

    Your docstring becomes the CLI --help text (help=__doc__), so document the accepted URL/ID formats and options there.

    @@ -2678,24 +2644,24 @@ device with ctx.obj.cdm_for("<plugin id>"). first: the base implementation loads the cookie jar into self.session.cookies and stores self.credential. Do all token fetching here. It runs before get_titles.

    -
    def authenticate(self, cookies=None, credential=None) -> None:
    -    super().authenticate(cookies, credential)
    -    self.session.headers.update({"user-agent": self.config["client"][self.device]["user_agent"]})
    -
    -    cache = self.cache.get(f"tokens_{self.device}_{self.profile}")
    -    if cache and cache.data.get("expires_in", 0) > int(datetime.now().timestamp()):
    -        self.log.info(" + Using cached tokens")
    -    else:
    -        token = self.session.post(self.config["endpoints"]["login"], data=body).json()
    -        cache.set(data=token, expiration=token.get("expires_in"))
    -    self.token = cache.data["token"]
    +
    def authenticate(self, cookies=None, credential=None) -> None:
    +    super().authenticate(cookies, credential)
    +    self.session.headers.update({"user-agent": self.config["client"][self.device]["user_agent"]})
    +
    +    cache = self.cache.get(f"tokens_{self.device}_{self.profile}")
    +    if cache and cache.data.get("expires_in", 0) > int(datetime.now().timestamp()):
    +        self.log.info(" + Using cached tokens")
    +    else:
    +        token = self.session.post(self.config["endpoints"]["login"], data=body).json()
    +        cache.set(data=token, expiration=token.get("expires_in"))
    +    self.token = cache.data["token"]
     

    Cookies come from files under directories.cookies. Credentials come from the credentials map in unshackle.yaml. For interactive prompts (OTP, captcha) use self.request_input(prompt), never a bare input(). Under serve mode there is no local terminal, so a bare input() would hang the server waiting on stdin that never arrives. request_input instead relays the prompt to the -client: a remote-dl session gets it through the attached InputBridge, and a +client: a remote session gets it through the attached InputBridge, and a REST download job shows it as input_prompt. Locally it routes through the shared Rich console (prompt_user) so the prompt renders correctly alongside progress and log output.

    @@ -2703,11 +2669,11 @@ progress and log output.

    use self.wait_for_approval(message, check, timeout), never a hand-written loop. It shows the message, then calls check at each interval until check returns a value. check returns None while the approval is pending.

    -
    token = self.wait_for_approval(
    -    f"Open {self.config['endpoints']['pair']} and enter code {code}",
    -    check=lambda: self.poll_pair_token(code),
    -    timeout=expires_in,
    -)
    +
    token = self.wait_for_approval(
    +    f"Open {self.config['endpoints']['pair']} and enter code {code}",
    +    check=lambda: self.poll_pair_token(code),
    +    timeout=expires_in,
    +)
     

    It raises TimeoutError after timeout seconds. Under serve mode it also stops when the client deletes the remote session, so the loop does not continue on the @@ -2719,12 +2685,12 @@ the code under it, on the client for a remote session. Give the text that the lo the code, such as the login URL. Keep the URL or code in the message too: a terminal that cannot draw the code, or a phone that cannot read it, still shows the text. EXAMPLE.scan_login in unshackle/services/EXAMPLE/ shows the whole flow.

    -
    token = self.wait_for_approval(
    -    f"Scan the code with the app, or open {login_url}",
    -    check=lambda: self.poll_login(session_id),
    -    timeout=expires_in,
    -    qr=login_url,
    -)
    +
    token = self.wait_for_approval(
    +    f"Scan the code with the app, or open {login_url}",
    +    check=lambda: self.poll_login(session_id),
    +    timeout=expires_in,
    +    qr=login_url,
    +)
     

    When the login API gives only a PNG of the QR code, read the text from the image with read_qr_image from unshackle.core.console, and give that text as qr. It reads a clean, @@ -2732,15 +2698,15 @@ axis-aligned code, dark on a light background, as a login API renders it. Decode to bytes first. It does no error correction, so a code with a logo or other mark over it does not read. It returns None for such a code, for an interlaced PNG or another image format, and for a photo of a code. The terminal then shows only the message.

    -
    from unshackle.core.console import read_qr_image
    -
    -png = self.session.get(login["qr_image_url"]).content
    -token = self.wait_for_approval(
    -    f"Scan the code with the app, or open {login_url}",
    -    check=lambda: self.poll_login(session_id),
    -    timeout=expires_in,
    -    qr=read_qr_image(png),
    -)
    +
    from unshackle.core.console import read_qr_image
    +
    +png = self.session.get(login["qr_image_url"]).content
    +token = self.wait_for_approval(
    +    f"Scan the code with the app, or open {login_url}",
    +    check=lambda: self.poll_login(session_id),
    +    timeout=expires_in,
    +    qr=read_qr_image(png),
    +)
     

    The wait sees a cancel only between two check calls, so check must return within a few seconds. A check that reads a socket keeps the socket open across calls and returns None @@ -2790,26 +2756,26 @@ identity for you.

    Every title carries a language (its original recorded language) and an arbitrary data dict you can use to stash metadata for later methods. You must return at least one title. If you return none, unshackle treats the ID as invalid.

    -
    def get_titles(self) -> Titles_T:
    -    match = re.match(self.TITLE_RE, self.title)
    -    if not match:
    -        raise ValueError("Could not parse a title ID - is the URL/ID correct?")
    -    metadata = self.session.get(
    -        self.config["endpoints"]["metadata"].format(title_id=match.group("title_id")),
    -        params={"token": self.token},
    -    ).json()
    -    original_lang = Language.find(metadata["languages"][0])
    -
    -    return Movies([
    -        Movie(
    -            id_=metadata["id"],
    -            service=self.__class__,
    -            name=metadata["title"],
    -            year=metadata.get("releaseYear") or None,
    -            language=original_lang,   # ORIGINAL audio language, not the -l preference
    -            data=metadata,            # read later as title.data
    -        )
    -    ])
    +
    def get_titles(self) -> Titles_T:
    +    match = re.match(self.TITLE_RE, self.title)
    +    if not match:
    +        raise ValueError("Could not parse a title ID - is the URL/ID correct?")
    +    metadata = self.session.get(
    +        self.config["endpoints"]["metadata"].format(title_id=match.group("title_id")),
    +        params={"token": self.token},
    +    ).json()
    +    original_lang = Language.find(metadata["languages"][0])
    +
    +    return Movies([
    +        Movie(
    +            id_=metadata["id"],
    +            service=self.__class__,
    +            name=metadata["title"],
    +            year=metadata.get("releaseYear") or None,
    +            language=original_lang,   # ORIGINAL audio language, not the -l preference
    +            data=metadata,            # read later as title.data
    +        )
    +    ])
     

    Optional availability metadata

    A service may set title.data["availability"] to a dict with two optional fields:

    @@ -2821,18 +2787,18 @@ return at least one title. If you return none, unshackle treats the ID as invali

    Only these allowlisted fields reach the REST API as availability, including through remote title reconstruction. The CLI's --list-titles does not display -them, and nothing in core reads them to select or authorize downloads.

    +them, and nothing in core reads them to select or authorise downloads.

    Common constructor fields:

    -
    Movie(id_, service, name, year=None, language=None, data=None, description=None)
    +
    Movie(id_, service, name, year=None, language=None, data=None, description=None)
     
    -
    Episode(id_, service, title, season, number, name=None, year=None,
    -        language=None, data=None, description=None, air_date=None,
    -        part=None)
    +
    Episode(id_, service, title, season, number, name=None, year=None,
    +        language=None, data=None, description=None, air_date=None,
    +        part=None)
     

    Pass air_date for daily and sports titles to name by date instead of SxxExx. Return a Series([...]) of episodes. Pass part only when the @@ -2840,8 +2806,8 @@ service splits one episode into several videos, see Split episodes.

    -
    Song(id_, service, name, artist, album, track, disc=1, year=None,
    -     language=None, data=None, ...)
    +
    Song(id_, service, name, artist, album, track, disc=1, year=None,
    +     language=None, data=None, ...)
     

    Return an Album([...]) of songs. disc defaults to 1 and year is optional. Optional metadata keywords such as album_artist, genre, isrc, label, @@ -2870,8 +2836,8 @@ when the API errors. It also applies the per-service title_map conf

    Some services split one logical episode into several separately playable videos, for example a variety show that ships episode 1 as Episode 1 (Part 1), (Part 2) and (Part 3). Episode.number stays an int. The optional part carries the index.

    -
    Episode(..., season=1, number=1, part=1, name="The Reckoning")
    -Episode(..., season=1, number=1, part=2, name="The Reckoning")
    +
    Episode(..., season=1, number=1, part=1, name="The Reckoning")
    +Episode(..., season=1, number=1, part=2, name="The Reckoning")
     
    1. part counts from 1, contiguous. unshackle rejects part=0, and -w can only @@ -2902,7 +2868,7 @@ the prefix before you pass it, or pass None.

      Once part is set, the filename gains a part token (S01E01.Part.2, see Output & naming), -w S01E01.2 selects a single part while a bare -w S01E01 selects them all, and the --list-titles tree labels -the episode 01.2. The REST API reports it as an extra part field on the serialized +the episode 01.2. The REST API reports it as an extra part field on the serialised title, described in Endpoints.

      Opt-in and additive

      @@ -2915,29 +2881,29 @@ has nothing to adopt.

      Subtitle tracks. In almost all cases you assemble these by parsing a manifest, not by hand.

      The manifest parsers live in unshackle.core.manifests:

      -
      from unshackle.core.manifests import DASH, HLS, ISM
      +
      from unshackle.core.manifests import DASH, HLS, ISM
       

      Each exposes from_url(url, session=...) (or from_text(text, url)) and then .to_tracks(language=...):

      -
      def get_tracks(self, title: Title_T) -> Tracks:
      -    return DASH.from_url(manifest_url, session=self.session) \
      -               .to_tracks(language=title.language)
      +
      def get_tracks(self, title: Title_T) -> Tracks:
      +    return DASH.from_url(manifest_url, session=self.session) \
      +               .to_tracks(language=title.language)
       
      -
      def get_tracks(self, title: Title_T) -> Tracks:
      -    return HLS.from_url(manifest_url, session=self.session) \
      -              .to_tracks(language=title.language)
      +
      def get_tracks(self, title: Title_T) -> Tracks:
      +    return HLS.from_url(manifest_url, session=self.session) \
      +              .to_tracks(language=title.language)
       

      The URL must be a variant (master) playlist, not a media playlist.

      -
      def get_tracks(self, title: Title_T) -> Tracks:
      -    return ISM.from_url(manifest_url, session=self.session) \
      -              .to_tracks(language=title.language)
      +
      def get_tracks(self, title: Title_T) -> Tracks:
      +    return ISM.from_url(manifest_url, session=self.session) \
      +              .to_tracks(language=title.language)
       
      @@ -2955,11 +2921,11 @@ language token.

      provides get_tracks_for_variants(title, fetch_fn) to fan out over every codec×range in the TrackRequest, including HYBRID (fetch HDR10, or HDR Vivid when there is no HDR10, + DV and merge) and --best-available skip-on-error handling:

      -
      def get_tracks(self, title: Title_T) -> Tracks:
      -    def fetch_variant(title, codec, range_) -> Tracks:
      -        vcodec = "H265" if codec == Video.Codec.HEVC else "H264"
      -        return self.fetch_dash_manifest(title, vcodec=vcodec, range_=range_)
      -    return self.get_tracks_for_variants(title, fetch_variant)
      +
      def get_tracks(self, title: Title_T) -> Tracks:
      +    def fetch_variant(title, codec, range_) -> Tracks:
      +        vcodec = "H265" if codec == Video.Codec.HEVC else "H264"
      +        return self.fetch_dash_manifest(title, vcodec=vcodec, range_=range_)
      +    return self.get_tracks_for_variants(title, fetch_variant)
       

      What the helper merges

      @@ -2983,7 +2949,7 @@ attachments come from the first manifest only.

      After parsing, you may correct track metadata the manifest gets wrong: -stamp the real video.range, fix odd audio channel counts, mark descriptive +stamp the real video.range, fix odd audio channel layouts, mark descriptive audio, add hand-built subtitles or an Attachment (e.g. cover art). Do not filter for resolution/bitrate. See fetch_dash_manifest in the EXAMPLE service for a thorough demonstration.

      @@ -3001,11 +2967,11 @@ and let the probe relabel the tracks.

      get_tracks is your only chance to capture license inputs

      -

      The license callbacks (get_widevine_license and the others) fire much later, in +

      The licence callbacks (get_widevine_license and the others) fire much later, in the download/decrypt step, long after get_tracks has returned, and they receive only challenge, title, and track. Nothing else from the -manifest response reaches them. So you must stash anything a license call needs -(the license URL, dt-custom-data, a session token) now, during +manifest response reaches them. So you must stash anything a licence call needs +(the licence URL, dt-custom-data, a session token) now, during get_tracks, onto self.license_data or title.data. This is a lifecycle-timing consequence you cannot infer from the callback signatures.

      @@ -3019,12 +2985,12 @@ sure encrypted tracks carry the correct drm so the core licenses th

      Return a Chapters object of 0 or more Chapters. It sorts by timestamp, numbers the chapters at mux time, and adds a 00:00:00.000 chapter if none exists. Timestamps take "HH:MM:SS[.mmm]", int milliseconds, or float seconds.

      -
      def get_chapters(self, title: Title_T) -> Chapters:
      -    chapters = [Chapter(name=c.get("name"), timestamp=c["start"]) for c in title.data.get("chapters", [])]
      -    unique: dict[str, Chapter] = {}
      -    for chapter in sorted(chapters, key=lambda c: not c.named):
      -        unique.setdefault(chapter.timestamp, chapter)
      -    return Chapters(sorted(unique.values(), key=lambda c: c.timestamp))
      +
      def get_chapters(self, title: Title_T) -> Chapters:
      +    chapters = [Chapter(name=c.get("name"), timestamp=c["start"]) for c in title.data.get("chapters", [])]
      +    unique: dict[str, Chapter] = {}
      +    for chapter in sorted(chapters, key=lambda c: not c.named):
      +        unique.setdefault(chapter.timestamp, chapter)
      +    return Chapters(sorted(unique.values(), key=lambda c: c.timestamp))
       

      Sort by timestamp before you build the Chapters

      @@ -3046,59 +3012,28 @@ start, an unnamed one where the intro ends.


      Handling DRM

      -

      The core drives licensing. Your job is to answer the license challenges the CDM +

      The core drives licensing. Your job is to answer the licence challenges the CDM produces. Mark encrypted tracks with the right DRM in get_tracks (the manifest parsers do this automatically for PSSH/EXT-X-KEY found in the manifest), then -write the license callbacks you need. Each receives the challenge plus the -current title and track:

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      MethodForReturns
      get_widevine_service_certificateWidevine privacy modeThe service certificate (bytes or base64 str), or None.
      get_widevine_licenseWidevineThe raw license response (bytes or base64 str), unmodified.
      get_playready_licensePlayReadyThe license response. Defaults to delegating to get_widevine_license.
      get_clearkey_licenseDASH org.w3.clearkeyThe JWK Set (dict/JSON/bytes), or None to let the framework POST the challenge to the manifest's Laurl.
      -

      A license callback can also declare optional keyword arguments. get_widevine_license can ask for pssh and session_id. get_playready_license can ask for pssh_b64 and session_id. session_id is the open CDM session. A callback gets only the arguments that its signature declares. When a --remote client licenses with its own CDM, the callback on the server gets pssh or pssh_b64 for the header the client licenses, but no session_id.

      -
      def get_widevine_license(self, *, challenge: bytes, title, track):
      -    response = self.session.post(
      -        self.license_data["url"],
      -        data=challenge,                       # POST the challenge as-is
      -        headers={"dt-custom-data": self.license_data["data"]},
      -    )
      -    response.raise_for_status()
      -    try:
      -        return response.json()["license"]     # some services wrap it in JSON
      -    except (ValueError, KeyError):
      -        return response.content               # others return raw bytes
      +write the licence callbacks you need. Each receives the challenge plus the
      +current title and track. The service-side hooks
      +names each callback, the optional arguments that it can declare, and what it returns:

      +
      def get_widevine_license(self, *, challenge: bytes, title, track):
      +    response = self.session.post(
      +        self.license_data["url"],
      +        data=challenge,                       # POST the challenge as-is
      +        headers={"dt-custom-data": self.license_data["data"]},
      +    )
      +    response.raise_for_status()
      +    try:
      +        return response.json()["license"]     # some services wrap it in JSON
      +    except (ValueError, KeyError):
      +        return response.content               # others return raw bytes
       
      -

      Return the license untouched

      +

      Return the licence untouched

      Do not base64-encode or decode the challenge or response. Pass them -through verbatim. A malformed license request can get your CDM/device +through verbatim. A malformed challenge can get your CDM/device flagged, banned, or downgraded.

      @@ -3113,16 +3048,16 @@ flagged, banned, or downgraded.

      the content key in get_tracks and pre-populate drm.signatures[kid] = key_hex on the track's ClearKeyCENC. The non-obvious payoff: when every KID is already keyed, the framework skips - the license round-trip entirely.
    2. + the licence round-trip entirely.

    Things the service does not do:

      -
    • HLS AES-128 (ClearKey) tracks and DRM-free tracks have no license +
    • HLS AES-128 (ClearKey) tracks and DRM-free tracks have no licence callback. The content key comes from the manifest, and unshackle applies it directly.
    • Key vaults cache KID:KEY pairs across runs, so repeat downloads skip the - license round-trip entirely.
    • + licence round-trip entirely.
    • Decryption tooling (shaka-packager or mp4decrypt) and the choice of local vs remote CDM are user configuration, not service concerns.
    @@ -3143,99 +3078,99 @@ of these hooks and no track.downloader of the service, so put what account, and when search() does its own setup. A search() that reads a token, a header or a region from authenticate() fails or gives results for the wrong region.

    -
    def search(self) -> Generator[SearchResult, None, None]:
    -    results = self.session.get(self.config["endpoints"]["search"],
    -                               params={"q": self.title}).json()
    -    for r in results["entries"]:
    -        yield SearchResult(id_=r["id"], title=r["title"],
    -                           description=r.get("description"), url=r.get("url"))
    +
    def search(self) -> Generator[SearchResult, None, None]:
    +    results = self.session.get(self.config["endpoints"]["search"],
    +                               params={"q": self.title}).json()
    +    for r in results["entries"]:
    +        yield SearchResult(id_=r["id"], title=r["title"],
    +                           description=r.get("description"), url=r.get("url"))
     

    Minimal service skeleton

    A complete, minimal single-manifest service. Save as services/MYSVC/__init__.py (class name MYSVC), with an optional services/MYSVC/config.yaml beside it.

    -
    services/MYSVC/__init__.py
    from __future__ import annotations
    -
    -import re
    -from typing import Any, Optional
    -
    -import click
    -
    -from unshackle.core.manifests import DASH
    -from unshackle.core.service import Service
    -from unshackle.core.titles import Movie, Movies, Title_T, Titles_T
    -from unshackle.core.tracks import Chapters, Tracks
    -
    -
    -class MYSVC(Service):
    -    """
    -    MyService - https://myservice.com
    -
    -    \b
    -    Usage: unshackle dl MYSVC <title-id-or-url>
    -    """
    -
    -    ALIASES = ("MY",)
    -    GEOFENCE = ("US",)
    -    TITLE_RE = r"^(?:https?://myservice\.com/watch/)?(?P<id>[\w-]+)"
    -
    -    @staticmethod
    -    @click.command(name="MYSVC", short_help="https://myservice.com", help=__doc__)
    -    @click.argument("title", type=str)
    -    @click.pass_context
    -    def cli(ctx: click.Context, **kwargs: Any) -> "MYSVC":
    -        return MYSVC(ctx, **kwargs)
    -
    -    def __init__(self, ctx: click.Context, title: str):
    -        self.title = title
    -        super().__init__(ctx)
    -
    -    def authenticate(self, cookies=None, credential=None) -> None:
    -        super().authenticate(cookies, credential)
    -        # obtain any tokens here, e.g. self.token = ...
    -
    -    def get_titles(self) -> Titles_T:
    -        match = re.match(self.TITLE_RE, self.title)
    -        if not match:
    -            raise ValueError("Could not parse a title ID.")
    -        meta = self.session.get(
    -            self.config["endpoints"]["metadata"].format(id=match.group("id"))
    -        ).json()
    -        return Movies([
    -            Movie(
    -                id_=meta["id"],
    -                service=self.__class__,
    -                name=meta["title"],
    -                year=meta.get("year") or None,
    -                language=meta.get("originalLanguage"),
    -                data=meta,
    -            )
    -        ])
    -
    -    def get_tracks(self, title: Title_T) -> Tracks:
    -        playback = self.session.get(
    -            self.config["endpoints"]["playback"].format(id=title.id)
    -        ).json()
    -        return DASH.from_url(
    -            url=playback["manifest_url"], session=self.session
    -        ).to_tracks(language=title.language)
    -
    -    def get_chapters(self, title: Title_T) -> Chapters:
    -        return Chapters()
    -
    -    def get_widevine_license(self, *, challenge: bytes, title, track):
    -        res = self.session.post(self.config["endpoints"]["license"], data=challenge)
    -        res.raise_for_status()
    -        return res.content
    +
    services/MYSVC/__init__.py
    from __future__ import annotations
    +
    +import re
    +from typing import Any, Optional
    +
    +import click
    +
    +from unshackle.core.manifests import DASH
    +from unshackle.core.service import Service
    +from unshackle.core.titles import Movie, Movies, Title_T, Titles_T
    +from unshackle.core.tracks import Chapters, Tracks
    +
    +
    +class MYSVC(Service):
    +    """
    +    MyService - https://myservice.com
    +
    +    \b
    +    Usage: unshackle dl MYSVC <title-id-or-url>
    +    """
    +
    +    ALIASES = ("MY",)
    +    GEOFENCE = ("US",)
    +    TITLE_RE = r"^(?:https?://myservice\.com/watch/)?(?P<id>[\w-]+)"
    +
    +    @staticmethod
    +    @click.command(name="MYSVC", short_help="https://myservice.com", help=__doc__)
    +    @click.argument("title", type=str)
    +    @click.pass_context
    +    def cli(ctx: click.Context, **kwargs: Any) -> "MYSVC":
    +        return MYSVC(ctx, **kwargs)
    +
    +    def __init__(self, ctx: click.Context, title: str):
    +        self.title = title
    +        super().__init__(ctx)
    +
    +    def authenticate(self, cookies=None, credential=None) -> None:
    +        super().authenticate(cookies, credential)
    +        # obtain any tokens here, e.g. self.token = ...
    +
    +    def get_titles(self) -> Titles_T:
    +        match = re.match(self.TITLE_RE, self.title)
    +        if not match:
    +            raise ValueError("Could not parse a title ID.")
    +        meta = self.session.get(
    +            self.config["endpoints"]["metadata"].format(id=match.group("id"))
    +        ).json()
    +        return Movies([
    +            Movie(
    +                id_=meta["id"],
    +                service=self.__class__,
    +                name=meta["title"],
    +                year=meta.get("year") or None,
    +                language=meta.get("originalLanguage"),
    +                data=meta,
    +            )
    +        ])
    +
    +    def get_tracks(self, title: Title_T) -> Tracks:
    +        playback = self.session.get(
    +            self.config["endpoints"]["playback"].format(id=title.id)
    +        ).json()
    +        return DASH.from_url(
    +            url=playback["manifest_url"], session=self.session
    +        ).to_tracks(language=title.language)
    +
    +    def get_chapters(self, title: Title_T) -> Chapters:
    +        return Chapters()
    +
    +    def get_widevine_license(self, *, challenge: bytes, title, track):
    +        res = self.session.post(self.config["endpoints"]["license"], data=challenge)
    +        res.raise_for_status()
    +        return res.content
     
    -
    services/MYSVC/config.yaml
    endpoints:
    -  metadata: https://api.myservice.com/v1/metadata/{id}
    -  playback: https://api.myservice.com/v1/playback/{id}
    -  license: https://api.myservice.com/v1/license/widevine
    +
    services/MYSVC/config.yaml
    endpoints:
    +  metadata: https://api.myservice.com/v1/metadata/{id}
    +  playback: https://api.myservice.com/v1/playback/{id}
    +  license: https://api.myservice.com/v1/license/widevine
     

    Try it with:

    -
    unshackle dl MYSVC https://myservice.com/watch/abc123
    +
    unshackle dl MYSVC https://myservice.com/watch/abc123
     

    Checklist

    @@ -3244,7 +3179,7 @@ or a region from authenticate() fails or gives results for the wron
  • cli is a @staticmethod that returns an instance. __init__ calls super().__init__(ctx).
  • get_titles, get_tracks and get_chapters written. Titles carry the original language.
  • Tracks come from a manifest parser with to_tracks(language=title.language). No filtering by quality or language.
  • -
  • Encrypted tracks carry their DRM. The license callbacks you need return responses unmodified.
  • +
  • Encrypted tracks carry their DRM. The licence callbacks you need return responses unmodified.
  • URLs, user agents, and certificates live in config.yaml, read through self.config[...].
  • Multi-file services import their own modules relatively (from .helpers import x), so they work when loaded from a repo.
  • diff --git a/dev/rest-api/authentication/index.html b/dev/rest-api/authentication/index.html index 6a2cf3c0..40aa1349 100644 --- a/dev/rest-api/authentication/index.html +++ b/dev/rest-api/authentication/index.html @@ -13,10 +13,10 @@ - + - + @@ -283,10 +283,12 @@ + + -
  • +
  • @@ -327,12 +329,10 @@ - - -
  • +
  • @@ -347,28 +347,6 @@ - - - - - - - -
  • - - - - - - - API Reference - - -
  • - - - -
    @@ -596,6 +574,8 @@ + + @@ -614,26 +594,31 @@ + + + + + -
  • +
  • - + -
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • - - - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • - - - - - - - - - + +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + - -
  • - - - - - - - - - - - - - - - - - @@ -2008,17 +2075,17 @@ - + -

    See Downloads for how the download endpoint uses these fields.

    Session IP binding (remote sessions)

    -

    The remote-download session endpoints (/api/session/*) add an extra check on top of the API key. When the server creates a remote session, it records the client's IP address. Any later request for that remote session must come from the same IP, or the server rejects it with 403 Forbidden. Thus the server binds a remote session both to the API key that created it and to the address it came from.

    +

    The remote session endpoints (/api/session/*) add an extra check on top of the API key. When the server creates a remote session, it records the client's IP address. Any later request for that remote session must come from the same IP, or the server rejects it with 403 Forbidden. Thus the server binds a remote session both to the API key that created it and to the address it came from.

    Transport security (HTTPS)

    The API server speaks plain HTTP. Because the client sends your API key on every request, do not use it over an unencrypted connection on an untrusted network. To serve over HTTPS, operate a reverse proxy in front of unshackle. The serve command can launch Caddy for you:

    unshackle serve --caddy
    @@ -2822,7 +2897,7 @@ that reads error_code to classify a 429 must cope with
     
     
     Failure status
    -401 Unauthorized, or 429 Too Many Requests for a key over its rate limit
    +401 Unauthorized, or 429 Too Many Requests for an API key over its rate limit
     
     
     Missing-header body
    @@ -2869,7 +2944,7 @@ that reads error_code to classify a 429 must cope with
     

    Integrated server (default). A serve_authentication middleware wraps pywidevine's authentication (and pyplayready's for /playready* paths), and the REST routes live in the same application, guarded by the same check. Here the accepted-keys map is your full serve config: api_secret (auto-added with access to all loaded devices) plus every entry under users, each with its declared devices / playready_devices.

    -

    Because the API-only middleware guards all non-health paths, the Swagger UI at /api/docs/ is also behind X-Secret-Key there. In --remote-only mode the Swagger UI is not mounted at all.

    +

    Because the API-only middleware guards every path outside the dashboard prefix, the Swagger UI at /api/docs/ is also behind X-Secret-Key there. In --remote-only mode the Swagger UI is not mounted at all.

    Both middlewares read the caller's API key through the shared request_secret_key() helper in unshackle/core/api/handlers.py. That helper returns the X-Secret-Key header, and falls back to the secret_key query parameter only when the matched route is the job event stream. The integrated server needs one extra branch for this. pywidevine's authentication is header-only. So serve_authentication compares the API key from the query parameter itself when the header is absent, and delegates to pywidevine in every other case. That is why both modes reject a present-but-wrong header.

    CORS and the Authorization header

    A cors_middleware runs on every response in both modes (and answers OPTIONS preflight requests with an empty response). It emits:

    @@ -2918,7 +2993,7 @@ that reads error_code to classify a 429 must cope with @@ -596,6 +574,8 @@ + + @@ -614,26 +594,31 @@ + + + + + -
  • +
  • - + -
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • - - - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  • - - - - - - - - - + +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + @@ -2221,7 +2296,7 @@ -

    Developer Dashboard

    +

    Server Dashboard

    The dashboard endpoints show the operator of a serve instance what the server is doing: version and uptime, request counts, live remote sessions, download jobs, and the recent log lines. They exist so you can watch a headless server (serve --quiet) from a web page @@ -2666,7 +2741,7 @@ without any extra field.

    @@ -614,6 +592,8 @@ + + @@ -886,6 +866,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1078,7 +1223,7 @@ - Output & Naming + Output & Naming Options @@ -1162,7 +1307,7 @@ - Key Vaults + Key Vault Options @@ -1282,6 +1427,8 @@ + + @@ -1400,14 +1547,6 @@ - - - - - - - - @@ -1436,9 +1575,8 @@ - + + - - - - - - - - - - - - - - - - - - - @@ -2320,25 +2233,28 @@ - - - - -
  • - - - - -
  • + + + + + + + -
  • + + + + + + + + @@ -2855,22 +2779,33 @@
  • - + - Remote-dl sessions + Remote sessions -
  • + +
  • + + + + Remote services relay + + + + +
  • -

    Each serialized title carries type ("episode", "movie", "song", or "other"), name, id, language, description, date, and cover_url. Episodes and movies add year. Episodes also add series_title, season, and number.

    +

    Each serialised title carries type ("episode", "movie", "song", or "other"), name, id, language, description, date, and cover_url. Episodes and movies add year. Episodes also add series_title, season, and number.

    The number that wanted takes for a song

    A song adds year and its music fields, such as artist, album, disc, track and position. wanted takes position when it is not null, else disc and track as in "2x3".

    -

    These keys are sent only when the title carries them, so a title without them serializes exactly as before:

    +

    These keys are sent only when the title carries them:

    @@ -3754,7 +3522,7 @@ ignore it safely. See Split e - +
    dl_params object noThe dl track selection that the service reads from ctx.parent.params: lang, v_lang, a_lang, s_lang, acodec, forced_subs and exact_lang, as on POST /api/session/create. Some services select the manifests they fetch from these values.The dl track selection that the service reads from ctx.parent.params: lang, v_lang, a_lang, s_lang, acodec, forced_subs and exact_lang, as on POST /api/session/create. Some services select the manifests they fetch from these values.
    @@ -3886,154 +3654,196 @@ ignore it safely. See Split e
    -

    Common parameters (all optional). These mirror the dl command flags:

    +

    Request body. Every field except service and title_id is optional. The dl fields mirror the flags of the dl command. This table comes from the OpenAPI description that /api/docs/ of a running server also shows.

    - + + + + + + + + + + + + + - + - + - + - + - + - + - + - - + + - + - + + + + + + + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - - + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + @@ -4045,25 +3855,43 @@ ignore it safely. See Split e - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + @@ -4072,70 +3900,124 @@ ignore it safely. See Split e + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -4145,57 +4027,57 @@ ignore it safely. See Split e - + - + - + - + - + - + - + - + - + - + - + - + @@ -4204,16 +4086,28 @@ ignore it safely. See Split e - - + + - + + + + + + + + + + + + + - + @@ -4222,28 +4116,58 @@ ignore it safely. See Split e + + + + + + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Type DefaultNotesDescription
    servicestringrequiredService tag.
    title_idstringrequiredTitle identifier.
    profile string nullCredential/cookie profile.Profile for credentials and cookies.
    qualityint[]integer[] []Target resolution(s); best available if empty, or the lowest with worst.Resolution(s) to download, such as [1080]. An empty list takes the best available, or the lowest with worst. An API key with a server_cdm_max_height for the service must send a quality at or under that height.
    vcodecstring/string[]string / string[] []Video codec filter.Video codec(s) to download, such as "HEVC" or ["AVC", "HEVC"]. Takes AVC, H.264, H264, HEVC, H.265, H265, VVC, H.266, H266, VC1, VC-1, VP8, VP9, AV1 and LCEVC.
    acodecstring/string[]string / string[] []Audio codec filter.Audio codec(s) to download, such as "AAC" or ["AAC", "EC3"]. Takes AAC, AC3, DD, EC3, DD+, EAC3, DDP, AC4, AC-4, OPUS, OGG, VORB, VORBIS, DTS, DTSX, DTS-X, DTSHD, DTS-HD, MPEGH, MPEG-H, AV3A, Audio Vivid, ALAC, FLAC and MP3.
    vbitrate / abitrateintvbitrateinteger ≥ 1 nullVideo / audio bitrate in kbps (positive).Video bitrate in kbps.
    vbitrate_range / abitrate_rangeabitrateinteger ≥ 1nullAudio bitrate in kbps.
    vbitrate_range string null"MIN-MAX" bitrate window.Video bitrate window in kbps as "MIN-MAX", such as "6000-7000". Selects the highest bitrate in the window. Not valid with vbitrate.
    abitrate_rangestringnullAudio bitrate window in kbps as "MIN-MAX", such as "128-256". Selects the highest bitrate in the window. Not valid with abitrate.
    range string[] ["SDR"]Dynamic range(s).Dynamic range(s) to download: SDR, HLG, HDR10, HDR10P, VIVID, DV or HYBRID, in any case. HDR10+ and HDR Vivid are also valid. An API key with a server_cdm_max_height for the service cannot send HYBRID.
    channels number nullAudio channel layout.Audio channels, a positive number such as 2.0, 5.1 or 7.1. 5.1 also matches a 6.0 layout.
    no_atmos boolean falseExclude Atmos tracks.Exclude Atmos audio tracks.
    wanted string / string[] []Episode/season selectors, as a list or as one comma-separated string. Accepts the part form, "S01E01.2", and the air-date form, "2026-08-11" or "2026-08-01:2026-08-31". For a music release, a selector is a number of the track list, "1-5" or "1,3,7", or "{disc}x{track}" such as "2x3".Episodes or seasons to download, as a list or as one comma-separated string, such as ["S01E01", "S01E02"]. Takes the part form "S01E01.2" and the air-date forms "2026-08-11" and "2026-08-01:2026-08-31". For a music release, a selector is a number in the track list, "1-5" or "1,3,7", or "{disc}x{track}" such as "2x3". An empty list downloads all titles.
    latest_episode boolean falseOnly the newest episode.Download only the most recent episode.
    latest_episodesintegerinteger ≥ 1 nullOnly the N newest episodes. A positive integer. When set, it overrides latest_episode.Download only the N most recent episodes. It overrides latest_episode.
    max_downloadsintegerinteger ≥ 1 nullStop the job after N titles have downloaded. A positive integer. A title in skipped_titles or already_present does not count.Stop the job after N titles have downloaded. A title in skipped_titles or already_present does not count.
    lang / v_lang / a_lang / s_langlang string[]["orig"] / [] / [] / ["all"]Language filters. A missing s_lang language gives a warning and the job continues.["orig"]Languages for video and audio. orig is the original language, and a - prefix excludes a language, as in ["all", "-es"].
    v_langstring[][]Languages for video tracks only. A - prefix excludes a language.
    a_langstring[][]Languages for audio tracks only. A - prefix excludes a language.
    s_langstring[]["all"]Languages for subtitle tracks. A - prefix excludes a language, as in ["all", "-es"]. A missing language gives a warning and the job continues.
    require_audio string[] []Audio languages that must exist. The job fails if one is missing, even with best_available, or skips the title with skip_missing.Audio languages that must exist. When one is missing, the job fails, also with best_available, or skips the title with skip_missing.
    require_video string[] []Video languages that must exist. The job fails if one is missing, even with best_available, or skips the title with skip_missing.Video languages that must exist. When one is missing, the job fails, also with best_available, or skips the title with skip_missing.
    require_subs string[] []Subtitle languages that must exist. The job fails if one is missing, or skips the title with skip_missing. s_lang still decides what to keep.Subtitle languages that must exist. When one is missing, the job fails, or skips the title with skip_missing. s_lang still selects the subtitles to keep.
    skip_missing boolean falseSkip a title that misses a required language or track, and continue with the next title. The job's skipped_titles lists each skip. The job fails when it has one title or skips every title.Skip a title that misses a required language or track, and continue with the next title. The skipped_titles of the job lists each skip. The job fails when it has one title or skips all titles.
    skip_existing boolean falseSkip variants recorded as completed for this API key, matched after selection by service, title ID, quality, range and codec. Does not verify files on disk or compare audio/subtitle choices.Skip a variant that the completion archive of this API key records as complete, matched after track selection by service, title ID, quality, range and codec. It does not read the files on disk or compare the audio and subtitle choices.
    force boolean falseBypass the completion archive check for this job. Does not change overwrite behaviour.Ignore the completion archive for this job. The overwrite behaviour does not change.
    forced_subs boolean falseInclude forced subtitles.Include forced subtitle tracks.
    forced_subs_only boolean falseDownload forced subtitles and no other subtitle; implies forced_subs. Not valid with no_subs, video_only, audio_only or chapters_only.Download forced subtitle tracks and no other subtitle tracks. Implies forced_subs. Not valid with no_subs, video_only, audio_only or chapters_only.
    forced_s_lang string[] []Forced subtitle language(s); implies forced_subs.Languages for forced subtitles. Implies forced_subs. A - prefix excludes a language.
    exact_langsub_format string nullOutput subtitle format.Output subtitle format, such as SRT or VTT, or original to keep the source format.
    sub_font string nullFont for subtitles converted to ASS; implies sub_format ASS. With another sub_format the request returns 400.Font for subtitles converted to ASS. Implies sub_format ASS. With another sub_format, the request returns 400.
    video_only / audio_only / subs_only / chapters_onlyvideo_only boolean falseTrack-type restriction. Two or more combine, as on the CLI.Download only video tracks. Two or more of video_only, audio_only, subs_only and chapters_only combine, as on the CLI.
    no_subs / no_audio / no_chapters / no_video / no_attachmentsaudio_only boolean falseSkip a track type.Download only audio tracks. Two or more of video_only, audio_only, subs_only and chapters_only combine, as on the CLI.
    subs_onlybooleanfalseDownload only subtitle tracks. Two or more of video_only, audio_only, subs_only and chapters_only combine, as on the CLI.
    chapters_onlybooleanfalseDownload only chapters. Two or more of video_only, audio_only, subs_only and chapters_only combine, as on the CLI.
    no_subsbooleanfalseDo not download subtitle tracks.
    skip_subtitle_errorsSkip a subtitle that fails to download and keep the other tracks.
    no_audiobooleanfalseDo not download audio tracks.
    no_chaptersbooleanfalseDo not download chapters.
    no_videobooleanfalseDo not download video tracks.
    no_attachmentsbooleanfalseDo not download or mux attachments, such as cover art or subtitle fonts.
    audio_description boolean falseDownload audio description.Download audio description tracks.
    audio_description_only boolean falseDownload audio description and no standard audio. Not valid with no_audio, video_only, subs_only or chapters_only.Download audio description tracks and no standard audio tracks. Not valid with no_audio, video_only, subs_only or chapters_only.
    slowboolean/string/arrayboolean / string / integer[] nullRandomized delay between downloads: true (60-120 seconds), "MIN-MAX", or [MIN, MAX].Add a random delay between title downloads. true is 60-120 seconds. "MIN-MAX" or [MIN, MAX] sets the window in seconds, such as "20-40". MIN must be 5 or more and not more than MAX.
    split_audio boolean nullSeparate files per audio codec.Make one output file for each audio codec, instead of one file with all audio.
    skip_dl boolean falseOnly fetch keys, do not download.Skip the download and get only the content keys.
    all_drm boolean falseLicense each track with both Widevine and PlayReady. Needs a CDM for each DRM system. Key vaults are read first; cdm_only: true sends a challenge for each system. The server refuses it with cdm, which selects one device.License each track with both Widevine and PlayReady. Needs a CDM for each DRM system. A DRM system sends a challenge only for a KID that no key vault has, unless cdm_only is true. Not valid with cdm, which selects one device.
    export boolean falseExport manifest/keys/subs to JSON.Export the manifest, DRM init data, keys and track information to a JSON file in the exports directory.
    cdm_only boolean nullForce CDM-only (true) or vault-only (false) key retrieval. With remote, true licenses every track with the CDM of this server and uses no CDM or vault of the remote server.Get content keys only from the CDM (true) or only from key vaults (false). With remote, true licenses each track with the CDM of this server and uses no CDM or key vault of the remote server.
    proxy / no_proxy / no_proxy_download / proxy_downloadstring / bool / bool / stringnull / false / false / nullProxy controls. proxy and proxy_download must be full proxy URIs on a public host unless the API key has server_proxy. A Control D resolver, controld://<resolver>@dns.controld.com, counts as a full proxy URI: the server runs a forwarder for it.proxystringnullProxy for all requests. Without server_proxy on the API key, it must be a full proxy URI on a public host. With server_proxy, it can also be a country code, which the proxy providers of the server resolve. A Control D resolver, controld://<resolver>@dns.controld.com, is a full proxy URI: the server runs a forwarder for it.
    no_folder / no_source / no_muxno_proxy boolean falseOutput/mux controls.Use no proxy.
    no_proxy_downloadbooleanfalseUse no proxy for the downloads. Manifest, licence and authentication requests still use proxy.
    proxy_downloadstringnullProxy for the downloads only, in the same form as proxy. Manifest, licence and authentication requests use proxy.
    no_folderbooleanfalseWrite the files directly in the output directory, with no folder for the title, for every kind of title.
    no_sourcebooleanfalseLeave the source tag out of the output file name.
    no_muxbooleanfalseDo not mux the tracks into a container file.
    sampleboolean/stringboolean / string nullDownload a short sample and write it with a SAMPLE tag on the filename in a Sample folder inside the output folder. true is 60 seconds from 2 minutes in; "0-60" is a window in seconds.Download a short sample and write it, with a SAMPLE tag in the file name, to a Sample folder in the output folder. true is 60 seconds from 2 minutes in. "START-END" is a window in seconds, such as "0-60".
    include_sample
    workersintinteger ≥ 1 nullThreads per track.Maximum threads for each track download.
    adaptive_workers boolean falseScale segment workers to measured CDN throughput, up to the workers cap.Scale the segment workers of each track to the measured CDN throughput, up to the workers limit.
    download_processesintinteger ≥ 1 1Split a track's segments across this many processes. Only engages for large batches.Split the segments of a track across this number of processes. Only a large batch uses them.
    continue_downloads boolean falseKeep the completed segment files across runs and resume a download that failed before.Keep the completed segment files across runs and continue a download that failed before.
    downloadsintinteger ≥ 1 1Concurrent tracks.Number of tracks to download at the same time.
    worst boolean falsePick the lowest-bitrate video at each resolution in quality, or at the lowest resolution if quality is empty.Select the lowest-bitrate video at each resolution in quality, or at the lowest resolution when quality is empty.
    best_available boolean falseFall back to best available. With all_drm, a DRM system that does not license is a warning.Continue with the best available quality when the requested quality is not available. With all_drm, a DRM system that does not license is a warning. An API key with a server_cdm_max_height for the service cannot set it.
    generate_dv boolean falseWith HYBRID in range, make Dolby Vision from the HDR10+ metadata or the decoded video when a title has no DV track. With HDR10 or HDR10P in range and no HYBRID, make it for that base and ignore a DV track. With none of the three in range, the field has no effect.With HYBRID in range, make Dolby Vision from the HDR10+ metadata or the decoded video when a title has no Dolby Vision track. With HDR10 or HDR10P in range and no HYBRID, make it for that base and ignore a Dolby Vision track. With none of the three in range, the field has no effect.
    repack boolean falseAdd REPACK tag.Add a REPACK tag to the output file name.
    tagRelease group tag.
    tmdb_id / imdb_id / tvdb_id / anilist_id-tmdb_idinteger ≥ 1 nullExternal ID overrides. Each resolves its metadata directly instead of by a title search, and is used for tagging. Set enrich to also take the title, year and original language. Give at most one of tmdb_id, imdb_id and tvdb_id, since unshackle resolves the others from it. Sending two returns 400. anilist_id still combines with one of them. tmdb_id and tvdb_id must be positive integers, imdb_id must look like tt1375666, and anilist_id must be a positive integer or a string like mal:12345, or the request returns 400. An ID whose provider is unconfigured, such as tmdb_id with no tmdb_api_key, returns 400. anilist_id needs no API key.Use this TMDB ID for tagging instead of a title search. Set enrich to also take its title, year and original language. Not valid with imdb_id or tvdb_id. Needs tmdb_api_key on the server.
    imdb_idstringnullUse this IMDB ID for tagging instead of a title search. It must look like tt1375666. Set enrich to also take its title, year and original language. Not valid with tmdb_id or tvdb_id.
    tvdb_idinteger ≥ 1nullUse this TVDB ID for tagging and episode order instead of a series lookup. Set enrich to also take its title, year and original language. Not valid with tmdb_id or imdb_id. Needs tvdb_api_key on the server.
    tvdb_order official, dvd, absolute, alternate, regional nullRenumber episodes to a TVDB season order. Falls back to the tvdb_order config option.Renumber the episodes to a TVDB season order. Without a value, the tvdb_order config option sets the order.
    continuous_episodesNumber each season on from the season before it, so season two starts at episode 5 after four episodes. Season 0 and episode 0 keep their numbers. wanted selects by the new numbers, but the list endpoints show the numbers of the service.
    anilist_idinteger / stringnullUse this AniList ID, a positive integer, for tagging instead of a title search, or a MyAnimeList ID as a string such as mal:21. Combines with one of tmdb_id, imdb_id and tvdb_id, which wins over the IDs that AniList maps. Needs no API key.
    enrich boolean falseOverwrite title, year and original language with the external source's. Needs one of tmdb_id, imdb_id, tvdb_id or anilist_id. Without one the request returns 400.Overwrite the show title, year and original language with those of the external source. Needs one of tmdb_id, imdb_id, tvdb_id or anilist_id.
    daily boolean falseTreat the title as daily/date-based content and fill missing episode air dates from TVDB. The fill needs enrich and a TVDB ID. An air date the service already set is kept.Treat the title as daily content and fill missing episode air dates from TVDB. The fill needs enrich and a TVDB ID. An air date that the service sets stays.
    output_dir string nullOutput directory, relative to the server's downloads directory. The server rejects a path that resolves outside it with 400.Output directory for this download, relative to the downloads directory of the server. The server refuses a path that resolves outside it with 400.
    no_cache / reset_cacheno_cache boolean falseTitle cache controls.Bypass the title cache for this download.
    reset_cachebooleanfalseClear the title cache before the title lookup.
    remotestringnullA remote_services server name from GET /api/config. The service runs through that server (login, titles, tracks, licences); the download still runs on this server.
    client_namestringnullNames this client on the dashboard of the remote server, as serve (<client_name>).
    cdmstringnullCDM device name on the server to license with, in place of the cdm config mapping. Needs serve.cdm_overrides to allow it.
    @@ -4990,475 +4914,55 @@ The archive is independent of history retention, isolated per API key, and has n

    -

    Remote-dl sessions

    -
    -

    Developer feature

    -

    The /api/session/* endpoints power unshackle's remote download mode. A thin local client authenticates once against a remote server, then fetches titles, tracks, and segments, and proxies DRM licensing back through it. The server mounts these endpoints in --remote-only mode, and they are what the built-in RemoteService client drives. Most end users never call them directly.

    -
    -

    The server holds remote sessions in memory. They expire after serve.session_ttl (default 300s) without a request, except while the login runs, which can stay idle for the larger of session_ttl and 600s. A remote session whose client is gone ends sooner: see Client presence. A remote session binds to the IP that made it, so the server rejects a request from a different IP with 403 FORBIDDEN.

    -

    Remote session lifecycle overview

    -
    POST /api/session/create        → returns session_id, status "authenticating"
    -GET  /api/session/{id}/channel  → WebSocket: prompts, CDM calls, logs, login state, drain
    -GET  /api/session/{id}/prompt   → without the channel: poll until authenticated (submit answers via POST)
    -GET  /api/session/{id}/titles   → list titles
    -POST /api/session/{id}/tracks   → tracks + chapters (with URLs) for one title; a track that resolves its URL on use has resolve_url true and no URL
    -POST /api/session/{id}/segments → resolve segment URLs / DRM / headers per track
    -POST /api/session/{id}/segment_filter → HLS segments the service drops (ads, bumpers)
    -POST /api/session/{id}/samples  → decrypt cbcs samples of a track on the server
    -POST /api/session/{id}/license  → proxy or server-CDM DRM licensing
    -POST /api/session/{id}/keys     → store the content keys the client proved on a track
    -POST /api/session/{id}/keys/bad → report a server-vault content key that did not decrypt
    -DELETE /api/session/{id}        → tear down, harvest updated cache
    -
    -

    Slow responses

    -

    The titles, tracks, segments and license routes can take minutes on a large catalogue. When the -answer is not ready after 30 seconds, the route sends status 200 and the headers. It then -sends a newline every 30 seconds until the JSON body is ready. JSON parsers ignore the leading -newlines. This keeps the connection open through a reverse proxy that closes an idle request.

    -
    -

    A late failure has status 200

    -

    The server sent the status before the work ended. A failure after the first 30 seconds -arrives as the standard error body with status 200. -Check status in the body, not only the HTTP status. The body has no HTTP status field. -Use error_code and retryable to decide what to do.

    -
    -

    A slow response is not gzip-compressed. Gzip output cannot start before the body is ready, and -the newlines must go out at once.

    -

    POST /api/session/create

    -

    Make a remote session for a service and title. Authentication runs asynchronously in the background. This call returns immediately with status: "authenticating", and you then poll the prompt endpoint. The body accepts service and title_id (both required). It also accepts a broad set of optional keys, because the body allows additionalProperties. These are session_id, credentials ({username, password, extra?}), cookies (base64 of zlib-compressed Netscape cookie file), proxy, no_proxy, profile, cache (map of forwarded cache files, keyed by the file path relative to the service cache directory with / separators and no .json suffix, so a nested key such as session_web/<sha1> lands in a subdirectory), client_region, proxy_region, cdm_type, range_, vcodec, quality, best_available, dl_params, plugins, client, and any service CLI options. plugins maps the id of each DRM plugin that the client loads to {version, device?}; device holds the plain values of the device attributes that the plugin names in device_facts. The server refuses a title with a track of a plugin that is not in plugins (or a body with no plugins) on POST /api/session/{id}/tracks with DRM_ERROR, and gives device to the service only in a remote session that the client's device licenses. A plugins value over 16384 bytes of JSON, or of another shape, gets INVALID_INPUT. proxy_region is the country code the client resolved proxy from; the server matches it against its own accounts. client is a freeform object the dashboard shows as sent (the CLI puts version, code_hash, platform and a redacted argv in it); the server ignores it above 4096 bytes of JSON.

    -

    session_id is the ID that you give the remote session, so that you can delete it before this call answers. It must be the canonical text of a version 4 UUID. Without it, the server makes the ID. A remote session with your ID ends when you send no request for it and open no channel within 150s of the create. A second create with the same ID from the same API key and IP ends the first one if the first one has not answered, and replaces its remote session when the new one is stored. A second create that fails leaves that remote session open.

    -

    dl_params is an object with the dl track selection: lang, v_lang, a_lang and s_lang (arrays of language strings), acodec (an array of audio codec names or dl -a aliases such as ddp), and forced_subs and exact_lang (booleans). The service reads these values from ctx.parent.params. The server uses the dl default for each absent value. It refuses a malformed value, an unknown codec, range or vcodec name, and a height of 0 or less with INVALID_PARAMETERS. The flat range_, vcodec, quality, best_available and generate_dv keys are dl values on this route. On the list and search routes they are dl values only when the body has service_params.

    -

    Service CLI options also travel in a nested service_params object. When the body has service_params, the server reads service options only from it, and a flat key with the same name stays a dl value. profile at the top level always means the credentials profile, never a service's own --profile option.

    -

    The proxy value must be a full proxy URI, unless the operator gives your API key server_proxy in the serve.users config. Without server_proxy, a proxy URI gets INVALID_PROXY when its host is not a public address, does not resolve, or is not a plain host name or IP address. Without server_proxy, the server does not resolve country codes with its own proxy providers. It rejects the request with INVALID_PROXY when no proxy is set and the reported client_region differs from the server's region. A request that reports no client_region is not blocked. Pass proxy with your own proxy, or no_proxy to accept the server's own connection. With server_proxy, the server resolves a country code and picks a proxy for your client_region itself. A Control D resolver, controld://<resolver>@dns.controld.com, counts as a full proxy URI: the server runs a forwarder for it and needs no Control D configuration of its own. A proxy URI needs an http, https or socks scheme: the server answers INVALID_PROXY to a host:port value, also with server_proxy.

    +

    Remote sessions

    +

    The /api/session/* and /api/tunnel routes carry the remote sessions of dl --remote. The +remote session protocol page is their reference: each route, its request and +response, the login states, the licensing modes and the error codes.

    +

    Remote services relay

    +

    A full-mode server can run a service through one of its own remote_services servers. +GET /api/config lists their names in remote_services, and GET /api/services?remote=<name> +lists the services of that server, each with remote set to the name. Add "remote": "<name>" to +POST /api/search, /api/list-titles, /api/list-tracks or /api/download, and the server opens +a remote session with its own API key for that server: the remote server logs in and resolves titles, +tracks and licences, and a download still runs, decrypts and muxes here. The tag may be any case or +an alias, and your allowlist applies to it. A --remote-only server does not relay.

    +
      +
    • An unknown name is 400 INVALID_PARAMETERS, a server that does not answer is + SERVICE_UNAVAILABLE, a server that rejects the API key of this server is AUTH_FAILED (424), + and a tag that it does not offer is INVALID_SERVICE.
    • +
    • List calls from the same API key for the same title, profile, proxy, client region and service + options share one remote session, which closes after 120 seconds unused.
    • +
    • When the server stops, a list call that waits on the login of a new remote session, or starts one, + gets SERVER_DRAINING (409). A call that opens a lost remote session again can be cut too: + list-titles then gets SERVER_DRAINING, and list-tracks that or SERVICE_ERROR (422).
    • +
    • An optional client_name names your client on the dashboard of the remote server as + serve (<client_name>).
    • +
    • A relayed search opens no remote session. The server sends its own credentials, cookies and cache + for the profile with the search. A service that searches with no login gets none of them.
    • +
    +

    A remote login that waits on you (a pair code or URL to approve on another device, or a question +such as an OTP) cannot answer through a list call. Poll GET /api/remote/logins beside it. A remote +download job shows the same text as its own notice, and asks a question through input_prompt as +a local job does.

    +

    GET /api/remote/logins

    +

    The logins of your list calls that wait on a remote server. An admin key sees the logins of every API +key.

    -
    {
    -  "session_id": "d4e5f6a7-...",
    -  "service": "EXAMPLE",
    -  "status": "authenticating",
    -  "server_account": false
    -}
    -
    -
    -
    -
    -

    server_account is true when the server authenticated with one of its own accounts (serve.server_accounts). Otherwise the server uses only what the client sent, and never falls back to its own credentials. When the login succeeds and the remote session does not use a server account, the login belongs to the client, and the client gets cookies, auth headers, and the remote session cache back. A remote session on the server's device is the exception: the client gets its cookies back, but no auth headers and no cache. For a server-account remote session the tracks and segments responses carry no cookies and no auth headers. The server also drops secret-looking keys from track data, and the cache stays on the server. A server-account service also refuses a client proxy URI, because the server's login would pass through it.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-Session created; authentication in progress.
    400INVALID_INPUTMissing service or title_id, or a session_id that is not the canonical text of a version 4 UUID.
    400INVALID_PARAMETERSInvalid range_, vcodec, quality or dl_params value.
    403FORBIDDENAnother API key or another IP has the session_id.
    404SESSION_NOT_FOUNDA DELETE or a newer create with the same session_id ended this create.
    400INVALID_SERVICEUnknown or disallowed service.
    -

    GET /api/session/{session_id}/channel

    -

    Open the remote session channel: a WebSocket that carries the prompts, CDM calls, log records, login state and drain state of the remote session, and the client's answers. Pass since=<seq> to get only the log records newer than that sequence number. The server closes the WebSocket with code 4404 when the remote session ends. See The remote session channel for the messages.

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    101-WebSocket open.
    403FORBIDDENRequest IP differs from the remote session creator.
    404SESSION_NOT_FOUNDNo such session.
    -

    GET /api/session/{session_id}/prompt

    -

    The polling fallback of the remote session channel. Poll for the authentication status and any pending interactive prompt (OTP, PIN, device code). Response variants:

    -
    -
    -
    -
    { "status": "authenticating" }
    -
    -
    -
    -
    { "status": "pending_input", "prompt": "Enter the code sent to your email:" }
    -
    -
    -
    -
    { "status": "authenticated" }
    -
    -
    -
    -
    { "status": "failed", "error": "Invalid credentials" }
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-Status returned.
    403FORBIDDENRequest IP differs from the remote session creator.
    404SESSION_NOT_FOUNDNo such session.
    -

    POST /api/session/{session_id}/prompt

    -

    Submit a response to a pending prompt. Body: { "response": "..." } (required).

    -
    -
    -
    -
    { "status": "accepted" }
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-Response accepted.
    400INVALID_INPUTMissing response, or no prompt is pending.
    404SESSION_NOT_FOUNDNo such session.
    -

    GET /api/session/{session_id}/logs

    -

    The polling fallback of the remote session channel. Drain the service's server-side log output for this remote session. The server mirrors every log call the service makes (self.log.info, warnings, errors) into a bounded per-session buffer, so a remote client can see why an auth, title, or license step failed. Pass since=<seq> to get only records newer than the last drained sequence number. Works in every auth state, including failed.

    -
    -
    -
    -
    {
    -  "session_id": "a1b2c3",
    -  "logs": [
    -    { "seq": 1, "level": "INFO", "message": "Signed in as profile 'Main'", "ts": 1724990000.1 },
    -    { "seq": 2, "level": "WARNING", "message": " - ThePlatform returned no streams", "ts": 1724990002.7 }
    -  ],
    -  "last_seq": 2
    -}
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-Records returned (empty list when nothing new).
    404SESSION_NOT_FOUNDNo such session.
    -

    The buffer keeps the newest 500 records. Only the service instance's own logger is mirrored; core pipeline loggers stay on the server. A server-account session gets no log relay at all - auth-time service output can carry the operator account's identity, so it stays server-side.

    -

    GET /api/session/{session_id}/titles

    -

    Fetch the titles for an authenticated remote session. -A slow answer arrives as a slow response.

    -
    -
    -
    -
    {
    -  "session_id": "d4e5f6a7-...",
    -  "titles": [ { "type": "episode", "name": "Pilot", "id": "ep-1" } ]
    -}
    -
    -
    -
    -
    -

    collection is present only when the service returned a music collection. It holds the facts of the collection itself: kind, title, artist, year, total_tracks, total_discs, artwork_url, total_duration, owner and description, for example "collection": { "kind": "playlist", "title": "Example Playlist", "total_tracks": 93 }. A fact that the collection does not have is absent.

    -

    Requires an authenticated remote session. Otherwise it returns 404 SESSION_NOT_FOUND.

    -

    POST /api/session/{session_id}/tracks

    -

    Get tracks and chapters for a specific title within the remote session. Body: { "title_id": "..." } (required). Unlike list-tracks, track objects here include download URLs, along with session headers/cookies and manifest data the client needs to download directly. A slow answer arrives as a slow response.

    -

    manifests holds each served DASH/ISM manifest once. One URL can have more than one entry, such as when a service merges a second manifest under the same URL. track_ids names the tracks that each entry restores, and the client matches such a track only in that entry's manifest. For DASH, filtered_period_ids names the periods that the download skips, such as ad periods. A service can build an AdaptationSet of its own that the served manifest does not contain. track_manifests holds a one-track MPD for each such track, and the client re-parses that in place of the whole manifest. That MPD starts at the period of the track and keeps the content periods after it.

    -

    hls_playlists holds the media playlist text of each HLS track that the service holds as text, with the track URL. A file: URL is never sent: such an entry has url set to null. The client keeps an entry only when it parses as a media playlist whose segment URIs are absolute http or https URLs, and is for the same URL as its track. Otherwise it logs Refusing track <id>: its HLS playlist ... and drops the track.

    -
    -
    -
    -
    {
    -  "title": { "type": "episode", "name": "Pilot", "id": "ep-1" },
    -  "video": [ { "id": "v-1", "url": "https://...", "drm": [ ... ] } ],
    -  "audio": [ { "id": "a-1", "url": "https://..." } ],
    -  "subtitles": [ { "id": "s-1", "url": "https://..." } ],
    -  "chapters": [ { "timestamp": "00:00:00.000", "name": "Intro" } ],
    -  "attachments": [ { "url": "https://...", "name": "font.ttf", "mime_type": "font/ttf", "description": "" } ],
    -  "manifests": [ { "type": "dash", "url": "https://...", "data": "<base64 zlib xml>", "track_ids": [ "v-1", "a-1" ], "filtered_period_ids": [ "ad-1" ] } ],
    -  "track_manifests": [ { "track_id": "s-1", "type": "dash", "url": "https://...", "data": "<base64 zlib xml>" } ],
    -  "hls_playlists": [ { "track_id": "v-1", "url": "https://...", "data": "<base64 zlib m3u8>" } ],
    -  "session_headers": { "User-Agent": "..." },
    -  "session_cookies": { "sid": "..." },
    -  "session_cookie_jar": [ { "name": "sid", "value": "...", "domain": ".example.com", "path": "/", "secure": true } ],
    -  "server_cdm_type": "widevine"
    -}
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-Tracks returned.
    400INVALID_INPUTMissing or unknown title_id.
    404SESSION_NOT_FOUNDNo such session.
    -

    POST /api/session/{session_id}/segments

    -

    Get the download URL, DRM info, headers, cookies, and track data for the selected tracks. Body: { "track_ids": ["v-1", "a-1"] } (required). A track that the tracks response sent with resolve_url gets its URL from the service here. The server makes one service call at a time per remote session, so parallel requests wait for each other. A slow answer arrives as described in Slow responses.

    -
    -
    -
    -
    {
    -  "tracks": {
    -    "v-1": { "descriptor": "DASH", "url": "https://...", "drm": [ ... ], "headers": { ... }, "cookies": { ... }, "cookie_jar": [ ... ], "data": { ... } }
    -  }
    -}
    -
    -
    -
    -
    -

    data has the form of the track data in list-tracks: the JSON-safe part of the service-set track.data, without the hls, dash, and ism parser keys. cookies gives names and values only. cookie_jar gives the same cookies with their domain, path and secure flag, in the session_cookie_jar form of the tracks response.

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-Segment info returned.
    400INVALID_INPUTMissing track_ids.
    404TRACK_NOT_FOUNDAn unknown track ID was requested.
    -

    POST /api/session/{session_id}/segment_filter

    -

    Get the HLS segments a service drops (ads, bumpers, dub cards). The server runs the service's own segment filter over the track's media playlist and returns only the URIs, so the client drops the same segments the service does. Body: { "track_id": "v-1" } (required). unwanted is null when the track has no filter. The client keeps every segment when the server does not have this route. When the server answers with an error, the client stops the track download.

    -
    -
    -
    -
    { "unwanted": ["https://cdn.example/hls/ad1.ts"] }
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-Unwanted segment URIs, or null.
    400INVALID_INPUTMissing track_id.
    404TRACK_NOT_FOUNDAn unknown track ID was requested.
    422SERVICE_ERRORThe playlist request or the filter failed.
    -

    POST /api/session/{session_id}/samples

    -

    Decrypt the samples of a track that the service decrypts itself after the download. The tracks response lists those track IDs in sample_decrypt_tracks. The client downloads the file, then sends each stsd sample entry's samples here, and writes the plaintexts back in place. The query string names the track and the 1-based entry: ?track_id=a-1&entry=2.

    -
      -
    • An empty body asks how the entry decrypts. The JSON response is { "key": "<hex>" }, which the client then uses itself, or { "decrypter": true }.
    • -
    • An application/octet-stream body is a sample frame: a big-endian uint32 count, one uint32 length per sample, then the samples. Each sample is a ciphertext cut to whole AES blocks. The response is a frame of the same shape with the plaintexts in the same order.
    • -
    -

    The client sends at most 8 MiB of samples per request, and the route accepts a body of up to 16 MiB. Binary frames keep the upload the size of the samples, and the server does not compress them. The route needs the server_cdm grant for the service, because the decrypter can use a process or an account of the server.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-The content key, decrypter, or the plaintext frame.
    400INVALID_INPUTMissing track_id, a bad entry, a malformed frame, or a track the service does not decrypt.
    413-The body is larger than 16 MiB.
    403FORBIDDENThe API key has no server_cdm grant for the service.
    404TRACK_NOT_FOUNDAn unknown track ID was requested.
    422SERVICE_ERRORThe service's decrypter failed.
    -

    POST /api/session/{session_id}/license

    -

    Get the content keys for the DRM. The mode field selects one of two modes. -A slow answer arrives as a slow response.

    -

    Proxy mode (mode: "proxy", the default) forwards the client's CDM challenge to the service's license endpoint and returns the raw license bytes:

    -
    -
    -
    -
    { "track_id": "v-1", "challenge": "<base64 CDM challenge>", "drm_type": "widevine" }
    -
    -
    -
    -
    { "license": "<base64 license bytes>" }
    -
    -
    -
    -
    -

    Server-CDM mode (mode: "server_cdm") runs the full CDM flow on the server using the device configured for your API key, returning content keys directly. Use track_id for a single track or track_ids for a batch:

    -
    -
    -
    -
    { "keys": { "<kid_hex>": "<key_hex>" }, "vault_keys": ["<kid_hex>"], "drm_type": "widevine" }
    -
    -
    -
    -
    { "keys": { "v-1": { "<kid_hex>": "<key_hex>" } }, "vault_keys": ["<kid_hex>"], "drm_type": "widevine" }
    +
    {
    +  "logins": [
    +    {
    +      "id": "3f2a9c...",
    +      "remote": "my_server",
    +      "service": "EXAMPLE",
    +      "title_id": "0ABCDEF",
    +      "prompt": null,
    +      "notice": "Open https://example.com/activate and enter ABCD-1234",
    +      "qr": "https://example.com/activate?code=ABCD-1234"
    +    }
    +  ]
    +}
     
    @@ -5472,43 +4976,37 @@ A slow answer arrives as a slow response.

    -track_id / track_ids -Single track, or a batch of tracks. +id +The ID to answer the prompt with. -challenge -Base64 CDM challenge (proxy mode). +remote, service, title_id +The remote server, the service and the title of the list call. -pssh -Base64 PSSH. Server-CDM mode licenses this PSSH. Proxy mode gives it to the service licence callback as pssh (Widevine) or pssh_b64 (PlayReady), the PSSH of the header the challenge is for. A proxy-mode PSSH that names a KID the track does not carry goes to no callback. +prompt +What the login asks you (an OTP, a PIN), or null. -drm_type -widevine (default), playready, or the id of a DRM plugin that both peers load. In server-CDM mode the server's cdm mapping for the service decides the DRM system and the response drm_type names the system that licensed. A mapping with a device for each system takes the system of the device the remote session loaded. With no mapping, the client's value decides when the track carries that system; else a system the track carries decides, PlayReady first. The tracks response server_cdm_type names the system the same order gives for the title's tracks. A track whose DRM is a whole-file cipher takes clearkeyctr with no pssh: the service on the server licenses it. A track of a DRM plugin that licenses locally takes the plugin id with no pssh and mode server_cdm: the server answers in keys with the content key from a server vault or from a licence of its own plugin device, only in a session that uses the server CDM, and only under the licence cap (SERVER_CDM_CAPPED above it). +notice +What the login shows you while it waits, such as a URL and a pair code, or null. -mode -proxy (default) or server_cdm. - - -clear_tracks (response) -Requested track ids that carry no DRM, so they have no keys. Absent when every requested track is encrypted. - - -file_keys (response) -Content keys of whole-file ciphers, by track id, for a single track and for a batch. Absent when no requested track holds such a cipher. - - -vault_keys (response) -KIDs whose content key came from a server vault, not the CDM. The client proves such a content key with a decode before it trusts it; the field is absent when every content key came from the CDM. - - -bridge_kids (response) -For a batch: the KIDs of the init segments of each FairPlay-only track that the server licensed through the FairPlay bridge, by track id. The client needs the content key of each of these KIDs, or the download of that track stops. Absent when the batch has no such track. +qr +The text of a QR code to scan with the prompt or notice, or null. +

    POST /api/remote/logins/{login_id}/input

    +

    Answer the prompt of a remote login. Body: { "response": "..." } (required).

    +
    +
    +
    +
    { "status": "accepted" }
    +
    +
    +
    +
    @@ -5521,135 +5019,37 @@ A slow answer arrives as a slow response.

    - + - - - - - - + - - + + - - - - - - - - + + +
    200 -License/keys returned.Answer accepted.
    400 INVALID_INPUTMissing challenge/PSSH, or no CDM device configured for the API key.
    400INVALID_PARAMETERSUnsupported drm_type.No response.
    404TRACK_NOT_FOUNDUnknown track ID.NOT_FOUNDNo such remote login for this API key.
    404NO_CONTENTServer CDM produced no keys.
    422SERVICE_ERRORThe service aborted during licensing.409CONFLICTThe login asks nothing now.
    -

    POST /api/session/{session_id}/keys

    -

    Store the content keys that the client proved on a track and that the server did not serve to this remote session. The server stores a content key only for a KID that a track of the remote session names and that no local server vault holds a content key for. It never stores a pair flagged bad, and it never removes a flag. The server answers when its local vaults hold the pairs, and sends them to its other vaults after the answer. The client sends each key of a licence when the licence returns, and each vault key after its decode check passes. A licence key of a FairPlay-only track that the client licensed through the bridge goes only after its decode check passes, so a client without FFmpeg does not send it.

    -
    { "track_id": "<track_id>", "keys": { "<kid_hex>": "<key_hex>" } }
    -
    - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-{}, whatever the server stored.
    404SESSION_NOT_FOUNDUnknown remote session.
    -

    POST /api/session/{session_id}/keys/bad

    -

    Report a content key from vault_keys that did not decrypt the track. The server flags the pair in its local vaults and reports it to the vault that served it, and the next licence for that KID reaches the CDM. When the CDM returns the same pair, the server removes the flag. The client never learns the server vault names.

    -
    { "kid": "<kid_hex>", "key": "<key_hex>" }
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatusError codeMeaning
    200-{"flagged": true}: the pair is flagged. {"flagged": false}: the CDM licensed the pair, so it is not flagged.
    400INVALID_INPUTThis remote session was not served that pair.
    404SESSION_NOT_FOUNDUnknown remote session.
    -

    GET /api/session/{session_id}

    -

    Return remote session metadata and validity.

    -
    -
    -
    -
    {
    -  "session_id": "d4e5f6a7-...",
    -  "service": "EXAMPLE",
    -  "valid": true,
    -  "expires_in": 300,
    -  "draining": false,
    -  "track_count": 4,
    -  "title_count": 10
    -}
    -
    -
    -
    -
    -

    404 SESSION_NOT_FOUND if the remote session does not exist or has expired.

    -

    DELETE /api/session/{session_id}

    -

    Tear down a remote session. The server cancels its input bridge, harvests any updated cache files, and deletes the remote session and its cache directory. A create of the same API key and IP that still runs under this ID ends too: it makes no remote session and answers 404 SESSION_NOT_FOUND. If no remote session exists yet, the DELETE answers 200 with no cache.

    -
    -
    -
    -
    {
    -  "status": "ok",
    -  "cache": { "tokens": "<base64 zlib bytes>", "session_web/<sha1>": "<base64 zlib bytes>" }
    -}
    -
    -
    -
    -
    -

    The cache field is present only if the remote session produced cache files and the login belongs to the client. Each cache key is the file path relative to the session cache directory, with / separators and no .json suffix, so a file in a subdirectory keeps its place on the client. The server rejects a cache key with a drive letter, a root, a .. segment, or an empty segment, and so does the client. 404 SESSION_NOT_FOUND if the remote session does not exist.


    Error responses

    The server serialises every structured error raised inside a handler to the same JSON envelope:

    -
    {
    -  "status": "error",
    -  "error_code": "INVALID_PARAMETERS",
    -  "message": "Invalid video codec: XYZ",
    -  "timestamp": "2026-07-03T12:00:00+00:00",
    -  "details": { "field": "vcodec" },
    -  "retryable": true,
    -  "debug_info": { "exception_type": "APIError", "traceback": "..." }
    -}
    +
    {
    +  "status": "error",
    +  "error_code": "INVALID_PARAMETERS",
    +  "message": "Invalid video codec: XYZ",
    +  "timestamp": "2026-07-03T12:00:00+00:00",
    +  "details": { "field": "vcodec" },
    +  "retryable": true,
    +  "debug_info": { "exception_type": "APIError", "traceback": "..." }
    +}
     
    • details appears only when non-empty.
    • @@ -5662,14 +5062,14 @@ A slow answer arrives as a slow response.

    Error codes and default status

    The error code catalogue gives the default HTTP status of each error code.

    -

    When a generic (uncategorized) exception reaches a handler, unshackle inspects its message and type to pick a code. For example, messages mentioning "connection" or "timeout" become NETWORK_ERROR (424, retryable), "rate limit" or "429" become RATE_LIMITED (429, retryable), and anything unrecognized collapses to INTERNAL_ERROR (422).

    +

    When a generic (uncategorised) exception reaches a handler, unshackle inspects its message and type to pick a code. For example, messages mentioning "connection" or "timeout" become NETWORK_ERROR (424, retryable), "rate limit" or "429" become RATE_LIMITED (429, retryable), and anything unrecognised collapses to INTERNAL_ERROR (422).


    See also

    @@ -5708,7 +5108,7 @@ A slow answer arrives as a slow response.

    @@ -614,6 +592,8 @@ + + @@ -886,6 +866,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1078,7 +1223,7 @@ - Output & Naming + Output & Naming Options @@ -1162,7 +1307,7 @@ - Key Vaults + Key Vault Options @@ -1282,6 +1427,8 @@ + + @@ -1400,14 +1547,6 @@ - - - - - - - - @@ -1436,9 +1575,8 @@ - + + - + + + + + + +
  • + + + + + + + + Remote Session Protocol + + + + + + + +
  • @@ -1886,9 +1952,10 @@ - - - + + + + @@ -1911,25 +1978,28 @@ - - - - -
  • - - - - -
  • + + + + + + + -
  • + + + + + + + + @@ -2307,7 +2385,7 @@ that carries a machine-readable error code, a human-readable HTTP status. This page documents that format and catalogues every error code the server can send.

    If you write a client against the API, read this page alongside the endpoint -reference. Each endpoint lists the specific codes it raises, and this page gives the +reference. The section of each endpoint names the specific codes it raises, and this page gives the meanings of those codes.

    Where this comes from

    @@ -2405,7 +2483,7 @@ stable across releases.

    Error ref 7f3a2c: SERVICE_ERROR 422 POST /api/session/<id>/license service=EXAMPLE user=alice: Licence request failed: ...
     

    Search the server log for Error ref <ref>. The handler's traceback, when there is one, -is directly above that line. The developer dashboard log view also shows it.

    +is directly above that line. The server dashboard log view also shows it.

    The details object

    When present, details carries extra context specific to the error. It is only included when it is non-empty, so a client must treat a missing details as "no @@ -2511,7 +2589,7 @@ while the server restarts.

    SESSION_NOT_FOUND 404 -The remote-dl session does not exist or has expired. +The remote session does not exist or has expired. TRACK_NOT_FOUND @@ -2536,7 +2614,7 @@ while the server restarts.

    DRM_ERROR 422 -DRM or license acquisition failed. +DRM or licence acquisition failed. RATE_LIMITED @@ -2713,9 +2791,9 @@ body that uses an integer status and no error_code or (integer status, no error_code).

    Late failures with status 200

    -

    The remote session titles, tracks and license routes send status 200 and the headers +

    The remote session titles, tracks, segments and license routes send status 200 and the headers when the work takes longer than 30 seconds. They then send a newline every 30 seconds to keep -the connection open. See Slow responses. A failure after that +the connection open. See Slow responses. A failure after that time arrives as the standard error body, but with status 200. The body has no field for the HTTP status that the error would otherwise have. error_code and retryable stay in the body.

    @@ -2770,7 +2848,7 @@ debugging, never on a server reachable by untrusted clients.

    Reference consumer

    -

    unshackle's own remote-download client treats any status of 400 or above as +

    unshackle's own remote session client treats any status of 400 or above as fatal, and a 200 body with "status": "error" and an error_code too: it logs Server error [<error_code>]: <message> and exits. It retries a request once, after one second, only when a 502, 503 or 504 arrives with a body that is @@ -2815,7 +2893,7 @@ handling.

    @@ -596,6 +574,8 @@ + + @@ -614,26 +594,31 @@ + + + + + -
  • +
  • - + -
  • - - - - - - - - - @@ -1717,17 +1784,17 @@ - + -
    -

    The server mounts only the remote-session subset of routes (health, services, search, -and everything under /api/session/*). This mode implies --api-only, and the +

    The server mounts only the remote session routes. This mode implies --api-only, and the interactive Swagger UI is not mounted.

    @@ -2437,7 +2510,9 @@ request and response in full.

    -

    Remote-download sessions

    +

    Remote sessions

    +

    The /api/session/*, /api/tunnel and /api/tunnel/check routes carry the remote sessions of +dl --remote. The remote session protocol lists each route.

    @@ -2448,86 +2523,21 @@ request and response in full.

    - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    POST/api/session/createStart a server-side, authenticated service session.
    GET/api/session/{session_id}Remote session info and time-to-live.
    DELETE/api/session/{session_id}Tear down a session.
    GET/api/session/{session_id}/titlesTitles for the session's title ID./api/remote/loginsThe logins of a relayed list call that wait on you.
    POST/api/session/{session_id}/tracksTracks (with URLs) for a chosen title.
    POST/api/session/{session_id}/segmentsPer-track segment/download details.
    POST/api/session/{session_id}/segment_filterServer-side HLS segment filter results for one track.
    POST/api/session/{session_id}/samplesServer-side cbcs sample decryption for one track.
    POST/api/session/{session_id}/licenseProxy or server-side DRM licensing.
    POST/api/session/{session_id}/keysStore the content keys the client proved on a track.
    POST/api/session/{session_id}/keys/badReport a server-vault content key that did not decrypt.
    GET/api/session/{session_id}/channelWebSocket of the remote session channel: prompts, CDM calls, logs, login state.
    GET/api/session/{session_id}/logsDrain the service's server-side log output.
    GET/api/session/{session_id}/promptPoll for interactive auth status/prompt.
    POST/api/session/{session_id}/promptSubmit an answer to an auth prompt./api/remote/logins/{login_id}/inputAnswer the prompt of such a login.

    Remote-only routes

    -

    The health, services, search, and /api/session/* routes are the ones exposed -when the server runs with --remote-only. Everything else (downloads, jobs, +

    A server that runs with --remote-only exposes only the +remote session routes and the dashboard routes. Everything else (downloads, jobs, history, config, maintenance) is only available in the full or --api-only modes.

    Authentication in one line

    @@ -2543,7 +2553,7 @@ the full model, including per-key service allowlists.

    Where to go next

      -
    • Quick Start: start the server, set an API key, and operate your +
    • REST API Quick Start: start the server, set an API key, and operate your first end-to-end download over the API.
    • Authentication: the X-Secret-Key header, --no-key, per-key service allowlists, and CORS.
    • @@ -2551,8 +2561,8 @@ the full model, including per-key service allowlists.

      shape, endpoint by endpoint.
    • Job Lifecycle: how a download moves from queued to a terminal state, live progress, cancellation, and retries.
    • -
    • Remote Sessions: the /api/session/* flow for driving a - service from a thin remote client.
    • +
    • Remote Session Protocol: the routes, login states, + licensing modes and message shapes of a remote session.
    • Error Responses: the standard error envelope, error codes, and their HTTP statuses.
    @@ -2594,7 +2604,7 @@ the full model, including per-key service allowlists.

    @@ -614,6 +592,8 @@ + + @@ -886,6 +866,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1078,7 +1223,7 @@ - Output & Naming + Output & Naming Options @@ -1162,7 +1307,7 @@ - Key Vaults + Key Vault Options @@ -1282,6 +1427,8 @@ + + @@ -1400,14 +1547,6 @@ - - - - - - - - @@ -1436,9 +1575,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1994,25 +2061,28 @@ - - - - -
  • - - - - -
  • + + + + + + + -
  • + + + + + + + + @@ -2419,10 +2497,10 @@
  • - + - Secret handling in serialized jobs + Secret handling in serialised jobs @@ -2949,12 +3027,12 @@ it repackages and muxes. A track counts as done when it reaches a terminal state subprocess (escalating to kill() if it does not exit within 5 seconds), and raises a cancellation so the task unwinds. The subprocess model is what makes this a clean, immediate stop rather than a cooperative one. A job with the remote parameter first ends its - remote session, in at most 4 + remote session, in at most 4 seconds, and runs no post-script after the cancel.
  • -

    Secret handling in serialized jobs

    +

    Secret handling in serialised jobs

    Job parameters may carry secrets: a raw user:pass credential, or a proxy URL with -embedded userinfo. Whenever the manager serializes a job (for an API response or the +embedded userinfo. Whenever the manager serialises a job (for an API response or the history file), it masks the sensitive keys (credential, credentials, password, token, api_key) and strips userinfo from proxy URLs. The manager also scrubs free-text fields that a service might have leaked a secret into (error_message, @@ -2966,7 +3044,7 @@ or logs them.

  • Endpoints: the full request/response reference for every job endpoint.
  • Error Responses: the error envelope, codes, and HTTP statuses a failed job reports.
  • Authentication: the X-Secret-Key header and per-key service allowlists that gate job creation and retry.
  • -
  • Downloading: the equivalent options on the dl command line.
  • +
  • CLI reference: dl: the equivalent options on the dl command line.
  • @@ -3022,13 +3100,13 @@ or logs them.

    - + @@ -614,6 +592,8 @@ + + @@ -886,6 +866,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1078,7 +1223,7 @@ - Output & Naming + Output & Naming Options @@ -1162,7 +1307,7 @@ - Key Vaults + Key Vault Options @@ -1282,6 +1427,8 @@ + + @@ -1400,14 +1547,6 @@ - - - - - - - - @@ -1436,9 +1575,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1894,25 +1961,28 @@ - - - - -
  • - - - - -
  • + + + + + + + -
  • + + + + + + + + @@ -2175,10 +2253,10 @@
    • - + - Frequently used download fields + Download fields @@ -2268,7 +2346,7 @@

      REST API Quick Start

      Unshackle ships with a built-in REST API that exposes the same download engine you drive from the command line. The unshackle serve command serves it and lets you queue downloads, poll their progress, browse services, and manage history over HTTP instead of the terminal.

      The full loop runs end to end: start the server, authenticate, submit a download job, and poll it to completion. The curl commands here come directly from the API routes.

      -
      +

      Who this page is for

      This is a developer guide. It assumes you are comfortable with HTTP, JSON, and a tool like curl. If you only want to download something, the command line is simpler. The REST API is meant for building tools, UIs, and automation on top of unshackle.

      @@ -2362,7 +2440,7 @@ --remote-only off -Expose only the remote-session subset of routes +Expose only the remote session routes: /api/health, /api/services, /api/search, /api/session/*, /api/tunnel and /api/tunnel/check, and the dashboard routes when serve.dashboard.key is set --caddy @@ -2472,80 +2550,9 @@ -d '{"service":"EXAMPLE","title_id":"12345","quality":[1080]}' \ | python -c "import sys, json; print(json.load(sys.stdin)['job_id'])")
    -

    Frequently used download fields

    -

    The request body accepts the full download parameter set. A few of the most useful:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDefaultMeaning
    service-Service tag (required)
    title_id-Title identifier (required)
    profilenullNamed credential/cookie profile to use
    quality[]Resolution(s), e.g. [1080]; empty means best available
    vcodec[]Video codec, e.g. "H265"
    acodec[]Audio codec, e.g. "EC3"
    range["SDR"]Dynamic range: SDR, HDR10, HDR10+, VIVID, DV, HLG, HYBRID
    wanted[]Episodes to fetch, e.g. ["S01E01"], or music tracks, e.g. ["1-5"]. Empty means all
    lang["orig"]Video/audio language(s)
    s_lang["all"]Subtitle language(s)
    downloads1Number of tracks to download concurrently
    proxynullProxy URI or country code
    -

    Validation is strict: invalid codecs, subtitle formats, dynamic-range names, non-positive counts, or flags that conflict (for example both no_subs and subs_only) come back as 400 with error code INVALID_PARAMETERS. See the full reference on the download reference page for every accepted field.

    +

    Download fields

    +

    The request body takes every dl option. The request body table gives the type, default and meaning of each field.

    +

    Validation is strict: invalid codecs, subtitle formats, dynamic-range names, non-positive counts, or flags that conflict (for example both no_subs and subs_only) come back as 400 with error code INVALID_PARAMETERS.

    Gated fields

    The server refuses a per-request CDM (cdm) or inline credentials (credential / credentials) with 403 FORBIDDEN, unless the server operator has explicitly opted in with serve.cdm_overrides and serve.allow_job_credentials. Both are off by default.

    @@ -2698,13 +2705,13 @@

    A retry reuses the original job's service, title, and parameters to enqueue a brand new job, and returns 202 with a fresh job_id. A retry works only on terminal jobs, and returns 409 CONFLICT otherwise. A priority change works only on jobs still in the queued state.


    Beyond a single download

    -

    The download loop above is the core of the API, but the same server exposes more:

    +

    The download flow above is the core of the API, but the same server exposes more:

    • Discovery: POST /api/search finds titles by query, and POST /api/list-titles / POST /api/list-tracks inspect what a title offers before you commit to downloading it. See titles and tracks.
    • History: GET /api/history reads a persisted log of jobs that reached a terminal state (newest first), and DELETE /api/history/{job_id} removes a single entry. See history.
    • Introspection: GET /api/profiles lists configured credential profiles per service, GET /api/config returns a redacted view of the effective server config, and GET /api/env/check reports which external binaries the machine has.
    • Maintenance: POST /api/maintenance/clear-cache, .../clear-temp, and .../refresh-services do housekeeping (the server blocks the cache and temp clears with 409 while a download is active).
    • -
    • Remote sessions: the /api/session/* endpoints drive the thin-client "remote download" flow, where the server authenticates and licenses on behalf of a local client. See remote sessions.
    • +
    • Remote sessions: the routes that carry the remote sessions of dl --remote, where the server authenticates and licenses on behalf of a local client. See remote sessions.

    The interactive Swagger UI at /api/docs/ documents every route and lets you try them in the browser (send your X-Secret-Key there too).


    @@ -2833,7 +2840,7 @@ @@ -614,6 +592,8 @@ + + @@ -886,6 +866,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1078,7 +1223,7 @@ - Output & Naming + Output & Naming Options @@ -1162,7 +1307,7 @@ - Key Vaults + Key Vault Options @@ -1282,6 +1427,8 @@ + + @@ -1400,14 +1547,6 @@ - - - - - - - - @@ -1436,9 +1575,8 @@ - + + + + + + @@ -2230,10 +2374,10 @@
    • - + - The big picture + Routes @@ -2241,33 +2385,22 @@
    • - + - Configuring a remote server (client side) + Conventions -
    @@ -614,6 +592,8 @@ + + @@ -886,6 +866,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1078,7 +1223,7 @@ - Output & Naming + Output & Naming Options @@ -1162,7 +1307,7 @@ - Key Vaults + Key Vault Options @@ -1282,6 +1427,8 @@ + + @@ -1794,14 +1941,6 @@ - - - - - - - - @@ -1830,9 +1969,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2103,25 +2170,28 @@ - - - - -
  • - - - - -
  • + + + + + + + -
  • + + + + + + + + @@ -2736,63 +2814,9 @@ does the rest.

    Two kinds of members matter: class variables that give the details of the service, and methods that the pipeline calls.

    Class variables

    -

    Declared at the top of your service class, these are static descriptors:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Class variableTypePurpose
    ALIASEStuple[str, ...]Alternate tags the service answers to, in any case (resolved by Services.get_tag).
    GEOFENCEtuple[str, ...]ISO region codes the service requires; empty means no geofence. unshackle treats the first entry as the "main region" for automatic proxy selection.
    GEOBLOCKtuple[str, ...]ISO region codes where the service refuses to work; every other region is allowed. Use it for a service that works worldwide except in its home market.
    VAULT_TAGOptional[str]Overrides the key-vault namespace; defaults to the service's own tag.
    AUTH_METHODSOptional[tuple[str, ...]]Accepted auth methods ("cookies" / "credentials"). When None, the REST /services endpoint infers them from authenticate().
    ANONYMOUS_SEARCHboolsearch() needs no login and no state from authenticate(). A search then skips the cookie load, authenticate() and the cookie save. Default False.
    ANIMEboolThe catalogue is anime, so metadata lookups prefer AniList. A title's own anime flag overrides it.
    METADATA_PROVIDEROptional[str]The metadata provider the catalogue resolves through, such as "tmdb". Lookups try it first. It only reorders metadata_providers and never adds a provider the user left out. A title's own metadata_provider overrides it.
    DAILYboolThe catalogue is daily/date-based, so unshackle names episodes by air date. A title's own daily flag overrides it.
    +

    Declared at the top of your service class, class variables such as ALIASES, GEOFENCE and +NO_SUBTITLES describe the service to the framework. The attributes table of +Service in the Service API gives each one, with its type and purpose.

    Required methods

    These are abstract. A service will not load unless it defines all three:

      @@ -2808,14 +2832,12 @@ Two kinds of members matter: class variables that give the deta
    • search(): raises NotImplementedError by default. Write it so that the search command can operate. unshackle calls authenticate() first, unless the service sets ANONYMOUS_SEARCH.
    • -
    • DRM license hooks: get_widevine_service_certificate, get_widevine_license, - get_playready_license (delegates to Widevine by default), and - get_clearkey_license (returns None by default). See DRM hooks below.
    • -
    • request_input(prompt, qr=None): prompts the user. It goes through the remote-dl input +
    • Licence callbacks: see DRM hooks below.
    • +
    • request_input(prompt, qr=None): prompts the user. It goes through the remote session input bridge, the REST download job relay, or the rich console.
    • wait_for_approval(message, check, timeout, interval=3.0, qr=None): shows a message, then calls check until it returns a value. Use it for a login that the user approves on - another device, such as a pair code. A remote-dl session shows the message as a log + another device, such as a pair code. A remote session shows the message as a log line, and a REST download job shows it as the job's notice. Both methods take qr, the text of a QR code to scan, and the terminal or UI that shows the user the message draws it. When the login API gives only a PNG, read_qr_image(data) in unshackle.core.console @@ -2826,49 +2848,9 @@ Two kinds of members matter: class variables that give the deta

    What __init__ wires up for you

    You rarely override __init__. The base constructor takes the Click context and sets -up the objects your methods rely on:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    AttributeWhat it is
    self.configThe merged service config (see Request and HTTP session objects).
    self.logA logging.Logger named after your class.
    self.sessionA ready-to-use HTTP session (headers, retries, and proxy applied). Send every request through it: with a proxy active, a request from service code that does not go through the proxy logs a warning. A separate HTTP session that goes direct on purpose sets proxy_exempt = True.
    self.cacheA generic key/value Cacher namespaced to the service.
    self.title_cacheA region- and account-aware TitleCacher.
    self.cache_dirconfig.directories.cache / <ServiceName>.
    self.credentialThe active Credential, or None until authenticated.
    self.track_requestA TrackRequest describing the requested codecs, ranges, and best-available flag (see below).
    +up the objects your methods rely on, such as self.session, self.cache and self.track_request. +The attributes table of Service lists each one. +Request and HTTP session objects explains the main ones.

    The constructor also resolves proxies: it reads --proxy, which dl and search have already resolved through the per-service proxy_map, and, if GEOFENCE is set and you did not give an explicit proxy, does a live IP check and auto-fetches a proxy to GEOFENCE[0] when it detects a geoblock. A @@ -2879,12 +2861,16 @@ outside GEOFENCE logs a warning and the run continues. See Proxies and VPN.

    TrackRequest

    -

    self.track_request is a small dataclass built from the CLI: codecs -(from --vcodec, empty means "accept any"), ranges (from --range, default -[Video.Range.SDR]), best_available, and generate_dv (from --generate-dv). -Use it in get_tracks to decide which variants to fetch. A service that fetches +

    self.track_request is a TrackRequest built from the +CLI. Use it in get_tracks to decide which variants to fetch. A service that fetches the HYBRID variants itself must also fetch HDR10P when generate_dv is set and -the title has no DV track, because unshackle prefers an HEVC HDR10+ base.

    +the title has no DV track, because unshackle prefers an HEVC HDR10+ base. +get_tracks_for_variants does this for you.

    Titles and the Title hierarchy

    get_titles() returns a title collection, one of the Titles_T types. Each @@ -2992,9 +2978,7 @@ copies them from the best selected lossless track (FLAC, ALAC or PCM) of the fir If that changes the Quality row, dl shows the release header again. A lossy track changes nothing.

    A Song is an ordinary Title on the one generic download path. unshackle has no -music-specific service API and no separate music download loop. The -GROUP_AUDIO_DOWNLOADS flag, get_music_track_options and get_music_collection_label -no longer exist, and a music service does not need them.

    +music-specific service API and no separate path for music.

    Core picks the container of a Song from the codec in the downloaded file, so a music service does not rename the track path. Read Music output files.

    @@ -3105,8 +3089,8 @@ The value also goes to a --remote client. A track without it muxes and sdh, and forced cannot combine with either. Subtitle.Codec includes SubRip (SRT), WebVTT (VTT), SubStationAlpha/SubStationAlphav4 (SSA/ASS), TimedTextMarkupLang (TTML), SAMI, SCC, and the box-encapsulated DASH formats fTTML -(STPP) and fVTT (WVTT). Subtitles receive post-download normalization -(segment merging, WebVTT sanitization, format conversion, and optional SDH stripping), +(STPP) and fVTT (WVTT). Subtitles receive post-download normalisation +(segment merging, WebVTT sanitisation, format conversion, and optional SDH stripping), all documented for users in Subtitles.

    Chapters and attachments

      @@ -3211,33 +3195,33 @@ least one and no track is left.

    • Segments of each format: unshackle inflates a segment body that is one whole gzip member before the merge, up to a size limit. A CDN can send such a body with no Content-Encoding header. Any other body stays as it is, such as AES-128 ciphertext that starts with the gzip magic.
    • -
    • ISM has no list of segments and no init segments: the parser synthesizes segment URLs +
    • ISM has no list of segments and no init segments: the parser synthesises segment URLs from the <c> fragment timeline, and rebuilds a moov/ftyp init box from CodecPrivateData (supported for AVC, HEVC, DV-over-HEVC, AAC, EC-3, and TTML). A track id covers the manifest URL, so a title you build from one ISM manifest per codec or range keeps every variant: - Tracks.add no longer reads the second manifest's tracks as duplicates of the first.
    • + Tracks.add does not read the tracks of the second manifest as duplicates of the first.

    DRM hooks

    If a track carries DRM, the framework licenses and decrypts it, but it needs your -service to talk to the platform's license server. unshackle recognizes six DRM classes:

    +service to talk to the platform's licence server. unshackle recognises six DRM classes:

    - + - + - + @@ -3257,7 +3241,7 @@ service to talk to the platform's license server. unshackle recognizes six DRM c - +
    DRM class SystemLicense flowLicence flow
    Widevine WidevineCDM challenge → license server → content keys (.wvd device)CDM challenge → licence server → content keys (.wvd device)
    PlayReady PlayReadyCDM challenge (WRM header) → license server → content keys (.prd device)CDM challenge (WRM header) → licence server → content keys (.prd device)
    ClearKeyCENC
    ClearKeyCTR AES-128-CTR over a whole filethe service gives the IV and licenses the content key at the licence step; no CDM, no license serverthe service gives the IV and licenses the content key at the licence step; no CDM, no licence server
    @@ -3269,50 +3253,27 @@ decrypted with shaka-packager or mp4decrypt like Widevine.

    The service-side hooks

    The framework supplies the CDM and the decryption backend. Your service gives the network -calls that must carry the CDM's challenge. Override the hooks that your platform -needs:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    HookReturnPurpose
    get_widevine_service_certificate(title, track, challenge)cert bytesOptional privacy-mode service certificate.
    get_widevine_license(title, track, challenge)license bytesPOST the Widevine challenge to the license server, return the response.
    get_playready_license(title, track, challenge)licenseSame for PlayReady; defaults to delegating to Widevine.
    get_clearkey_license(title, track, challenge)dict / str / bytes / NoneFor ClearKeyCENC; return None to let the framework POST to the manifest Laurl.
    get_fairplay_bridge_license(title, track, challenge, drm_system)licenseOptional, not on the base class. Licenses a FairPlay-only HLS track; see The FairPlay bridge hook.
    +calls that must carry the CDM's challenge. Override the licence callbacks that your platform +needs: get_widevine_service_certificate, get_widevine_license, get_playready_license and +get_clearkey_license. Each one gets challenge, title and track as keyword arguments, and +returns the licence as the server gives it, without decoding it. The base get_playready_license calls +get_widevine_license, and the base get_clearkey_license returns None, so that the framework +POSTs the challenge to the manifest Laurl. The Service API gives the +signature and the return type of each callback.

    +

    A licence callback can also declare optional keyword arguments. get_widevine_license can ask for +pssh and session_id. get_playready_license can ask for pssh_b64 and session_id. +session_id is the open CDM session. A callback gets only the arguments that its signature declares. +When a --remote client licenses with its own CDM, the callback on the server gets pssh or +pssh_b64 for the header that the client licenses, but no session_id.

    You do not open CDM sessions or operate shaka-packager yourself. The Widevine/PlayReady -classes drive the CDM handshake and call the decryption backend. Your hook is only the -"send this challenge, give me back the license" step.

    +classes drive the CDM handshake and call the decryption backend. Your callback is only the +"send this challenge, give me back the licence" step.

    The FairPlay bridge hook

    -

    unshackle has no FairPlay CDM and never sends a FairPlay challenge. For a FairPlay-only track it can send a PlayReady or Widevine challenge for the KIDs of the init segments to the licence server of the platform, which works only when that server issues the same content key to PlayReady or Widevine. The bridge runs only for a service that defines -get_fairplay_bridge_license. The base class does not define it.

    +

    unshackle has no FairPlay CDM and never sends a FairPlay challenge. For a FairPlay-only HLS track it can +send a PlayReady or Widevine challenge for the KIDs of the init segments to the licence server of the +platform. This works only when that server issues the same content key to PlayReady or Widevine. The +bridge runs only for a service that defines get_fairplay_bridge_license. The base class does not +define it.

    def get_fairplay_bridge_license(
         self, *, challenge: bytes, title: Title_T, track: AnyTrack, drm_system: str
     ) -> bytes | str:
    @@ -3322,11 +3283,12 @@ classes drive the CDM handshake and call the decryption backend. Your hook is on
     
    • drm_system is "playready" or "widevine". The hook must accept it.
    • -
    • The hook can also declare the arguments of the licence callback of that system: pssh for Widevine, - pssh_b64 for PlayReady, and session_id. It gets only the arguments that it declares.
    • +
    • The hook can also declare the optional arguments of the licence callback of that system (see + The service-side hooks). It gets only the arguments that it declares.
    • The key IDs are on the DRM object of the track (track.drm[0].kids) when the hook runs. A service that needs its own request shape builds the request in the hook.
    • -
    • The challenge of every other track goes to get_playready_license or get_widevine_license, as before.
    • +
    • The hook gets only the challenges of FairPlay-only tracks. The challenge of every other track goes to + get_playready_license or get_widevine_license.

    The DRM system of the challenge is the drm_preference of the track, else the system of the configured CDM. For a licence server that issues the content key to one system only, set drm_preference on the @@ -3335,23 +3297,13 @@ FairPlay-only tracks in get_tracks():

    if not track.drm: track.drm_preference = "playready"
    -

    Without the hook, no challenge goes to the licence server for a FairPlay-only track, and dl leaves -such a track out of the selection:

    -
      -
    • After the selection and the deferred DRM load, dl checks each selected video and audio track that has - no DRM object. An HLS track costs one request for its media playlist. A DASH track is FairPlay-only when - its ContentProtection elements name only DRM systems that unshackle cannot license and its init segment - has no Widevine or PlayReady pssh.
    • -
    • dl removes each FairPlay-only track and selects again, so the run takes the next best track that - licenses. It logs one line for each title: Left out 2 FairPlay-only tracks: EXAMPLE has no FairPlay bridge hook.
    • -
    • When a quality, range or codec flag matches only FairPlay-only tracks, the second selection skips the - title with its usual reason, and --best-available takes its usual fallback. When each selected video - or each selected audio track is FairPlay-only, dl skips the title.
    • -
    • --list shows every track and checks none. An import is not checked, because its export holds the - content keys.
    • -
    • With the hook, dl still leaves out FairPlay-only DASH tracks, because the bridge works for HLS only. - The line then reads Left out 1 FairPlay-only track: DASH has no FairPlay bridge.
    • -
    +

    The init segment (EXT-X-MAP) of the track must name a real key ID in its tenc box. When the tenc +key ID is all zeros and the playlist has one key URI, the pssh boxes of the init segment can name it. +unshackle never reads a key ID from the skd:// URI.

    +

    Without the hook, dl leaves each FairPlay-only track out of the selection and takes the next best +track that licenses. It logs one line for each title: +Left out 2 FairPlay-only tracks: EXAMPLE has no FairPlay bridge hook. With the hook, dl still leaves +out FairPlay-only DASH tracks, because the bridge works for HLS only.

    A licence server that does not issue the content key refuses the challenge, and can flag the device. Test the route with a licence-only run (--cdm-only --skip-dl) before a service relies on it.

    Decrypting a cbcs file yourself

    @@ -3372,41 +3324,8 @@ to None, and after it your on_track_downloaded runs an runs on the server: the client sends the samples through the samples route, so a decrypter that needs a process on the server also works for a remote client.

    A playlist whose key tag unshackle cannot license

    -

    A media playlist can name only a key system that unshackle does not read, such as an skd:// key -over cbcs media, while the licence server of the platform also issues the same content key over -PlayReady or Widevine. HLS.download_track licenses such a track when all of these conditions are true:

    -
      -
    • The service has the FairPlay bridge hook.
    • -
    • The track has no DRM object.
    • -
    • Every EXT-X-KEY of its media playlist is SAMPLE-AES or SAMPLE-AES-CTR for a DRM system - unshackle cannot license, or METHOD=NONE. A segment under METHOD=NONE must have an init segment - that no encrypted segment uses: a decrypter that reads the encrypted init segment decrypts the clear - samples too. A tag with KEYFORMAT="identity", or with no KEYFORMAT, names no DRM system: each - encrypted segment also needs a tag of a DRM system.
    • -
    • The drm_preference of the track, or else the configured CDM, is PlayReady or Widevine.
    • -
    • The init segment (EXT-X-MAP) of the track names a key ID in its tenc box. When the tenc key ID is all - zeros, the playlist must have one key URI, and each init segment under the key tag must give the same - key ID: its tenc key ID, or else the one key ID that its pssh boxes name. A clear init segment, - such as the one of a clear lead or tail, does not count. MPEG-TS media has no init segment.
    • -
    • The init segment does not change without an EXT-X-DISCONTINUITY.
    • -
    -

    The download reads the key ID from the init segment, builds a DRM object for that DRM system with -drm_stub, and sends the challenge to the hook. Over --remote the tracks reply tells the client that -the service on the server has the hook. The server reads the same key ID at the licence step, accepts -the DRM object of the client and sends the challenge to the hook of its service. A server that cannot -read the key ID refuses the challenge. A licence that gives no content key stops the track before it -downloads a segment. With the server CDM, the batch licence names the key IDs that the server read, so an -answer without their content keys stops the track in the same way. A content key that does not decode -the downloaded track stops the track with an error, and unshackle keeps no output file.

    -

    unshackle reads one key ID from each init segment. So it licenses a playlist that changes its content key -correctly only when each content key has its own init segment with a real tenc key ID, after an -EXT-X-DISCONTINUITY. When the first key ID is real, the download also reads the tenc key ID of -each other init segment of the encrypted segments, and licenses each real key ID in its own licence step. A -PlayReady DRM object then has one header for each key ID, because the header of drm_stub holds -one key ID. A key ID that gets no content key stops the track before it downloads a segment. An -init segment that gives no real key ID does not count.

    A service that must choose the DRM system itself, or one that knows the key ID, puts the DRM object -on the track:

    +on the track and needs no FairPlay bridge hook:

    1. Read the key ID from the init segment of the encrypted segments. HLS.get_track_kid_from_init returns it for the track, a reader of init segments (HLS.init_reader(playlist, session)) and that init segment.
    2. @@ -3416,24 +3335,16 @@ on the track:

    3. Let your licence callback send the challenge to the server that issues that key.

    drm_stub builds the header from the key ID alone, so this works with a licence server that goes -by the key ID, not with one that checks a header a packager signed. A platform can issue the -content key of one package of a title and refuse another. When a track carries a Widevine or PlayReady DRM -object and every EXT-X-KEY of its playlist is SAMPLE-AES or SAMPLE-AES-CTR for a key system -unshackle cannot license, or METHOD=NONE under the same condition, HLS.drop_unsupported_keys removes the -tags from the parsed playlist. -The download then licenses and decrypts the track with the DRM object of the track. This works for -one content key per track: the key changes of the playlist go with the tags. This limit also -applies to a DRM object that the download builds. Any other track stops with -None of the key systems are supported before it downloads a segment.

    -

    A DASH track with no DRM object stops with the same error when its init segment has an encrypted -sample entry. A DASH track with no init segment stops after the download when the file has one, and -unshackle deletes the file. A service sample decrypter turns off both checks.

    +by the key ID, not with one that checks a header a packager signed. When every EXT-X-KEY of the +playlist names a key system that unshackle cannot license, unshackle ignores those tags and licenses +and decrypts the track with its DRM object, for one content key per track. Any other track that has +only such tags stops with None of the key systems are supported before it downloads a segment.

    How unshackle chooses a CDM and finds keys

    -

    CDM selection is config-driven: the cdm map resolves a service tag (and optionally the +

    The CDM choice comes from config: the cdm map resolves a service tag (and optionally the track quality or DRM type) to a device name, which load_cdm instantiates as a local -.wvd/.prd or a remote CDM. Before ever requesting a license, the framework tries an -in-process cache of content keys and the configured key vaults. Only unresolved KIDs -trigger an actual license request, and the framework writes newly licensed keys back to +.wvd/.prd or a remote CDM. Before ever requesting a licence, the framework tries an +in-process cache of content keys and the configured key vaults. The CDM makes a challenge only +for an unresolved KID, and the framework writes newly licensed keys back to every vault. This is why the same content key is rarely re-licensed twice. Users configure all of this in DRM and CDM and Key vaults. The DRM API reference gives @@ -3464,8 +3375,8 @@ prepared, all derived from the Click context (ctx) that dlself.session: a requests.Session with config.headers applied, a retry policy (total=5, backoff, retry on 429/5xx), and any resolved proxy already mounted. Pass this HTTP session into the manifest parsers and DRM calls so headers, cookies, and proxies flow - everywhere. (unshackle also ships an rnet-based TLS-fingerprinting HTTP session that the - newer session() factory uses and that the network config key configures.) + everywhere. To impersonate a browser TLS fingerprint, override get_session() to return an + rnet HTTP session from session() in unshackle.core.session, which the network config key configures.

  • self.credential: the active Credential (username:password[:extra]), populated by authenticate. unshackle uses its sha1 as the account hash for cache keys. A login with cookies only uses a hash of the path of its cookie file.
  • @@ -3477,46 +3388,8 @@ prepared, all derived from the Click context (ctx) that dltitle_cache_max_retention when an API call fails, and --no-cache bypasses it. If you put the cookies of a different account into the same cookie file, use --reset-cache once. -
  • self.track_request: the TrackRequest describing what the user asked for - (codecs, ranges, best-available), for use inside get_tracks.
  • -
    -

    A minimal service skeleton

    -
    services/EXMP/__init__.py
    from unshackle.core.service import Service
    -from unshackle.core.manifests import DASH
    -from unshackle.core.titles import Movie, Movies
    -
    -
    -class EXMP(Service):
    -    ALIASES = ("example",)
    -    GEOFENCE = ("us",)
    -
    -    def get_titles(self) -> Movies:
    -        data = self.session.get(f"https://api.example.com/title/{self.title}").json()
    -        return Movies([
    -            Movie(
    -                id_=data["id"],
    -                service=self.__class__,
    -                name=data["name"],
    -                year=data.get("year"),
    -                language=data.get("language"),
    -            )
    -        ])
    -
    -    def get_tracks(self, title) -> "Tracks":
    -        mpd_url = self.session.get(...).json()["manifest"]
    -        mpd = self.session.get(mpd_url).text
    -        return DASH.from_text(mpd, mpd_url).to_tracks(language=title.language)
    -
    -    def get_chapters(self, title):
    -        return []
    -
    -    def get_widevine_license(self, *, challenge, title, track):
    -        return self.session.post("https://lic.example.com/wv", data=challenge).content
    -
    -

    The directory name (EXMP) must match the class name exactly. That stem is the -service tag. Put your service in one of the directories.services paths.

    -
    +

    Creating a Service gives a complete minimal service.

    Where to go next

    @@ -681,34 +659,6 @@
    - - - - -
  • - - - - The filenames config key - - - -
  • @@ -771,6 +721,8 @@ + + @@ -1043,6 +995,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1235,7 +1352,7 @@ - Output & Naming + Output & Naming Options @@ -1319,7 +1436,7 @@ - Key Vaults + Key Vault Options @@ -1439,6 +1556,8 @@ + + @@ -1550,14 +1669,6 @@ - - - - - - - - @@ -1583,9 +1694,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1864,17 +1903,17 @@ - + -
    - - - - -
  • - - - - The filenames config key - - - -
  • @@ -2202,7 +2221,7 @@
  • The config filename

    The main configuration file is always named unshackle.yaml. It uses plain YAML. You can open and edit it in any text editor, or manage individual values with the unshackle cfg command.

    -

    If you have never created one, that is fine: unshackle runs entirely on built-in defaults when no config file exists. The file only needs to contain the keys you want to change from their defaults.

    +

    The file only needs to contain the keys you want to change from their defaults, with one exception: dl needs an output_template to name its files, and stops with an error without one. unshackle setup writes a first config that has one.

    Where the config file lives

    When unshackle starts, it searches a fixed list of locations and uses the first one that exists. In order of priority:

    @@ -2257,237 +2276,82 @@

    Not sure which file is being used?

    Operate unshackle env info. It prints the path unshackle loaded the config from, or tells you that it found none. It also prints every directory unshackle currently uses.

    -

    The config is read exactly once, when unshackle starts. If you edit the file, the change takes effect on the next command.

    +

    unshackle reads the config once, when it starts. If you edit the file, the change takes effect on the next command.

    Top-level structure

    unshackle.yaml is a flat map of top-level config keys. Each config key configures one area of the program. You include only the config keys you want to change. Everything else falls back to its default.

    -

    Here is a small, realistic example that sets a download location, a release tag, a default CDM, and one service's credentials:

    +

    Here is a small, realistic example that sets a download location, filename templates, a release tag, a default CDM, and one service's credentials:

    unshackle.yaml
    # Where finished downloads are written
     directories:
       downloads: ~/Videos/unshackle
     
    -# Release group tag appended to filenames
    -tag: MYGRP
    -
    -# Default Widevine/PlayReady device to use, with per-service overrides
    -cdm:
    -  default: my_device_l3
    -  EXAMPLE: my_device_l1
    +# How dl names movie and episode files (dl needs this key)
    +output_template:
    +  movies: "{title}.{year}.{quality}.{source}.WEB-DL.{audio_full}.{video}-{tag?}"
    +  series: "{title}.{season_episode}.{episode_name?}.{quality}.{source}.WEB-DL.{audio_full}.{video}-{tag?}"
    +
    +# Release group tag appended to filenames
    +tag: MYGRP
     
    -# Per-service login details (service tag -> "username:password")
    -credentials:
    -  EXAMPLE: my_email@example.com:hunter2
    -
    -# Default HTTP headers merged into every request
    -headers:
    -  Accept-Language: en-US,en;q=0.9
    +# Default Widevine/PlayReady device to use, with per-service overrides
    +cdm:
    +  default: my_device_l3
    +  EXAMPLE: my_device_l1
    +
    +# Per-service login details (service tag -> "username:password")
    +credentials:
    +  EXAMPLE: my_email@example.com:hunter2
    +
    +# Default HTTP headers merged into every request
    +headers:
    +  Accept-Language: en-US,en;q=0.9
     
    -

    The top-level keys group loosely into these areas:

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    AreaExample keys
    Downloading & DRMdl, cdm, remote_cdm, decryption
    Networkingnetwork, headers
    Credentials & cookiescredentials, firefox_cookies
    Tracks & muxingsubtitle, audio, muxing, language_tags
    Key vaultskey_vaults, vault_timeout
    Proxies & remoteproxy_providers, remote_services, serve, services
    Naming & taggingtag, output_template, chapter_fallback_name
    External API keystmdb_api_key, tvdb_api_key, simkl_client_id, ipinfo_api_key, metadata_providers
    Behaviour & loggingupdate_checks, redact_paths, debug, unicode_filenames
    Post-scriptspost_scripts
    Pathsdirectories, filenames
    -

    For the full list with types and defaults, see the Configuration Reference.

    +

    The quick index of the Configuration Reference lists every top-level key, grouped by area, with a link to its types and defaults.

    Unknown keys are silently ignored

    unshackle does not validate your config against a schema. If you misspell a config key, unshackle skips it and uses the default. You will not get an error. Examine the config key names (and their nesting) if a setting does not seem to apply.

    Setting download defaults (dl:)

    If you always pass the same dl flags (a language, a resolution, a codec), put them under a -dl: config key once and unshackle applies them to every download. Any flag from -Downloading works here. The config key is the flag's long name with -dashes turned into underscores (--best-available → best_available).

    +dl: config key once and unshackle applies them to every download. An explicit flag on the +command line still wins.

    unshackle.yaml
    dl:
       lang: [en]          # -l en
       quality: [1080]     # -q 1080
    -  vcodec: [H.265]     # -v H.265
    -  sub_format: srt     # convert subtitles to SRT
    -  downloads: 2        # two tracks at once
    +  sub_format: srt     # convert subtitles to SRT
     
    -

    You can still override any of these on the command line for a one-off. An explicit flag -always beats the config default. You can also scope defaults to a single service by nesting a -dl: block under it:

    -
    Per-service defaults
    dl:
    -  lang: [en]          # default for everything
    -services:
    -  EXAMPLE:
    -    dl:
    -      lang: [en, ja]  # Example downloads English + Japanese
    -
    -
    -

    A few keys are named after the flag's internal name

    -

    Most keys are obvious, but set these exact ones: range (-r), list (--list), -tmdb_id (--tmdb), imdb_id (--imdb), tvdb_id (--tvdb), no_atmos (--noatmos), and output_dir -(-o). The Configuration Reference has the full list -and every available config key.

    -
    +

    The dl reference gives how a flag becomes a config key, the +keys that do not follow that rule, per-service defaults and the order in which the values +apply.

    The directory layout

    -

    The directories config key controls where unshackle reads and writes its various files. Each directory has a sensible default, and you can override most of them by giving a new path. A path can use ~ for your home directory.

    -
    unshackle.yaml
    directories:
    -  downloads: ~/Videos/unshackle
    -  temp: /mnt/fast/unshackle-temp
    -  cache: ~/.cache/unshackle
    +

    The directories config key controls where unshackle reads and writes its files. Each +directory has a default, and a path can use ~ for your home directory:

    +
    unshackle.yaml
    directories:
    +  downloads: ~/Videos/unshackle
    +  temp: /mnt/fast/unshackle-temp
     
    -

    The directories unshackle uses:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NamePurposeOverridable
    downloadsDefault output folder for finished downloadsYes
    tempTemporary working files during a downloadYes
    cacheCache store (title cache, update checks, service caches)Yes
    cookiesPer-service cookie filesYes
    logsLog filesYes
    exportsExport JSONsYes
    wvdsWidevine devices (.wvd files)Yes
    prdsPlayReady devices (.prd files)Yes
    dcslDCSL dataYes
    servicesSearch paths for service code (see below)Yes
    commandsCLI command modulesYes
    vaultsVault modulesYes
    fontsBundled fontsYes
    -
    -

    Some directories cannot be moved

    -

    unshackle protects five internal entries: app_dirs, core_dir, namespace_dir, user_configs, and data. If you write any of them under directories, unshackle ignores the override. This is intentional. Those paths come from the package location and your OS user directories.

    -
    -

    The services directory is special

    -

    Unlike the other entries, services is a list, and each entry can be either a local folder or a remote repository. This lets you mix your own local services with services pulled from Git:

    -
    unshackle.yaml
    directories:
    -  services:
    -    - you/your-services          # a GitHub owner/repo shorthand
    -    - https://example.com/private-services.git
    -    - ~/code/local-services      # a local folder
    -
    -

    unshackle examines the entries in the order you wrote them, and the first source to define a given service tag wins. Put local folders last if you want them to act as fallbacks and not overrides. unshackle clones remote repositories on first use and refreshes them at most once a day. See Creating a Service for how service discovery and repositories work.

    -

    The filenames config key

    -

    Alongside directories, the filenames config key lets you override the templates unshackle uses when it names its own working and log files. Two examples are the log filename and the temporary chapters file. Most users never need to touch this. The Configuration Reference gives the available names and their default templates.

    +

    The Directories reference lists every directory with its default, +the directories that you cannot move, and how the services list loads services from local +folders and Git repositories. The filenames config key on the same page changes the names +of unshackle's own working and log files.

    Editing the config with unshackle cfg

    You do not have to edit unshackle.yaml by hand. The unshackle cfg command reads and writes individual values for you, creating the config file (and its parent directory) if it does not exist yet.

    Read a single value by passing its config key. Nested config keys use dot notation:

    -
    $ unshackle cfg tag
    -$ unshackle cfg cdm.default
    +
    $ unshackle cfg tag
    +$ unshackle cfg cdm.default
     

    Set a value by passing a config key and a value:

    -
    $ unshackle cfg tag MYGRP
    -$ unshackle cfg cdm.default my_device_l3
    +
    $ unshackle cfg tag MYGRP
    +$ unshackle cfg cdm.default my_device_l3
     

    unshackle parses the value as a Python literal, so write booleans as True/False and quote the strings inside a list ("['en']"). unshackle stores anything that is not valid Python literal syntax as a plain string:

    -
    $ unshackle cfg update_checks False
    -$ unshackle cfg vault_timeout 30
    +
    $ unshackle cfg update_checks False
    +$ unshackle cfg vault_timeout 30
     

    Remove a value with --unset:

    -
    $ unshackle cfg cdm.default --unset
    +
    $ unshackle cfg cdm.default --unset
     

    Show everything currently set with --list:

    -
    $ unshackle cfg --list
    +
    $ unshackle cfg --list
     

    When it writes, unshackle cfg targets the config file that unshackle loaded. If none exists yet, it makes unshackle.yaml in the unshackle package folder (location 1 above):

      diff --git a/getting-started/installation/index.html b/getting-started/installation/index.html index 4436c723..f51dfc45 100644 --- a/getting-started/installation/index.html +++ b/getting-started/installation/index.html @@ -347,28 +347,6 @@ - - - - - - - -
    • - - - - - - - API Reference - - -
    • - - - -
    @@ -855,6 +833,8 @@ + + @@ -1127,6 +1107,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1319,7 +1464,7 @@ - Output & Naming + Output & Naming Options @@ -1403,7 +1548,7 @@ - Key Vaults + Key Vault Options @@ -1523,6 +1668,8 @@ + + @@ -1634,14 +1781,6 @@ - - - - - - - - @@ -1667,9 +1806,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1948,17 +2015,17 @@ - + -
    @@ -782,6 +760,8 @@ + + @@ -1054,6 +1034,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1246,7 +1391,7 @@ - Output & Naming + Output & Naming Options @@ -1330,7 +1475,7 @@ - Key Vaults + Key Vault Options @@ -1450,6 +1595,8 @@ + + @@ -1561,14 +1708,6 @@ - - - - - - - - @@ -1594,9 +1733,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1875,17 +1942,17 @@ - + -
    unshackle dl --latest-episode EXAMPLE 81234567
    -

    See Downloading for the complete flag reference, including -codec, bitrate, channel-layout, and track-type selection.

    +

    See the CLI reference for every flag, and +Downloading for codec, bitrate, channel-layout, and track-type selection.

    8. Where the output lands

    By default, unshackle writes finished files to the downloads directory. unshackle env info shows its exact path. A config from unshackle setup uses the @@ -2435,7 +2510,7 @@ command with -o:

    • unshackle writes movies as a single .mkv file named from your movies template.
    • unshackle groups TV episodes into a per-show / per-season folder (from your - series template) unless you pass --no-folder.
    • + series template). --no-folder writes every title directly in the output directory.
    • unshackle builds the filename from your output_template and adds IMDb/TMDB/TVDB IDs to the file's metadata tags when available.
    @@ -2447,9 +2522,10 @@ command with -o:

    • Downloading. The full dl command: quality, codecs, languages, track selection, hybrid Dolby Vision, and output control.
    • -
    • Configuration. Every unshackle.yaml config key, plus - directories, key vaults, proxies, and naming templates.
    • -
    • REST API. Operate the serve server to drive downloads +
    • Configuration. Where unshackle.yaml lives and what a first + config holds. The Configuration Reference lists every + config key.
    • +
    • Server Overview. Operate the serve server to drive downloads over HTTP.
    diff --git a/guide/cli-reference/index.html b/guide/cli-reference/index.html index df45d91d..6e21615f 100644 --- a/guide/cli-reference/index.html +++ b/guide/cli-reference/index.html @@ -347,28 +347,6 @@ - - - - - - - -
  • - - - - - - - API Reference - - -
  • - - - -
    @@ -616,6 +594,8 @@ + + @@ -793,6 +773,23 @@
    + +
  • @@ -848,23 +845,6 @@ - -
  • @@ -1436,6 +1416,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1628,7 +1776,7 @@ - Output & Naming + Output & Naming Options @@ -1712,7 +1860,7 @@ - Key Vaults + Key Vault Options @@ -1832,6 +1980,8 @@ + + @@ -1943,14 +2093,6 @@ - - - - - - - - @@ -1976,9 +2118,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2257,17 +2327,17 @@ - + -
    + +
  • @@ -2549,23 +2644,6 @@ - -
  • @@ -3042,9 +3120,7 @@
  • SERVICE: a service tag (for example EXAMPLE1 or EXAMPLE2). Tags are case-insensitive and honour each service's aliases (example+, EXAMPLE2, and the other alias forms all give the same tag).
  • SERVICE ARGS: the title, URL, or ID, plus any service-specific options. These belong to the service, not to dl.
  • -
    -

    Typical downloads

    -
    # Best available 1080p SDR of a title
    +
    Typical downloads
    # Best available 1080p SDR of a title
     unshackle dl -q 1080 EXAMPLE 81234567
     
     # 4K HDR10, English audio + subs, from a URL
    @@ -3053,10 +3129,10 @@
     # A season range, HEVC video, EC3 audio
     unshackle dl -w S01-S03 -v H.265 -a EC3 SERVICE TITLE-ID
     
    -
    +

    Downloading shows how these flags work together for common tasks.

    -

    Config-driven defaults

    -

    You can give any dl flag a default under the dl: section of unshackle.yaml, and per-service under services.<TAG>.dl. Explicit command-line values (and environment values) always win over both. Service defaults only fill in options you did not set. See the configuration file guide.

    +

    Defaults from the configuration file

    +

    You can give any dl flag a default in the dl block of unshackle.yaml, and for one service under services.<TAG>.dl. A REST API download job takes most of these options: POST /api/download lists them.

    Quality, codec, bitrate & range

    @@ -3081,12 +3157,12 @@ - + - + @@ -3111,7 +3187,7 @@ - + @@ -3121,7 +3197,7 @@ - + @@ -3150,9 +3226,96 @@
    -v, --vcodec anyVideo codec(s). Accepts names or values: AVC/H.264/H264, HEVC/H.265/H265, VVC/H.266/H266, VC1/VC-1, VP8, VP9, AV1.Video codec(s). Accepts names or values: AVC/H.264/H264, HEVC/H.265/H265, VVC/H.266/H266, VC1/VC-1, VP8, VP9, AV1, LCEVC. unshackle selects an LCEVC track only when you name it, because it cannot play without its base video track.
    -a, --acodec anyAudio codec(s), comma-separated. Accepts AAC, AC3/DD, EC3/DD+/eac3/ddp, AC4/AC-4, OPUS, OGG/VORB/vorbis, DTS, DTSX/DTS-X, ALAC, FLAC, MP3.Audio codec(s), comma-separated. Accepts a name or a value from Audio codec values, and the aliases eac3 and ddp (EC3) and vorbis (OGG).
    -vb, --vbitrate
    -r, --range SDRColour range(s): SDR, HLG, HDR10, HDR10P (HDR10+), VIVID (HDR Vivid), DV, HYBRID.Colour range(s): SDR, HLG, HDR10, HDR10P (HDR10+), VIVID (HDR Vivid), DV, HYBRID. HDR10+ and "HDR Vivid" also work.
    --generate-dv
    -c, --channels -Audio channels; matches sub-layouts (5.1 ≈ 6.0).Audio channels, e.g. 5.1 or 2.0; matches sub-layouts (5.1 ≈ 6.0). An immersive layout such as 5.1.4 matches its total number of channels (-c 10).
    -naa, --noatmos
    +

    Audio codec values

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameValueCodec
    AACAACAdvanced Audio Coding
    AC3DDDolby Digital
    EC3DD+Dolby Digital Plus
    AC4AC-4Dolby AC-4
    OPUSOPUSOpus
    OGGVORBVorbis
    DTSDTSDTS
    DTSXDTS-XDTS:X Profile 2 (DTS-UHD)
    DTSHDDTS-HDDTS-HD High Resolution, Master Audio and Express
    MPEGHMPEG-HMPEG-H 3D Audio
    AV3AAudio VividAudio Vivid (AVS3-P3)
    ALACALACApple Lossless
    FLACFLACFLAC
    MP3MP3MPEG-1 Audio Layer III
    PCMPCMPulse-code modulation

    HYBRID range

    -

    -r HYBRID fetches both an HDR10/HDR10+/HDR Vivid base and Dolby Vision and merges them with dovi_tool. It requires the dovi_tool binary on your PATH.

    +

    -r HYBRID fetches both an HDR10/HDR10+/HDR Vivid base and Dolby Vision and merges them with dovi_tool. See Colour range for what it needs.

    Language & subtitles

    @@ -3217,7 +3380,7 @@ - + @@ -3227,7 +3390,7 @@ - + @@ -3237,7 +3400,7 @@ - + @@ -3265,7 +3428,7 @@ configuration file.

    - + @@ -3273,19 +3436,19 @@ configuration file.

    - + - + - + - +
    -fs, --forced-subs offInclude forced subtitle tracks.Include forced subtitle tracks. Without it, unshackle drops them.
    -fso, --forced-subs-only
    -fsl, --forced-s-lang noneLanguage(s) wanted for forced subtitles; implies -fs. A - prefix excludes.Language(s) wanted for forced subtitles; implies -fs. A - prefix excludes. Independent of --s-lang: -sl all -fsl en keeps every full subtitle and only the English forced track.
    --exact-lang
    --sub-format -Output subtitle format (SRT/srt, VTT/webvtt, ASS/ssa, TTML, SMI, ...), or original to keep the source format.Output subtitle format, converted only when necessary: a subtitle codec name or value, case-insensitive (SRT, VTT/webvtt, ASS, SSA, TTML, SMI, ...), or original to keep the source format.
    --sub-font
    -w, --wantedWanted episodes, e.g. S01-S05,S07, S01E01-S02E03. Supports exclusions with a leading - (e.g. -S03). For a split episode, .N picks one part (S01E01.2), a range must stay inside the episode (S01E01.1-S01E01.3), and S01E01 on its own takes every part. For a dated episode, a token can also be an ISO air date (2026-08-11) or a date range with a colon (2026-08-01:2026-08-31). For a music release, a token is a number of the track list (1-5, 1,3,7), or {disc}x{track} (2x3) when the release has more than one disc.Wanted episodes, e.g. S01-S05,S07, S01E01-S02E03. Supports exclusions with a leading - (e.g. -S03). For a split episode, .N picks one part (S01E01.2), a range must stay inside the episode (S01E01.1-S01E01.3), and S01E01 on its own takes every part. For a dated episode, a token can also be an ISO air date (2026-08-11) or a date range with a colon (2026-08-01:2026-08-31). For a music release, a token is a number of the track list (1-5, 1,3,7), or {disc}x{track} (2x3) when the release has more than one disc.
    --select-titles
    --latest-episodeDownload only the single most recent episode.Download only the single most recent episode. -w has no effect with it.
    --latest-episodes NDownload only the N most recent episodes.Download only the N most recent episodes, which can come from more than one season. A split episode counts as one episode, and all its parts download. -w has no effect with it.
    --max-downloads NStop after N titles have downloaded. A skipped title, or a title already in the completion archive, does not count.Stop after N titles have downloaded. A skipped title, or a title already in the completion archive, does not count. With --skip-dl or --no-mux, a title counts when its run completes. Each part of a split episode counts as one title. unshackle does not open the titles after the limit.
    --list-titlesList titles only; do not download.List every title the service returned, then stop. -w, --latest-episode and --latest-episodes do not apply to this list.
    @@ -3331,7 +3494,7 @@ configuration file.

    -ad, --audio-description -Include descriptive (audio-description) tracks. +Include descriptive (audio-description) tracks. Without it, unshackle drops them. -ado, --audio-description-only @@ -3366,7 +3529,7 @@ configuration file.

    --no-folder -Disable folder creation for TV shows. +Write the files directly in the output directory, with no folder for the title. Applies to every kind of title. --no-source @@ -3437,7 +3600,7 @@ configuration file.

    --tvdb-order -Renumber episodes to a TVDB season order: official (aired), dvd, absolute, alternate, or regional. Needs tvdb_api_key. +Renumber episodes to a TVDB season order: official (aired), dvd, absolute, alternate, or regional. Needs tvdb_api_key. See Episode ordering. -ce / --continuous-episodes @@ -3450,19 +3613,8 @@ configuration file.

    You cannot combine --tmdb, --imdb and --tvdb. Give one and unshackle finds the others from it, and writes all three to the tags. --anilist is outside that rule and pairs with one of them, which is how you set the western ID of an anime title yourself. -An ID with no metadata provider that can find it, such as --tmdb with no tmdb_api_key, -fails before the download starts. --anilist needs no API key, so it never fails this check.

    -
    -

    Episode ordering

    -

    A service does not always number a series the way TVDB's aired order does. Some services use -TVDB's alternate (Streaming) order for Futurama, for example. --tvdb-order works out which -order the service used, then renumbers the episodes into the order you asked for.

    -
    -

    Orders that do not cover the whole series

    -

    An order can ignore episodes the service carries. TVDB's dvd order for Futurama leaves -out the four movies. Those episodes keep their original numbering. If that would give two -episodes the same season/episode slot, and so the same filename, unshackle logs an error -and keeps the service's numbering unchanged. Pick an order that covers the whole series.

    +An ID with no metadata provider that can find it, such as --tmdb with no tmdb_api_key +or an ID whose providers metadata_providers leaves out, fails before the download starts. --anilist needs no API key, so it never fails this check.

    DRM, keys & decryption

    @@ -3474,12 +3626,16 @@ and keeps the service's numbering unchanged. Pick an order that covers the whole - - + + + + + + - + @@ -3491,7 +3647,7 @@ and keeps the service's numbering unchanged. Pick an order that covers the whole - +
    --cdm-only / --vaults-onlyUse only the CDM, or only Key Vaults, for key acquisition.--cdm-onlyRead no key vault, and get each content key that the run does not already hold from a licence. Over --remote, your own CDM licenses each track, and the run uses neither the server CDM nor the server vault. A run with no local CDM fails, and so does a remote session on the server's device.
    --vaults-onlyGet no licence. A content key that no key vault, export or earlier track gives fails the title. With both flags, the last one wins.
    --cdm <name>Use the named CDM device from the cdm config mapping for this run, ignoring the service/default mapping. Over --remote, that device licenses the remote session, not the server CDM.Use the named CDM device for this run, and ignore the cdm config mapping, its quality and Widevine/PlayReady entries included. Over --remote, that device licenses the remote session, not the server CDM.
    --skip-dl
    --exportExport track info and keys to a mediaexport JSON file in the exports directory.Write an export of each title's tracks, DRM init data and content keys to the exports directory.
    @@ -3526,7 +3682,7 @@ and keeps the service's numbering unchanged. Pick an order that covers the whole --remote -Use a remote unshackle server. +Use a remote unshackle server. See Remote sessions. --local @@ -3561,7 +3717,7 @@ and keeps the service's numbering unchanged. Pick an order that covers the whole --download-processes 1 -Split large segment batches (24+) across this many download processes to exceed the single-process throughput cap on multi-gigabit connections. Ignored while a speed limit is set: the cap is one shared budget, which extra processes cannot share, so the download stays in a single process. Also ignored when the service HTTP session carries state a child process cannot rebuild, such as a custom TLS adapter. +Split a batch of 24 or more segments across this many download processes, which share the --workers threads. One process tops out at about 1.3 Gb/s; 2 reaches 2.5GbE line rate on a fast CDN. Ignored while a speed limit is set (--speed-limit, or the share of global_speed_limit that serve gives a job): the limit is one budget for every thread of the process, which child processes cannot share. Also ignored when the service HTTP session carries state a child process cannot rebuild, such as a custom TLS adapter. --continue-downloads @@ -3591,12 +3747,12 @@ and keeps the service's numbering unchanged. Pick an order that covers the whole --list off -List available/would-be-downloaded tracks; do not download. +List the tracks of each title, then stop before track selection. --slow - -Inter-title delay. Bare --slow = 60-120s; --slow 20-40 = custom range (minimum 20s). +Delay between titles. Bare --slow = 60-120 s; --slow MIN-MAX (e.g. --slow 20-40) = a custom range in seconds, with MIN at least 5 and not more than MAX. @@ -3613,7 +3769,7 @@ and keeps the service's numbering unchanged. Pick an order that covers the whole

    Find titles on a service. Like dl, search is a group whose subcommands are the installed services, and it reuses dl's authentication, cookie, and proxy machinery.

    unshackle search [OPTIONS] SERVICE [QUERY...]
     
    -

    Each service defines its own query syntax. unshackle prints the results as a tree of titles with their service IDs. Feed an ID straight into dl.

    +

    Each service defines its own query syntax. unshackle prints the results as a tree of titles with their title IDs. Feed an ID straight into dl.

    unshackle logs in to the service before the search. A service that declares a search with no login is the exception: unshackle then reads no cookies and no credentials, and --profile has no effect.

    @@ -3653,27 +3809,21 @@ and keeps the service's numbering unchanged. Pick an order that covers the whole
    -
    -

    Example

    -
    unshackle search EXAMPLE "My Show"
    +
    search examples
    unshackle search EXAMPLE "My Show"
     unshackle search -p myprofile EXAMPLE "Another Show"
     unshackle search --proxy nordvpn:ca SERVICE "query"
     unshackle search --remote --server my_server SERVICE "query"
     
    -

    import

    Reconstruct a download (download → decrypt → mux) from an --export JSON file without re-contacting the service. It uses the DASH or ISM manifest that the export saved, or fetches the manifest again when the export has none. It injects the stored keys and then runs the normal dl pipeline. The service tag is read from the export file, not passed by you.

    unshackle import EXPORT_FILE [DL_ARGS...]
     

    unshackle forwards any dl options after the file verbatim, so you can override quality, range, proxy, and so on. The import selects tracks with the dl defaults, not with the selection of the export. Give the selection options of the export again, for example -r HYBRID for an export of HDR tracks.

    -
    -

    Example

    -
    unshackle import export.json
    +
    import examples
    unshackle import export.json
     unshackle import export.json -r HDR10 --proxy US
     
    -
    -

    The export file can be a mediaexport file from dl --export, an export from an older version of unshackle, or an export from unidl. The file must name the service it came from.

    +

    The export file can be an export from dl --export, an export from an older version of unshackle, or an export from unidl. The file must name the service it came from.


    tunnel-test

    Check --local-proxy before a real --remote run. The command finds the IP address that this @@ -3706,12 +3856,9 @@ through the tunnel. It stops at the first step that fails.

    unshackle setup
     

    The command takes no options and asks its questions at the prompt. It shows the missing external tools and downloads the ones you accept. It puts them in a binaries folder, in the package folder of a git clone or in your user data directory for a uv tool install. If no unshackle.yaml exists, it writes a first one: inside the clone, or to your user config directory for a uv tool install. It then makes the data folders and imports .wvd and .prd devices, one file or folder per answer, until you give an empty answer. It ends with a summary of the tools, the path of a config that it wrote, and a pointer to env check. You can run it again: it skips the tools it finds and never overwrites a config. Installation gives the full steps and where each file goes.

    -
    -

    Example

    -
    uv run unshackle setup   # from a git clone
    +
    setup examples
    uv run unshackle setup   # from a git clone
     unshackle setup          # from a uv tool install
     
    -

    cfg

    Read, set, delete, or show configuration values in unshackle.yaml without hand-editing YAML.

    @@ -3747,16 +3894,13 @@ through the tunnel. It stops at the first step that fails.

    Comments are stripped

    Writing a value through cfg rewrites the configuration file and removes all comments from it. If your config relies on comments, edit it by hand instead. Setting a value and using --unset together is an error. If a config key is set twice in the same block, every command warns with the line numbers of the two copies and uses the later copy. cfg stops without a change.

    -
    -

    Example

    -
    unshackle cfg --list                        # print entire config
    +
    cfg examples
    unshackle cfg --list                        # print entire config
     unshackle cfg serve.api_secret              # read a nested key
     unshackle cfg tag MYGROUP                    # set a string
     unshackle cfg update_checks false           # literal → boolean False
     unshackle cfg directories.downloads /mnt/dl # set a nested path
     unshackle cfg tag --unset                    # remove a key
     
    -

    env

    Inspect and manage the project environment.

    @@ -3843,19 +3987,16 @@ through the tunnel. It stops at the first step that fails.

    -
    -

    Example

    -
    unshackle env check
    +
    env examples
    unshackle env check
     unshackle env info
     unshackle env theme
     unshackle env clear cache
     unshackle env clear cache EXAMPLE   # one service only
     unshackle env clear temp
     
    -

    kv

    -

    Manage Key Vaults. You configure vaults under key_vaults in unshackle.yaml, each with a name, a type (sqlite, mysql, http, api), and type-specific options. unshackle normalises service tags automatically.

    +

    Manage Key Vaults. You configure vaults under key_vaults in unshackle.yaml. unshackle normalises service tags automatically.

    unshackle kv COMMAND [ARGS]...
     

    kv copy TO_VAULT FROM_VAULT...

    @@ -3884,7 +4025,7 @@ through the tunnel. It stops at the first step that fails.

    kv add FILE SERVICE VAULT...

    Add content keys to one or more vaults for a service. FILE contains one KID:KEY pair per line (32 hex : 32 hex, UTF-8). unshackle skips every line that does not match that form.

    kv search KID

    -

    Find a KID (32 hex characters, no dashes) in the configured vaults and report its content key.

    +

    Find a KID (32 hex characters; unshackle removes dashes) in the configured vaults and report its content key.

    @@ -3909,9 +4050,7 @@ through the tunnel. It stops at the first step that fails.

    kv prepare VAULT...

    Make service tables on vaults that use tables, for every installed service, where they do not already exist.

    -
    -

    Example

    -
    unshackle kv copy main backup1 backup2
    +
    kv examples
    unshackle kv copy main backup1 backup2
     unshackle kv copy main backup -s EXAMPLE
     unshackle kv copy main ~/Downloads/key_store.db -s EXAMPLE
     unshackle kv sync main mysql_vault
    @@ -3919,7 +4058,6 @@ through the tunnel. It stops at the first step that fails.

    unshackle kv search 0123456789abcdef0123456789abcdef -s EXAMPLE -v main unshackle kv prepare main mysql_vault
    -

    wvd

    Manage Widevine Device (.wvd) files. Devices live in the configured WVDs directory.

    @@ -3982,14 +4120,11 @@ through the tunnel. It stops at the first step that fails.

    -
    -

    Example

    -
    unshackle wvd add device.wvd
    +
    wvd examples
    unshackle wvd add device.wvd
     unshackle wvd parse nexus_6p_1234_l1
     unshackle wvd dump device.wvd ./out_dir
     unshackle wvd new "Nexus 6P" private_key.pem client_id.bin vmp.bin -t ANDROID -l 3
     
    -

    prd

    Manage PlayReady Device (.prd) files. Devices live in the configured PRDs directory. Each command runs the matching pyplayready command.

    @@ -4050,16 +4185,13 @@ through the tunnel. It stops at the first step that fails.

    Write the group key (zgpriv.dat) and the group certificate (bgroupcert.dat) of a device into OUT_DIR/<name>/. -o sets OUT_DIR; the default is the current directory. A version 2 device has no group key, so export writes only the certificate. If the folder is not empty, export writes nothing.

    prd inspect

    Show each certificate of a certificate chain: type, security level, expiry date, name, features and keys. Give -d with a .prd file, or -c with a chain file such as bgroupcert.dat.

    -
    -

    Example

    -
    unshackle prd new ./device_folder/
    +
    prd examples
    unshackle prd new ./device_folder/
     unshackle prd new zgpriv.dat bgroupcert.dat -o /out/dir
     unshackle prd reprovision mydevice.prd
     unshackle prd test mydevice.prd -sl 3000 -c aescbc
     unshackle prd export mydevice.prd -o ./out_dir
     unshackle prd inspect -d mydevice.prd
     
    -

    serve

    Serve your local Widevine/PlayReady devices and the REST API for remote access. Built on aiohttp.

    @@ -4122,7 +4254,7 @@ through the tunnel. It stops at the first step that fails.

    --remote-only off -Expose only the remote service session endpoints (health, services, search, session). Implies --api-only. +Expose only the remote session routes: /api/health, /api/services, /api/search, /api/session/*, /api/tunnel and /api/tunnel/check, and the dashboard routes when serve.dashboard.key is set. Implies --api-only. @@ -4139,15 +4271,12 @@ through the tunnel. It stops at the first step that fails.

    username: user
    -
    -

    Example

    -
    unshackle serve
    +
    serve examples
    unshackle serve
     unshackle serve -h 0.0.0.0 -p 8080
     unshackle serve --api-only
     unshackle serve --remote-only
     unshackle serve --caddy
     
    -

    util

    Various helper media utilities. When you give a command a directory, it processes every .mkv/.mp4 inside it in natural (S01E01 before S01E10) order.

    @@ -4226,20 +4355,17 @@ through the tunnel. It stops at the first step that fails.

    -
    -

    Example

    -
    unshackle util refresh-services
    +
    util examples
    unshackle util refresh-services
     unshackle util crop video.mkv 2.39:1
     unshackle util crop ./season/ 16:9 --pillar -o 10
     unshackle util range video.mkv --full
     unshackle util test video.mkv -m 0:v:0
     
    -

    See also

    diff --git a/guide/downloading/index.html b/guide/downloading/index.html index d666612a..3f45b1af 100644 --- a/guide/downloading/index.html +++ b/guide/downloading/index.html @@ -347,28 +347,6 @@ - - - - - - - -
  • - - - - - - - API Reference - - -
  • - - - -
    @@ -616,6 +594,8 @@ + + @@ -1102,10 +1082,10 @@
  • - + - Music tracks + Songs @@ -1314,28 +1294,6 @@ -
  • - -
  • - - - - Configuration defaults - - - - -
  • - -
  • - - - - Quick reference - - - -
  • @@ -1543,6 +1501,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1735,7 +1861,7 @@ - Output & Naming + Output & Naming Options @@ -1819,7 +1945,7 @@ - Key Vaults + Key Vault Options @@ -1939,6 +2065,8 @@ + + @@ -2050,14 +2178,6 @@ - - - - - - - - @@ -2083,9 +2203,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2364,17 +2412,17 @@ - + -

    Best-available and worst

    -

    By default a missing requested resolution is an error. Two flags change that:

    - - - - - - - - - - - - - - - - - -
    FlagBehaviour
    --best-available (--warn-only)If the requested resolution(s) are not present, continue with the best that is available instead of failing. Also softens missing video and audio languages and hybrid fallbacks, and with --all-drm a DRM system that does not license.
    --worstPick the lowest-bitrate video at each requested resolution. With no requested resolution, pick the lowest-bitrate video at the lowest resolution.
    +

    By default a missing requested resolution is an error. +--best-available and --worst change that: +the first continues with the best resolution that is available, and the second picks the +lowest-bitrate video.

    A quality in the config counts as a requested resolution. When --best-available finds none of the requested resolutions, --worst also picks from the lowest resolution. In hybrid mode, that is the lowest resolution that has an HDR10, HDR10+ or HDR Vivid base.

    @@ -3302,97 +3320,16 @@ lowest resolution that has an HDR10, HDR10+ or HDR Vivid base.

    Video codec and colour range

    Codec

    -

    -v / --vcodec selects one or more video codecs. The default is any codec. It accepts -either enum names or their values, comma-separated.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NameValue
    AVCH.264
    HEVCH.265
    VVCH.266
    VC1VC-1
    VP8VP8
    VP9VP9
    AV1AV1
    LCEVCLCEVC
    -

    H264, H265 and H266 are aliases of AVC, HEVC and VVC.

    -

    An LCEVC (MPEG-5 Part 2) track only adds detail on top of its base video track and cannot play -alone, so unshackle selects it only when you ask for it with -v LCEVC.

    +

    -v / --vcodec selects one or more video codecs, +comma-separated, by name (HEVC) or by value (H.265). The default is any codec.

    Either spelling works
    unshackle dl -v HEVC   EXAMPLE 81234567
     unshackle dl -v H.265  EXAMPLE 81234567
     unshackle dl -v hevc,avc EXAMPLE 81234567
     

    Colour range

    -

    -r / --range selects one or more colour ranges. The default is SDR.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    RangeMeaning
    SDRStandard dynamic range (default)
    HLGHybrid Log-Gamma
    HDR10HDR10
    HDR10PHDR10+ (-r HDR10+ also works)
    VIVIDHDR Vivid (-r "HDR Vivid" also works)
    DVDolby Vision
    HYBRIDFetch both an HDR10/HDR10+/HDR Vivid base and a DV track, then merge them
    +

    -r / --range selects one or more colour ranges. +The default is SDR. HYBRID fetches both an HDR10/HDR10+/HDR Vivid base and a DV track, +then merges them.

    Grab HDR10 and Dolby Vision in one run
    unshackle dl -q 2160 -r HDR10,DV EXAMPLE '...'
     

    --list labels a track that carries a second format as <range>+<format>:

    @@ -3530,50 +3467,18 @@ download and the HDR10 track are not changed.

    By default unshackle keeps the highest-bitrate rendition for each selected resolution/codec/range/language combination. One requested video language is one language here, also when it matches more than one regional tag (en can match -en-AU and en-GB). You can constrain this.

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FlagPurpose
    -vb / --vbitrateExact video bitrate in kbps.
    -ab / --abitrateExact audio bitrate in kbps.
    -vb-range / --vbitrate-rangeVideo bitrate range in kbps, e.g. 6000-7000; picks the highest within it.
    -ab-range / --abitrate-rangeAudio bitrate range in kbps, e.g. 128-256.
    -
    -

    Exact vs range are mutually exclusive

    -

    You cannot combine --vbitrate with --vbitrate-range, and likewise for the audio -pair. Pick one form.

    -
    +en-AU and en-GB). To pick a different bitrate, give an exact bitrate (-vb, -ab) +or a bitrate range (-vb-range, -ab-range); the +CLI reference describes each.

    Real bitrate probing

    Manifest-declared bitrates are sometimes rounded or wrong. Services often advertise a peak or nominal bandwidth that is far from the track's real average. This matters because a track's bitrate drives the track listing, the sort order, and the --vbitrate/--vbitrate-range selection above. A bogus declared value therefore makes -unshackle pick the wrong track. These flags probe the actual media size to compute a true -bitrate for the top renditions, overriding the manifest value:

    -
      -
    • -rvb / --real-video-bitrate: probe real video bitrates (per codec/range).
    • -
    • -rab / --real-audio-bitrate: probe real audio bitrates (per codec/channels/ - language). Slower than the video variant because there are more renditions to probe.
    • -
    +unshackle pick the wrong track. +-rvb and -rab probe the media size to calculate +the real bitrate of the top video and audio renditions, and override the manifest value. The +audio probe is slower, because there are more audio renditions to probe.

    Reading the probed numbers

    unshackle measures a single-file track (DASH SegmentBase/BaseURL) exactly. A @@ -3596,99 +3501,14 @@ non-fatal: the manifest value stays in place.

    Audio codec, channels, and Atmos

    Codec

    -

    -a / --acodec selects one or more audio codecs (comma-separated). The default is any.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NameValueCodec
    AACAACAdvanced Audio Coding
    AC3DDDolby Digital
    EC3DD+Dolby Digital Plus
    AC4AC-4Dolby AC-4
    OPUSOPUSOpus
    OGGVORBVorbis
    DTSDTSDTS
    DTSXDTS-XDTS:X Profile 2 (DTS-UHD)
    DTSHDDTS-HDDTS-HD High Resolution, Master Audio and Express
    MPEGHMPEG-HMPEG-H 3D Audio
    AV3AAudio VividAudio Vivid (AVS3-P3)
    ALACALACApple Lossless
    FLACFLACFLAC
    MP3MP3MPEG-1 Audio Layer III
    -

    unshackle accepts names, values, and a few aliases: eac3 and ddp both give EC3, -and vorbis gives OGG.

    +

    -a / --acodec selects one or more audio codecs, +comma-separated, by name, value or alias from the audio codec values. +The default is any.

    Prefer Dolby Digital Plus, fall back to AAC
    unshackle dl -a EC3,AAC EXAMPLE 81234567
     

    Channels and Atmos

    -
      -
    • -c / --channels: desired channel layout, for example 5.1 or 2.0. Matching is by - ceiling, so 5.1 implicitly matches a 6.0-reported layout. An immersive layout such as - 5.1.4 matches on its total number of channels, so -c 10 selects it.
    • -
    • -naa / --noatmos: exclude Atmos audio tracks from selection.
    • -
    +

    -c / --channels and -naa / --noatmos select a +channel layout, such as 5.1 or 2.0, and drop the Atmos tracks.

    A track is Atmos when its manifest says so: a DD+ JOC descriptor, an HLS CHANNELS value with JOC or ATMOS (16/JOC, 2/IMSA,ATMOS), or the Smooth Streaming HasAtmos attribute. A DASH manifest has no Atmos signal for AC-4, so a DASH AC-4 track is Atmos only when the service marks it.

    @@ -3712,7 +3532,7 @@ sample rate, such as "24-bit / 96 kHz".

    Languages

    Video and audio language

    -

    -l / --lang sets the wanted language(s) for both video and audio. The default is +

    -l / --lang sets the wanted language(s) for both video and audio. The default is orig, the title's original language.

    Original language plus English
    unshackle dl -l orig,en EXAMPLE 81234567
     
    @@ -3800,7 +3620,7 @@ keeps every subtitle language.

    Subtitles

    Selecting subtitle languages

    -

    -sl / --s-lang sets the wanted subtitle language(s). The default is all, so +

    -sl / --s-lang sets the wanted subtitle language(s). The default is all, so unshackle downloads every available subtitle language.

    Only English and Spanish subtitles
    unshackle dl -sl en,es EXAMPLE 81234567
     
    @@ -3808,7 +3628,7 @@ unshackle downloads every available subtitle language.

    Excluding languages. -sl all,-es keeps every subtitle language except Spanish, forced Spanish subtitles included.

    Requiring subtitles

    -

    --require-subs takes a list of languages that must exist. If any is missing, the +

    --require-subs takes a list of languages that must exist. If any is missing, the title fails, even under --best-available / --warn-only. Use it when a download is only worth keeping if a specific subtitle track is present.

    It gates the title. It does not select tracks: --s-lang still decides what to keep, and @@ -3836,7 +3656,7 @@ so never report a missing language on their own:

    orig resolves to the title language, and --exact-lang applies. Audio carried inside the video track counts. --no-audio and --no-video drop the matching requirement.

    A failed title stops the whole run. To skip that title and come back for it later, add ---skip-missing, or set skip_missing: true under dl: in unshackle.yaml. It also skips a +--skip-missing, or set skip_missing in the dl block. It also skips a title that has no track for a filter such as -q, -v, -r, -a or a language you request. A run with one title, or a run that skips every title, still fails. A REST API job lists each skipped title and the reason in skipped_titles.

    @@ -3844,53 +3664,12 @@ skipped title and the reason in skipped_titles.

    unshackle dl -al ko,en --require-audio ko --skip-missing -w S06 EXAMPLE 0ABC123

    Forced subtitles and output format

    -
      -
    • -fs / --forced-subs: include forced subtitle tracks (signs/foreign dialogue). - Without this flag, unshackle drops forced subtitle tracks from the selection.
    • -
    • -fsl / --forced-s-lang: keep forced subtitles only in these languages (implies - -fs). Works independently of --s-lang, so -sl all -fsl en grabs every full - subtitle but only the English forced track. It accepts exclusions too: -fsl all,-es - keeps every forced subtitle except the Spanish one, and -fsl -es means the same.
    • -
    • -fso / --forced-subs-only: keep only the forced subtitle tracks and drop every - other subtitle (implies -fs). --s-lang and -fsl still select the languages.
    • -
    • --sub-format: set the output subtitle format, converting only when necessary. - Accepts codec names/values and common aliases (srt, vtt, ass, ssa, ttml, - and the other codec aliases), or the literal original to keep the source format.
    • -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ValueFormat
    SRT / srtSubRip
    VTT / vttWebVTT
    ASS / assAdvanced SubStation Alpha
    SSA / ssaSubStation Alpha
    TTML / ttmlTimed Text Markup
    originalKeep the source format, no conversion
    +

    Forced subtitles carry signs and foreign dialogue. unshackle drops them unless you add +-fs, -fsl or -fso. -fsl takes exclusions too: +-fsl all,-es keeps every forced subtitle except the Spanish one. With -fso, --s-lang +and -fsl still select the languages.

    +

    --sub-format sets the subtitle format of the output, or +original keeps the source format.

    Convert subtitles to SRT
    unshackle dl --sub-format srt EXAMPLE 81234567
     
    @@ -3907,7 +3686,7 @@ select the tracks of a music release. By default, unshackle downloads al

    Wanted ranges

    -w / --wanted accepts season and episode ranges, comma-separated. Prefix a token with - to exclude it. For a music release, the same option takes track numbers. Read -music tracks below.

    +songs below.

    @@ -3951,7 +3730,7 @@ with - to exclude it. For a music release, the same option takes tr
    -

    Music tracks

    +

    Songs

    -w selects the tracks of an album, EP, single, or playlist. Give a track by its number. A release with more than one disc uses the {disc}x{track} form. A number on its own is a track on disc 1, which is the number the track list shows for a single-disc release. The @@ -4057,37 +3836,8 @@ the episode has no parts, rather than quietly handing you the whole episode. Use --list-titles to see which episodes carry parts.

    Other selection flags

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FlagBehaviour
    --select-titlesInteractively pick episodes of a series, or films when a title has more than one. Cannot combine with -w.
    --latest-episodeDownload only the single most recent episode.
    --latest-episodes NDownload only the N most recent episodes. The newest episodes can come from more than one season. A split episode counts as one episode, and all its parts download.
    --max-downloads NStop after N titles have downloaded. A skipped title, or a title already in the completion archive, does not count. With --skip-dl or --no-mux, a title counts when its run completes. Each part of a split episode counts as one title. unshackle does not open the titles after the limit.
    --list-titlesList every title the service returned, then stop. -w, --latest-episode and --latest-episodes are not applied to this listing.
    -

    When --latest-episode or --latest-episodes is set, -w has no effect.

    +

    --select-titles, --latest-episode, --latest-episodes and --max-downloads +also select the episodes to download.

    Grab just the newest episode
    unshackle dl --latest-episode EXAMPLE 81234567
     
    Grab the three newest episodes
    unshackle dl --latest-episodes 3 EXAMPLE 81234567
    @@ -4101,31 +3851,9 @@ the same command can run each day:

    A season that the limit stops before its last episode gets no season post-script event.

    Including and excluding track types

    You can restrict a download to certain track categories, either positively (only these) -or negatively (everything but these).

    -

    Only these types (*-only flags):

    -
      -
    • -V / --video-only
    • -
    • -A / --audio-only
    • -
    • -S / --subs-only
    • -
    • -C / --chapters-only
    • -
    -

    Skip these types (no-* flags):

    -
      -
    • -nv / --no-video
    • -
    • -na / --no-audio
    • -
    • -ns / --no-subs
    • -
    • -nc / --no-chapters
    • -
    • -nt / --no-attachments (cover art, subtitle fonts, and files the service attaches)
    • -
    -

    Additional track-type flags:

    -
      -
    • -ad / --audio-description: include descriptive (audio-description) tracks, which - unshackle drops by default.
    • -
    • -ado / --audio-description-only: keep only the descriptive tracks and drop the - standard audio. It does not need -ad. Add -A to download no video or subtitles.
    • -
    • --skip-subtitle-errors: if a subtitle fails to download, skip it and continue rather - than aborting the whole title. Video and audio failures remain fatal.
    • -
    +or negatively (everything but these). The CLI reference +gives the *-only and no-* flags, -ad and -ado for descriptive audio, and +--skip-subtitle-errors.

    The -only kind flags

    -ado and -fso each keep one kind of track inside its track type. They do not drop @@ -4156,84 +3884,24 @@ starting set of categories, then no-* subtracts from it. Attachment are always kept.

    Listing and dry runs

    -

    Before committing to a long download, inspect what unshackle would do:

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FlagEffect
    --listList the tracks the service exposes for each title, then stop. No selection, no download.
    --list-titlesList every title the service returned, then stop. -w, --latest-episode and --latest-episodes are not applied to this listing.
    --skip-dlSkip downloading but still acquire the decryption keys.
    --all-drmLicense each track with both Widevine and PlayReady. See Widevine and PlayReady on the same title.
    +

    Before a long download, check what unshackle would do with +--list, +--list-titles or +--skip-dl. To license +each track with both Widevine and PlayReady, see +Widevine and PlayReady on the same title.

    See the track selection without downloading
    unshackle dl -q 1080 -v H.265 -r HDR10 --list EXAMPLE 81234567
     

    Output and muxing

    Output location and folders

    -
      -
    • -o / --output: override the output directory for this run (otherwise unshackle - uses the configured downloads directory).
    • -
    • --no-folder: do not make a per-show folder for TV downloads.
    • -
    • --no-source: remove the service source tag from the filename and path.
    • -
    +

    -o / --output sends one run to another directory, and +--no-folder and --no-source change the folder and the file name.

    Send this download somewhere specific
    unshackle dl -o ~/Videos/incoming EXAMPLE 81234567
     

    Muxing behaviour

    By default, mkvmerge muxes the tracks of a movie or an episode into a single Matroska -(.mkv) file. These flags change how unshackle assembles the output:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FlagBehaviourDefault source
    --no-muxDo not mux; keep the individual track files.-
    --sampleDownload a short sample: 60 seconds from 2 minutes in, or --sample START-END for a window in seconds.-
    --include-sampleDownload the full title, then also cut a 60 second sample from each muxed file into a Sample folder.-
    --split-audioWrite a separate output file per audio codec instead of merging all audio.config muxing.merge_audio (on)
    --merge-videoMux video tracks that share a height, range, and codec into one file, so only language varies inside a file.config muxing.merge_video (off)
    +(.mkv) file. --no-mux, --sample, --include-sample, --split-audio and +--merge-video change how unshackle assembles the output.

    --sample needs a segmented track

    --sample downloads only the segments that hold the window, and mkvmerge cuts the output @@ -4253,7 +3921,7 @@ such as .flac, .m4a, or .mp3, and writes Read Music output files.

    After the download

    -

    --postscript "<command>" runs your own command once per output file, with unshackle's +

    --postscript "<command>" runs your own command once per output file, with unshackle's metadata substituted into {variable} placeholders. It is repeatable, and it replaces the post_scripts config for that run. No success post-script operates under --no-mux, because that run writes no muxed output; a song is the exception, because --no-mux does not apply to it. @@ -4268,14 +3936,11 @@ config and --postscript together, for every event and mode.

    post-scripts and for the full variable list, see Post-scripts.

    Naming tags

    -
      -
    • --tag: set the release group tag (overrides the configured tag).
    • -
    • --repack: add a REPACK tag to the output filename.
    • -
    +

    --tag and --repack change the tags in the file name.

    Custom group tag and a REPACK label
    unshackle dl --tag MYGRP --repack EXAMPLE 81234567
     

    Proxies

    -

    --proxy accepts a full proxy URI, a country or location code (resolved through your +

    --proxy accepts a full proxy URI, a country or location code (resolved through your configured proxy providers), or a provider:region form. See Proxies & VPN for the exact grammar.

    Proxy forms
    unshackle dl --proxy us EXAMPLE 81234567
    @@ -4283,78 +3948,27 @@ configured proxy providers), or a provider:region form. See
     unshackle dl --proxy controld:yul EXAMPLE 81234567
     unshackle dl --proxy 'http://user:pass@host:8080' EXAMPLE 81234567
     
    -

    Three related flags:

    -
      -
    • --no-proxy: force-disable all proxy use for this run.
    • -
    • --no-proxy-download: bypass the proxy for all downloads. The manifest, - license, and authentication requests still go through the proxy. This is useful when you - need the proxy only to satisfy geo-checks, not to move the bulk of the data.
    • -
    • --proxy-download: use a different proxy for all downloads. The manifest, - license, and authentication requests still go through --proxy. Takes the same forms - as --proxy.
    • -
    +

    --no-proxy, --no-proxy-download and --proxy-download change +which requests use the proxy. Use --no-proxy-download when you need the proxy only to pass +the geo-check of the service, not to move the bulk of the data.

    Performance and caching

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FlagPurpose
    --workers NThreads used per track for segment downloads. Default depends on the downloader.
    --adaptive-workersOpt-in: start the per-track worker count at --workers, reduce it when the CDN returns errors, then raise it again while the extra workers add measured throughput. The count never goes above --workers. Off by default (fixed worker count).
    --download-processes NOpt-in: split a large segment batch across N download processes, each with its own worker pool. A single process tops out around 1.3 Gb/s (Python interpreter limit); 2 reaches 2.5GbE line rate on fast CDNs. Only engages for batches of 24+ segments. Ignored while --speed-limit (or serve's global_speed_limit) is set: the cap is a per-job budget, which extra processes cannot share, so the download stays in a single process. Also ignored when the service HTTP session carries state a child process cannot rebuild, such as a custom TLS adapter. The download stays in a single process instead of running with the wrong settings. Default 1.
    --continue-downloadsOpt-in: keep completed segment files when a download fails so the next run resumes instead of restarting from zero. One-off enable of the continue_downloads config option, which documents what can and cannot resume.
    --downloads NNumber of tracks downloaded concurrently. Default 1.
    --slow [MIN-MAX]Add a delay between titles to look more like a real device. --slow alone means 60-120s; --slow 20-40 sets a custom range. Minimum 20s.
    --no-cacheBypass the title cache for this download.
    --reset-cacheClear the title cache before fetching.
    +

    The concurrency and caching flags control the parallel +downloads, the speed limit, the delay between titles and the title cache.

    Two tracks at a time, eight threads each
    unshackle dl --downloads 2 --workers 8 EXAMPLE 81234567
     
    Space out a season download
    unshackle dl -w S01 --slow 30-60 EXAMPLE 81234567
     

    Keys, vaults, and export

    -

    By default, unshackle checks your key vaults first and only asks a CDM to license -a content key when the vault misses. You can force one side or the other:

    -
      -
    • --cdm-only: only use the CDM (skip vaults). Over --remote, your own CDM licenses each track, and the run uses neither the server CDM nor the server vault. It needs a local CDM, and a remote session on the server's device fails.
    • -
    • --cdm <name>: use the named CDM device for this run, ignoring the cdm config mapping (including its quality and Widevine/PlayReady sub-entries). Over --remote, that device licenses the remote session, not the server CDM.
    • -
    • --vaults-only: only use key vaults and never license through the CDM. A missing - content key fails.
    • -
    +

    By default, unshackle checks your key vaults and only asks a CDM for a licence +when no vault has the content key; Keys, vaults, and caching +gives the full order. --cdm-only and --vaults-only force +one side or the other, and --cdm selects the CDM device for one run.

    Fetch keys only, no download
    unshackle dl --skip-dl EXAMPLE 81234567
     
    -

    --export writes a mediaexport JSON file into the configured exports directory. It holds -the manifest, the DRM init data, the content keys, the KIDs of each track and the title -metadata for each title. For a DASH or ISM title, it also holds the manifest as the service -left it, with the ad periods that the service skips. unshackle import reads it to reconstruct +

    --export writes an export into the configured exports +directory. It holds the manifest, the DRM init data, the content keys, the KIDs of each track +and the title metadata for each title. For a DASH or ISM title, it also holds the manifest +snapshot: the manifest as the service left it, with the filtered periods that the download skips. unshackle import reads it to reconstruct a download later, and gives each track only the content keys for its KIDs. The import uses the saved manifest, so it skips the same periods and does not fetch the manifest again. The importer also reads the older unshackle version: 2 files and unidl's own export files.

    @@ -4448,11 +4062,11 @@ title language, the video track takes the language of the default audio track. W the master playlist gives no audio language either, the import stops with a message.

    -

    Ad periods a service skipped stay skipped

    +

    Filtered periods stay filtered

    Some services skip DASH periods, such as ads, by a rule of their own. The export also records the periods the service kept as content_periods on each manifest. An import that must fetch the manifest again, because the file has no saved manifest or another tool wrote -it, downloads only those periods, also when the new manifest gives an ad period a new ID. +it, downloads only those periods, also when the new manifest gives a filtered period a new ID. When the new manifest has none of the recorded periods, the import logs a warning and keeps every period.

    @@ -4464,52 +4078,9 @@ To also take that source's title, year and original language, add --enrich of --tmdb, --imdb and --tvdb, and unshackle works the rest out from it. To stop the automatic lookups but keep the IDs you give, set disable_metadata in your config.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FlagExamplePurpose
    --tmdb--tmdb 27205Use this TMDB ID instead of an automatic search. Needs tmdb_api_key.
    --imdb--imdb tt1375666Use this IMDb ID instead of an automatic search. Needs no API key.
    --tvdb--tvdb 73871Use this TVDB ID instead of looking the series up. Needs tvdb_api_key.
    --anilist--anilist 21Use this AniList ID instead of an automatic search. mal:12345 is also accepted. Needs no API key.
    --enrich-Overwrite the show title, year and original language with the external source's. Requires one of --tmdb, --imdb, --tvdb, or --anilist.
    --tvdb-order--tvdb-order dvdRenumber episodes to a TVDB season order. Needs tvdb_api_key.
    -ce / --continuous-episodes-Number each season on from the season before it, so season two starts at S02E05 after four episodes.
    +

    The CLI reference describes --tmdb, --imdb, --tvdb, +--anilist, --enrich, --tvdb-order and --continuous-episodes, and the rules for +combining the ID flags.

    Force the right IMDb match, and keep the service's own naming
    unshackle dl --imdb tt1375666 EXAMPLE 81234567
     
    Force the match and take IMDb's title, year and language too
    unshackle dl --imdb tt1375666 --enrich EXAMPLE 81234567
    @@ -4601,12 +4172,6 @@ tries that provider first, also before AniList for an anime title, but never add
       Pair it with --tmdb, --imdb or --tvdb when the map has no entry for the title, or
       a wrong one. An ID that you give always wins over the map.
     
    -

    Give one of --tmdb, --imdb and --tvdb. You cannot combine them, because one ID -does the job on its own: unshackle finds the other two from it and writes all three to the -tags. -Passing two is an error rather than a silent choice between them. --anilist is the exception -and still pairs with one of the three, which is how you set the western ID of an anime title -yourself.

    The AniList ID map

    An AniList match, from a search or from --anilist, has no TMDB, IMDb or TVDB ID. unshackle @@ -4624,11 +4189,6 @@ single entry has that season. It reads the season number in the TMDB numbering a numbering, and when the two give different entries, it writes no AniList tag. A TMDB movie ID takes only the AniList entry of that movie. An AniList ID that you give with --anilist always wins over the map.

    -

    The ID you give must have a metadata provider that can find it, so unshackle makes sure of -that before it downloads anything. --tmdb without tmdb_api_key, or an ID whose metadata -providers your metadata_providers list leaves out, fails immediately with a message naming -what to set. --imdb needs no API key, because the imdb metadata provider is keyless -and in the default order.

    With --enrich, the title, year and original language are all replaced with the external source's values, whether or not the service already filled them in. A field the source does not answer with is left alone, and unshackle logs which fields those were, so a metadata provider @@ -4655,8 +4215,8 @@ holds back four season-one episodes to the start of season two. --tvdb-ord order the service used, then renumbers the episodes into the order you asked for:

    Download Futurama in DVD order
    unshackle dl --tvdb-order dvd EXAMPLE 81234567
     
    -

    Available orders are official (aired), dvd, absolute, alternate, and regional. Set -tvdb_order in your config to apply one by default.

    +

    Set tvdb_order in your config to apply +an order by default.

    Orders that do not cover the whole series

    An order can leave out episodes the service carries. TVDB's dvd order does not @@ -4666,7 +4226,7 @@ error and leaves the numbering untouched. Pick an order that covers the whole se

    Continuous episode numbers

    Some anime release groups number each season on from the season before it. With ---continuous-episodes, a season two that follows a four-episode season one starts at +--continuous-episodes, a season two that follows a four-episode season one starts at S02E05:

    Number season two on from season one
    unshackle dl -ce EXAMPLE 81234567
     
    @@ -4676,226 +4236,6 @@ Season 0 and episode 0 keep their numbers, and a season that already starts past season before it is not changed. The renumbering runs before --wanted, so select episodes by their new numbers, for example -w S02E05. A whole-season selection such as -w S05 matches episodes up to E999 only.

    -

    Configuration defaults

    -

    You can set every flag on this page as a default in your configuration file so you do not -have to type it each time, and you can scope defaults per service. See -Configuration file for the dl: block and -per-service overrides.

    -
    -

    Explicit flags always win

    -

    A value you pass on the command line (or through an environment variable) always takes -precedence over both the global dl: defaults and any per-service dl: overrides. -Config only fills in options you did not set explicitly.

    -
    -

    Quick reference

    -

    A condensed lookup of the most-used options. Use unshackle dl --help for the complete, -authoritative list.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FlagShortMeaning
    --quality-qTarget resolution(s), e.g. 1080,720.
    --vcodec-vVideo codec(s).
    --acodec-aAudio codec(s).
    --range-rColour range(s). Default SDR.
    --channels-cAudio channel layout.
    --noatmos-naaExclude Atmos audio.
    --lang-lVideo + audio language(s); default orig. - excludes, e.g. all,-es.
    --a-lang-alAudio-only language override. - excludes.
    --v-lang-vlVideo-only language override. - excludes.
    --s-lang-slSubtitle language(s); default all. - excludes, e.g. all,-es.
    --forced-subs-fsInclude forced subtitles.
    --forced-s-lang-fslForced subtitle language(s); implies -fs. - excludes.
    --sub-formatOutput subtitle format.
    --sub-fontFont for subtitles converted to ASS; implies --sub-format ASS.
    --wanted-wEpisode/season range, an air date, or a number of the track list for a music release (1-5, 2x3).
    --dailyFill missing air dates from TVDB during --enrich.
    --select-titlesInteractively pick episodes or films.
    --latest-episodeOnly the newest episode.
    --latest-episodes NOnly the N newest episodes.
    --max-downloads NStop after N downloaded titles.
    --video-only / --audio-only / --subs-only-V / -A / -SRestrict track types.
    --no-video / --no-audio / --no-subs / --no-chapters / --no-attachments-nv / -na / -ns / -nc / -ntSkip track types.
    --worstLowest-bitrate video at each requested resolution, or at the lowest resolution if none is set.
    --require-audioAudio languages that must exist. The title fails if one is missing.
    --require-videoVideo languages that must exist. The title fails if one is missing.
    --best-availableDegrade gracefully instead of failing.
    --skip-missingSkip a title that misses a required language or track, and continue with the next title.
    --output-oOutput directory for this run.
    --split-audio / --merge-video / --no-muxMuxing behaviour.
    --postscript / --no-postscriptRun a command after each output file, or run none.
    --proxy / --no-proxy / --no-proxy-download / --proxy-downloadProxy control.
    --workers / --downloads / --slowConcurrency and pacing.
    --list / --list-titles / --skip-dlDry runs.
    --cdm-only / --vaults-onlyContent key source control.
    --cdm <name>Pin one CDM device, bypassing the cdm config mapping.
    --exportExport track info and keys to JSON.
    --tmdb / --imdb / --tvdb / --anilist / --enrichMetadata overrides.
    --tvdb-orderRenumber episodes to a TVDB season order.
    -ce / --continuous-episodesNumber each season on from the season before it.
    diff --git a/guide/drm-and-cdm/index.html b/guide/drm-and-cdm/index.html index bd40caf8..24e5f3fa 100644 --- a/guide/drm-and-cdm/index.html +++ b/guide/drm-and-cdm/index.html @@ -347,28 +347,6 @@ - - - - - - - -
  • - - - - - - - API Reference - - -
  • - - - -
    @@ -616,6 +594,8 @@ + + @@ -1249,6 +1229,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1441,7 +1589,7 @@ - Output & Naming + Output & Naming Options @@ -1525,7 +1673,7 @@ - Key Vaults + Key Vault Options @@ -1645,6 +1793,8 @@ + + @@ -1756,14 +1906,6 @@ - - - - - - - - @@ -1789,9 +1931,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2070,17 +2140,17 @@ - + -
    +

    Who this page is for

    This is a practical configuration guide for end users of the unshackle CLI. A few sections have a Developer mark. They give internal behaviour that is @@ -2624,10 +2702,10 @@ title.

    line between two things:

    • A CDM (Content Decryption Module) is the trusted "black box" that turns a - license challenge into content keys. A device backs it: a file that carries + licence challenge into content keys. A device backs it: a file that carries the cryptographic identity of a real client, such as a phone or a browser.
    • A DRM system is the wrapper around a CDM that parses the protection metadata, - drives the challenge → license → keys handshake, and finally invokes an external + drives the challenge → licence → keys handshake, and finally invokes an external tool to physically decrypt the downloaded file.

    A handful of other terms show up throughout:

    @@ -2653,28 +2731,28 @@ line between two things:

    Challenge -The license request the CDM produces, sent to the service's license server. +The request the CDM produces, sent to the service's licence server. -License +Licence The server's response, which the CDM parses to recover the content keys.

    For a Widevine or PlayReady title, the flow is: unshackle reads the PSSH and KIDs -from the track, asks the CDM for a license challenge, sends that challenge to the -service's license server, hands the response back to the CDM to extract the keys, and +from the track, asks the CDM for a licence challenge, sends that challenge to the +service's licence server, hands the response back to the CDM to extract the keys, and then decrypts the file with those keys.

    Supported DRM systems

    unshackle has five DRM systems built in. Only the first two need a device file and a -license-server handshake. The rest are special cases. A DRM plugin adds another system (see +licence-server handshake. The rest are special cases. A DRM plugin adds another system (see DRM plugins).

    - + @@ -2682,19 +2760,19 @@ license-server handshake. The rest are special cases. A DRM plugin adds another - + - + - + @@ -2706,7 +2784,7 @@ license-server handshake. The rest are special cases. A DRM plugin adds another - + @@ -2768,29 +2846,13 @@ you. You must supply your own. The wvd and prd command provision device files once you have the raw cryptographic material.

    Providing a device with the wvd and prd commands

    -

    Device files live in dedicated directories, by default:

    -
    System Device fileLicense flowLicence flow Decryption
    Widevine (Google) .wvdCDM challenge → license server → CDM parses → keysCDM challenge → licence server → CDM parses → keys shaka-packager / mp4decrypt
    PlayReady (Microsoft) .prdCDM challenge (WRM header) → license server → CDM parses → keysCDM challenge (WRM header) → licence server → CDM parses → keys shaka-packager / mp4decrypt
    ClearKey (CENC), W3C EME org.w3.clearkey or the W3C common PSSH noneJSON {"kids":[...],"type":"temporary"} → license server returns a JWK Set. No CDM.JSON {"kids":[...],"type":"temporary"} → licence server returns a JWK Set. No CDM. shaka-packager / mp4decrypt
    ClearKey (CTR), AES-128-CTR noneThe service gives the per-track key and IV. No CDM, no license server.The service gives the per-track key and IV. No CDM, no licence server. in-process AES-CTR over the whole file
    - - - - - - - - - - - - - - - - -
    KindDefault directory
    Widevine .wvddata/WVDs
    PlayReady .prddata/PRDs
    -

    You can move these with the directories section of your unshackle.yaml:

    +

    Device files live in two directories: .wvd files in directories.wvds and .prd files +in directories.prds. Their defaults are in the +Directories reference. To move them, set +them under directories in your unshackle.yaml:

    unshackle.yaml
    directories:
    -  wvds: /home/george/unshackle-data/WVDs
    -  prds: /home/george/unshackle-data/PRDs
    +  wvds: ~/unshackle-data/WVDs
    +  prds: ~/unshackle-data/PRDs
     

    Widevine devices: the wvd command

    The wvd command group manages .wvd files.

    @@ -2859,7 +2921,7 @@ present, that is, a version 3 or higher device).

    $ unshackle prd test ./data/PRDs/mydevice.prd -sl 2000 -c aesctr
     
    -

    Runs a full challenge/license/keys cycle against Microsoft's public PlayReady +

    Runs a full challenge/licence/keys cycle against Microsoft's public PlayReady test server and prints the returned keys, confirming the device works. -sl/--security-level accepts 150, 2000, or 3000 (default 2000). -c/--ckt accepts aesctr or aescbc.

    @@ -2887,10 +2949,10 @@ fallback:

    Lookups are case-insensitive.

    The device name is the file name

    -

    A device named chromecdm_l3 in the config resolves to chromecdm_l3.wvd in the -WVDs directory (or chromecdm_l3.prd in the PRDs directory). It may also be the -name of a remote CDM defined in remote_cdm. See -Remote CDMs below.

    +

    A device named chromecdm_l3 in the config resolves to a remote CDM of that name in +remote_cdm (see Remote CDMs below), else to a device file such as +chromecdm_l3.wvd in the device directories. The +cdm reference gives the lookup order.

    Advanced selection: by quality, DRM, or profile

    Instead of a plain name, a cdm entry can be a nested mapping, letting unshackle pick @@ -2933,7 +2995,7 @@ fallback.

    A CDM can operate in two places:

    • A local CDM loads a .wvd or .prd device from your machine and performs the - challenge/license/keys handshake locally. This is what the cdm mapping above + challenge/licence/keys handshake locally. This is what the cdm mapping above resolves to by default.
    • A remote CDM delegates the CDM operations to an HTTP API. Your device (and its secrets) live on the remote CDM host. unshackle sends it PSSH/challenge data and @@ -2962,9 +3024,8 @@ standard pywidevine "serve" endpoint:

      cdm: default: my_wv_remote
    -

    security_level defaults to 3000 if omitted. unshackle reads field names -case-insensitively, so Device Type/device_type, System ID/system_id, and the -other field names are all accepted.

    +

    The remote_cdm reference gives the default +of each field and the two spellings of each field name.

    PlayReady remote CDM

    If the device type is PLAYREADY, unshackle routes the entry to the pyplayready remote CDM:

    @@ -3000,10 +3061,9 @@ includes an intelligent key-caching layer:

    unshackle sends the API key as the decrypt-labs-api-key header. If you do not write secret on the entry, unshackle falls back to the global decrypt_labs_api_key value. -If neither is present it raises an error. The host defaults to -https://keyxtractor.decryptlabs.com. PlayReady devices (SL2/SL3) default to -security level 2000/3000 respectively. Widevine devices default to -system_id: 26830, security_level: 3.

    +If neither is present it raises an error. The +decrypt_labs fields give the host, +system ID and security level that unshackle uses when you leave them out.

    Custom API (custom_api)

    For an arbitrary CDM HTTP API, type: custom_api provides a fully configurable client that adapts to almost any request/response shape through YAML alone. A minimal example:

    @@ -3077,9 +3137,10 @@ globally, or a per-service mapping:

    How the value is interpreted

    -

    The default is shaka. Only the exact value mp4decrypt selects mp4decrypt. -Anything else (including shaka) selects shaka-packager. Per-service lookups -are case-insensitive, with the default/DEFAULT entry used as the fallback.

    +

    The default is shaka. mp4decrypt selects mp4decrypt, and anything else +(including shaka) selects shaka-packager. The +decryption reference gives how unshackle +reads the value, and the tracks that use mp4decrypt whatever this setting says.

    The two backends give equivalent output for a standard CENC title. In most conditions shaka-packager is the better backend. Switch a specific service to @@ -3094,30 +3155,30 @@ ignores the decryption setting entirely. You do not need to configu

    When an HLS playlist references a content key with an EXT-X-KEY tag, unshackle fetches the content key directly (from the given URI or an inline data: URL) and decrypts each segment in-process with AES-CBC. There is no device, no CDM, and no -license challenge, so you do not set anything up. unshackle decrypts such tracks +licence challenge, so you do not set anything up. unshackle decrypts such tracks automatically during download.

    The EXT-X-KEY URI must return a content key of exactly 16 bytes, or the download stops with an error. If a decrypted segment has no valid PKCS7 padding, unshackle keeps the output and logs one warning for the track, because the content key is possibly wrong.

    ClearKey over CENC (W3C EME org.w3.clearkey)

    -

    The CENC ClearKey scheme is a proper license flow, but the "license server" +

    The CENC ClearKey scheme is a proper licence flow, but the "licence server" returns the keys as a JWK Set and not a DRM-wrapped blob. unshackle builds a W3C EME request of the form:

    {"kids": ["<base64url-kid>", ...], "type": "temporary"}
     
    -

    It sends this to the manifest's license URL (or to whatever a service's ClearKey -license hook returns) and reads the JSON Web Key set back. You do not need a device +

    It sends this to the manifest's licence URL (or to whatever a service's ClearKey +licence hook returns) and reads the JSON Web Key set back. You do not need a device file. The decrypted file still goes through shaka-packager or mp4decrypt like any other CENC track, so the decryption setting applies.

    A DASH manifest can also give the KID of a ClearKey track with only the W3C common PSSH (urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b). The common PSSH can name KIDs for any DRM system, so unshackle reads it as ClearKey (CENC) only when the manifest and the init segment -give no other DRM system. This scheme has no license URL in the manifest, so the content key -must come from the service's ClearKey license hook or from a key vault.

    +give no other DRM system. This scheme has no licence URL in the manifest, so the content key +must come from the service's ClearKey licence hook or from a key vault.

    ClearKey over a whole file (AES-CTR)

    Some services encrypt one whole audio file with AES-128-CTR and give the content key and the IV with the track. unshackle decrypts the file in-process after the download. There is -no device, no CDM and no license challenge. The licence step of a download or of a --skip-dl run licenses +no device, no CDM and no licence challenge. The licence step of a download or of a --skip-dl run licenses the content key, so --list asks for none. The IV, the length of the header in front of the media and the signature the file must start with travel with the track list.

    Over --remote the track list carries no content key. After the track selection the client asks the server @@ -3229,81 +3290,38 @@ merged file once. The README of each plugin gives its device files, its tools an Vaults).

    Keys, vaults, and caching

    -

    Fetching a license is comparatively slow and, for some services, rate-limited. +

    Fetching a licence is comparatively slow and, for some services, rate-limited. unshackle therefore resolves each key ID in this order before ever contacting a -license server:

    +licence server:

      -
    1. Keys already known for the current DRM object.
    2. -
    3. An in-process cache of content keys, for the current dl run.
    4. +
    5. The content keys that a remote server gives over --remote, or that an export holds + for unshackle import.
    6. +
    7. The content keys that the run already holds: from the service, or from an earlier track.
    8. Your configured key vaults.
    9. -
    10. Only if still missing, a live license request.
    11. +
    12. Only if still missing, a licence from the CDM.
    -

    After a successful license request, unshackle writes the recovered keys back to all -configured vaults, so future downloads can skip the license server. Two flags let you -control this trade-off on the dl command:

    - - - - - - - - - - - - - - - - - - - - - -
    FlagEffect
    --vaults-onlyNever send a license request; use only cached/vault keys. Fails if a content key is missing.
    --cdm-onlyIgnore vaults for sourcing keys and always perform a fresh license request. Over --remote, your own CDM licenses each track, and the run uses neither the server CDM nor the server vault. A remote session on the server's device fails, and so does a run with no local CDM.
    --cdm <name>Use the named CDM device for this run instead of the one the cdm config maps for the service. Over --remote, that device licenses the remote session, not the server CDM.
    +

    After a successful licence, unshackle writes the recovered keys back to all +configured vaults, so future downloads can skip the licence server. +--vaults-only, --cdm-only and --cdm change +this for one dl run.

    See key vaults for how to configure vault backends.

    Debugging DRM issues

    -

    A few configuration toggles help when a title will not decrypt:

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    Config keyDefaultEffect
    debugfalseGlobal debug output.
    debug_keysfalseLog decryption keys.
    debug_requestsfalseLog HTTP requests to the console with -d, each request to the JSON debug log, and the request and response bodies as files in a folder beside it. The folder holds tokens and content keys as sent and received.
    +

    A few configuration toggles help when a title will not decrypt: debug, debug_keys (logs +the content keys) and debug_requests (logs each HTTP request, see +Debugging HTTP traffic). Their defaults and effects are in +the logging and debug reference.

    unshackle.yaml
    debug_keys: true
     debug_requests: true
     

    Keys and paths in logs

    -

    When you enable key logging, unshackle writes content keys (KID:key pairs) to the logs. +

    When you enable key logging, unshackle writes content keys (KID:KEY) to the logs. Treat those logs as sensitive. The unrelated redact_paths option (default true) masks local directory paths in log output.

    See also

      -
    • Downloading: the dl command and its DRM-related flags.
    • +
    • CLI reference: the DRM-related flags of the dl command.
    • Key vaults: caching content keys across downloads.
    • Configuration: the full unshackle.yaml reference.
    • Dependencies: installing shaka-packager and mp4decrypt.
    • diff --git a/guide/output-and-naming/index.html b/guide/output-and-naming/index.html index 76115aa2..85930722 100644 --- a/guide/output-and-naming/index.html +++ b/guide/output-and-naming/index.html @@ -347,28 +347,6 @@ - - - - - - - -
    • - - - - - - - API Reference - - -
    • - - - -
    @@ -616,6 +594,8 @@ + + @@ -935,28 +915,6 @@ @@ -1468,7 +1550,7 @@ - Output & Naming + Output & Naming Options @@ -1552,7 +1634,7 @@ - Key Vaults + Key Vault Options @@ -1672,6 +1754,8 @@ + + @@ -1783,14 +1867,6 @@ - - - - - - - - @@ -1816,9 +1892,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2097,17 +2101,17 @@ - + -
    - - -
  • - - - - Developer notes - - - -
  • @@ -1320,6 +1289,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + + + @@ -1512,7 +1649,7 @@ - Output & Naming + Output & Naming Options @@ -1596,7 +1733,7 @@ - Key Vaults + Key Vault Options @@ -1716,6 +1853,8 @@ + + @@ -1827,14 +1966,6 @@ - - - - - - - - @@ -1860,9 +1991,8 @@ - + + + + + + + + -
  • - - - - - - - - Error Responses - - - - - - - - -
  • - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2141,17 +2200,17 @@ - + -
    - - -
  • - - - - Developer notes - - - -
  • @@ -2763,10 +2819,9 @@ a query to a real proxy URL: basic static proxie

    Where proxies are configured

    All proxy provider configuration lives under the top-level proxy_providers: -config key in your unshackle.yaml. Each proxy provider has its own sub-key, and -the config keys inside it map directly onto that proxy provider's settings. See the -Configuration file page for where the -file lives and how unshackle loads it.

    +config key in your unshackle.yaml. Each proxy provider has its own sub-key. The +proxy_providers reference lists the config keys of each +proxy provider, with their types and defaults.

    The --proxy flag

    Five options on the dl command control proxying at download time:

    @@ -2810,7 +2865,7 @@ file lives and how unshackle loads it.

    Set a default proxy in config

    Like every dl flag, you can give --proxy a default in your configuration, so you do not have to pass it on every command. See -Downloading for how dl options and config defaults interact.

    +the dl block for how dl options and config defaults interact.

    --no-proxy-download

    Segment downloads are usually the largest share of traffic, and a residential-grade VPN @@ -2902,9 +2957,9 @@ directly, prefix the query (--proxy controld:us).

    Auto-loading providers

    Most providers only load when you configure them under proxy_providers:. Three are -special: ExpressVPN and Proton VPN also load automatically once their cache -file exists on disk (even with no YAML), and Hola loads automatically -whenever the hola-proxy binary is found on your PATH.

    +special: ExpressVPN also loads once its token cache exists on disk (even with no +YAML), Proton VPN once its cookie file exists, and Hola +whenever unshackle finds the hola-proxy binary.

    Connection feedback

    After a proxy provider resolves a query, unshackle prints a line so you can see @@ -3080,7 +3135,7 @@ network.

    Each request crosses the tunnel twice

    A request from the server goes to your machine and then to the service, so it takes longer than a request that the server sends directly. The segments do not go through the -tunnel: the client downloads them as before.

    +tunnel: the client downloads them as it does without one.

    A service that uses a server account does not work with --local-proxy, because the server logs in with its own account. If the tunnel drops, the client connects again, and a new request @@ -3127,8 +3182,7 @@ them:

  • If a country has a single proxy string, that proxy is always returned.
  • If it has a list and you give a plain country code, unshackle picks one at random. Append an index (de1, de2) to pin a specific entry.
  • -
  • unshackle normalises each URL (a missing scheme defaults to http) and validates it, - so it rejects a malformed URI up front and does not fail mid-download.
  • +
  • See the basic reference for the URI rules.
  • unshackle dl --proxy de2 EXAMPLE 81234567
     
    @@ -3383,140 +3437,31 @@ The <vpn-provider> must be one you have configured under pia
    and privateinternetaccess both map to private internet access).

    Configuration

    -

    Each VPN provider you want to use gets an entry under providers:, carrying its VPN type, -credentials, and how your region aliases map onto Gluetun's server selectors.

    +

    Each VPN provider you want to use gets an entry under providers:, with its VPN type, its +credentials, and how your region aliases map onto Gluetun's server selectors:

    unshackle.yaml
    proxy_providers:
       gluetun:
         providers:
    -      windscribe:
    +      nordvpn:
             vpn_type: wireguard
             credentials:
               private_key: YOUR_WIREGUARD_PRIVATE_KEY
    -          addresses: YOUR_WIREGUARD_ADDRESS
    -          preshared_key: YOUR_PRESHARED_KEY
    -        server_countries:
    -          us: US
    -          uk: GB
    -        server_cities: {}
    -        server_hostnames: {}
    -        extra_env: {}
    -      nordvpn:
    -        vpn_type: wireguard
    -        credentials:
    -          private_key: YOUR_WIREGUARD_PRIVATE_KEY
    -        server_countries:
    -          us: US
    -          de: DE
    -
    -    # Global settings (all optional)
    -    base_port: 8888
    -    auto_cleanup: true
    -    container_prefix: unshackle-gluetun
    -    auth_user: null
    -    auth_password: null
    -    verify_ip: true
    +        server_countries:
    +          us: US
    +          de: DE
     
    -

    Per-provider keys:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    KeyPurpose
    vpn_typewireguard (default) or openvpn.
    credentialsThe secrets for the tunnel; see the credential rules below.
    server_countriesMaps your region alias (e.g. us) to Gluetun's country value (e.g. US).
    server_citiesOptional. Maps an alias to a Gluetun city.
    server_hostnamesOptional. Maps an alias directly to a specific server hostname.
    extra_envOptional. Raw environment variables merged into the container last, for any Gluetun setting not covered above.
    -

    Credential rules by VPN type:

    -
    -
    -
    -
      -
    • private_key is always required.
    • -
    • surfshark, mullvad, and ivpn also require addresses.
    • -
    • windscribe additionally requires both addresses and preshared_key - (preshared_key may be an empty string, but the config key must be present). - Get both from the Windscribe WireGuard config generator.
    • -
    • NordVPN and Proton VPN need only private_key.
    • -
    -
    -
    -
      -
    • Requires username and password.
    • -
    -
    -
    -
    +

    The gluetun reference lists every config key of an entry, the global config keys +(base_port, auto_cleanup, verify_ip and others) and the credentials that each VPN +provider needs. For Windscribe WireGuard, get addresses and preshared_key from the +Windscribe WireGuard config generator.

    Which vpn_type should I pick?

    -

    WireGuard is the default because it can be faster, but it needs the fiddlier -credential setup above (private keys, and for some providers addresses and a -preshared_key). OpenVPN is the simplest to configure (only a username and -password) at the cost of some speed. If you start out, or if you have credential -trouble, OpenVPN is the path of least resistance. Switch to WireGuard when you want -the extra throughput.

    +

    WireGuard is the default because it can be faster, but it needs more credential +setup (private keys, and for some providers addresses and a preshared_key). +OpenVPN is the simplest to configure (only a username and password) at the cost of +some speed. If you start out, or if you have credential trouble, use OpenVPN. Switch to +WireGuard when you want the extra throughput.

    -

    Global keys:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    KeyDefaultPurpose
    base_port8888The first local port to expose proxies on. Additional containers take the next free ports.
    auto_cleanuptrueRemove containers on exit. If false, containers are only stopped, not deleted.
    container_prefixunshackle-gluetunPrefix for Docker container names.
    auth_user / auth_passwordnullOptional HTTP-proxy credentials. If set, the local proxy requires auth and the credentials are embedded in the proxy URL.
    verify_iptrueAfter connecting, verify the container's real exit IP and region.

    Region selection

    For a given query region, Gluetun resolves the server like this:

      @@ -3609,22 +3554,8 @@ servers:

      server_map: myserver: usny-newyork-2
      -

      Default file location:

      - - - - - - - - - - - - - -
      FileDefault path
      Token cache{cache}/vpn/expressvpn_tokens.json
      -

      Where {cache} is your configured cache directory.

      +

      The expressvpn reference lists every config key and the default +path of the token cache.

      Query forms:

      @@ -3658,11 +3589,6 @@ servers:

      The resolved proxy is an HTTPS proxy on port 443. On success, unshackle prints a location summary such as (USA - New York, #3 of 5): .214.

      -
      -

      Cache safety

      -

      unshackle writes ExpressVPN's token cache with 0600 permissions, so the refresh -token is never briefly world-readable.

      -

      NordVPN

      NordVPN uses your Service Credentials, not your normal NordVPN login. Make them from the NordVPN dashboard under manual @@ -3675,11 +3601,9 @@ setup. They are a long random username/password pair, not your email and passwor us: 1234 us:seattle: 5678 -

      Required keys: username, password. unshackle validates them up front: the -combined username and password must be exactly 48 alphanumeric characters (case-insensitive), and -the username must not contain an @. If validation fails, you have almost certainly used -your login credentials instead of your service credentials.

      -

      server_map is optional and maps a region (or code:city) to a pinned NordVPN server ID, or to a +

      unshackle checks the credentials when it loads: login credentials fail the check of the +nordvpn reference.

      +

      server_map is optional and pins a region to a NordVPN server ID, or to a selector (see Choose a server network). Its main use is to tune performance: for a given streaming service one specific server often performs noticeably better than NordVPN's recommended pick. So you can hard-code @@ -3728,7 +3652,7 @@ port 80 in 2021).

      Proton VPN

      Proton VPN supports two authentication methods, and unshackle can work with either. Note that free Proton accounts work, but Proton limits them to its free-tier exit countries.

      -
      +

      Proton's TV device-login flow gives a self-sustaining, refreshable sign-in. This is @@ -3764,27 +3688,8 @@ exactly why TV login is the better method for set-and-forget use.

      -

      Default file locations:

      - - - - - - - - - - - - - - - - - -
      FileDefault path
      Cookies{cookies}/vpn/protonvpn.txt
      Session cache{cache}/vpn/protonvpn.json
      -

      Proton VPN auto-loads if its cookie file exists. Like ExpressVPN, unshackle writes -its cache file with 0600 permissions.

      +

      The protonvpn reference lists every config key and the default paths +of the cookie file and the TV login cache.

      Cache vs cookie precedence

      If both a TV-login cache and a cookie file exist, unshackle prefers the cache @@ -3854,14 +3759,11 @@ them from the S us: us-dal us:seattle: us-sea

      -

      Required keys: username, password, validated with the same 48-character rule as -NordVPN (combined username+password must be 48 alphanumeric characters, case-insensitive, no @). +

      unshackle checks the credentials with the same 48-character rule as NordVPN. server_map optionally pins a server per region, or holds a selector (see Choose a server network). Give the server name from Surfshark's -server list, for example us-dal. A full hostname such as us-dal.prod.surfshark.com also -works. Surfshark does not use numeric server IDs. unshackle ignores a numeric or empty value -and logs a warning. A us:seattle entry applies only to that city query, and it does not -fall back to the us entry.

      +server list, for example us-dal; Surfshark has no numeric server IDs. The +surfsharkvpn reference gives the value rules.

      Query forms:

      @@ -3910,9 +3812,10 @@ time, and a pinned IP can stop working.

      because the local port is on your machine. The server then selects and pins the server with its own Surfshark configuration. This needs the server_proxy grant on your API key.

      Windscribe

      -

      Windscribe uses Service Credentials from its -OpenVPN config page. unshackle only makes -sure that a username and a password are present (there is no 48-character rule).

      +

      Windscribe uses its proxy Service Credentials, which Windscribe issues through its +ServerCredentials API. The OpenVPN and IKEv2 credentials of Windscribe's config +generator pages do not work on the proxy: it refuses them with 407. unshackle only makes +sure that a username and a password are present.

      unshackle.yaml
      proxy_providers:
         windscribevpn:
           username: YOUR_SERVICE_USERNAME
      @@ -3921,9 +3824,9 @@ sure that a username and a password are present (there is no 48-character rule).
             us: us-east.totallyacdn.com
             us:seattle: us-seattle.totallyacdn.com
       
      -

      Required keys: username, password. server_map optionally takes a selector (see +

      server_map optionally takes a selector (see Choose a server network), or maps a region (or -region:city) directly to a hostname.

      +region:city) directly to a hostname. See the windscribevpn reference.

      Query forms:

      @@ -3952,64 +3855,13 @@ sure that a username and a password are present (there is no 48-character rule).

      The returned proxy is HTTPS on port 443.

      -

      Developer notes

      -
      -

      One resolution path (developers)

      -

      dl, search, the REST API handlers and the remote-service client all load proxy -providers through load_proxy_providers() in unshackle/core/proxies/resolve.py. -The REST API, its download jobs and the remote-service client call it through -initialize_proxy_providers(), which leaves out Gluetun because Gluetun starts a -local Docker container. All paths read a value through resolve_proxy_value(), which -returns the proxy URI with the proxy provider, the query and the log line: a -controld:// resolver, a provider:query or a bare query tried against providers in -order, or else an explicit proxy URI or host:port.

      -

      The remote-service client resolves --proxy with its own -resolve_remote_proxy_arg(). It changes a controld: query to a controld:// -resolver for the server with get_remote_proxy(), and it removes Control D from a bare -query, because a loopback forwarder is of no use to a server on another machine.

      -
      -
      -

      Keeping service requests on the proxy (developers)

      -

      unshackle/core/utils/run_proxy.py holds the proxy rules for service traffic:

      -
        -
      • pin(session) stops environment and system proxies from overriding the proxy of a - requests HTTP session, and keeps the environment CA bundle. Call it on each requests - HTTP session that gets a proxy.
      • -
      • fallback_session() gives a core helper with no HTTP session (a manifest parser, a DRM - class) a session on the proxy of the service that called it.
      • -
      • An audit hook on socket.getaddrinfo and on socket.connect to a host name, and a - check in RnetSession.request, warn about requests from service code that do not use - the proxy. A service sets - proxy_exempt = True on an HTTP session that goes direct on purpose.
      • -
      -
      -
      -

      Implementing a new provider (developers)

      -

      Every proxy provider subclasses unshackle.core.proxies.proxy.Proxy and has three -methods:

      -
        -
      • __init__(self, **kwargs) receives its proxy_providers sub-dict splatted as - keyword arguments, so YAML keys map 1:1 to constructor parameters. Check the - configuration here, but make no request: every dl run builds every configured - proxy provider, even for a run with no proxy. Read the server or location catalogue - through a functools.cached_property, so the first query fetches it.
      • -
      • __repr__(self) is a human summary, conventionally "{n} Countries ({m} Servers)".
      • -
      • get_proxy(self, query) returns a Requests-compatible proxy URI, or None only - when the query was valid but no proxy exists. Raise on genuine errors or bad queries.
      • -
      -

      Optionally add get_connection_info(query) (as Gluetun does) or -last_connection_display() (as ExpressVPN and Proton VPN do) to make dl print a -friendly connection line instead of the raw proxy URL.

      -

      See also

      • Downloading: the full dl command guide, including where proxy flags sit in the download flow.
      • -
      • Configuration file: the unshackle.yaml - reference, including directories for cookies and cache used by the cookie-based - providers.
      • -
      • Configuration reference: the developer-facing - configuration API, including the proxy_providers structure.
      • +
      • Network & proxy reference: every proxy_providers config key.
      • +
      • Directories: the cookies and cache + directories that the cookie-based providers use.
      diff --git a/guide/remote-sessions/index.html b/guide/remote-sessions/index.html new file mode 100644 index 00000000..d586a1bb --- /dev/null +++ b/guide/remote-sessions/index.html @@ -0,0 +1,2837 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Remote Sessions - unshackle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +
      + + + + +
      + + +
      + +
      + + + + + + + + + +
      +
      + + + +
      +
      +
      + + + + + + + +
      +
      +
      + + + + + + + +
      + +
      + + + + + + + + +

      Remote Sessions

      +

      A remote session runs a service on a remote unshackle server and the download on your machine. +The server logs in to the service, lists the titles, gets the tracks and their manifests, and can +license the tracks. Your machine selects the tracks, downloads and decrypts them, and muxes the +result.

      +
      +

      When to use a remote session

      +
        +
      • The server has service accounts, cookies or a CDM that you do not want to copy to each machine.
      • +
      • You want to download on a fast machine and keep the logins and the licensing in one place.
      • +
      • A service is available only in the region of the server.
      • +
      +
      +

      The server is an unshackle serve instance. The routes, fields and message shapes between your +machine and the server are on the remote session protocol +page. The server settings are under serve.

      +

      Configure the client

      +

      On your machine (the client), add a remote_services block to unshackle.yaml. Each entry names +a server and gives its URL and API key:

      +
      unshackle.yaml (client)
      remote_services:
      +  my_server:
      +    url: "https://my-box.example:8786"
      +    api_key: "your-api-key"
      +    server_cdm: true            # optional: the server CDM licenses the tracks
      +    services:
      +      EXAMPLE:
      +        server_cdm: false       # optional: your own CDM licenses EXAMPLE
      +        title_map:
      +          "0ABCDEF": "The Show (Renamed Locally)"
      +
      +

      remote_services in the configuration +reference gives each setting of a server entry.

      +

      Select a server

      +

      When you configure one server, unshackle uses it:

      +
      unshackle dl --remote EXAMPLE 0ABCDEF
      +
      +

      When you configure more than one server, select one with --server:

      +
      unshackle dl --remote --server my_server EXAMPLE 0ABCDEF
      +
      +

      With no remote_services block, unshackle stops with an error that tells you to add one.

      +

      Make a service remote by default

      +

      To run a service on the server without --remote, set remote in the +services block, not in the services +sub-dict of remote_services. Add server to select one of several servers:

      +
      unshackle.yaml (client)
      services:
      +  EXAMPLE:
      +    dl:
      +      remote: true
      +      server: my_server
      +
      +

      unshackle dl EXAMPLE 0ABCDEF and unshackle search EXAMPLE "query" then run on my_server. +--local runs the local service code for one run. The +services reference gives the other rules.

      +
      +

      What happens during a download

      +

      The command looks like an ordinary download. The client takes the remote session through these +steps.

      +
      +
      +
      +

      The client creates the remote session and sends what it can, so that the server does not +have to prompt:

      +
        +
      • The local credentials and cookies of the service and profile.
      • +
      • The local cache files of the service (for example refreshed tokens), including the files + in subdirectories of the service cache directory, but only the files of the active profile. + The client withholds a file whose path, in any directory or file name, embeds a hash of another + credential or the name of another profile. Thus the tokens of one profile never reach the + server while you use a different profile. At worst, a withheld file makes the server log in + again.
      • +
      • A resolved proxy, or, if you set none, your detected region. Without the + server_proxy grant on your API key, the + proxy must be a full proxy URI on a public host, and the server rejects the remote session when + it is in a different region from yours: pass --proxy with your own proxy, or --no-proxy + to accept the server's own connection. For Control D, see + Control D. The client also downloads playlists and segments + through the same proxy, as a local run does. --no-proxy-download and --proxy-download + change that for downloads only.
      • +
      • With --local-proxy, the client opens a tunnel first, and the server sends the service + requests through your machine's own connection. See + Send the server's requests through your machine.
      • +
      • Your track selection (-r, -v, -q, --best-available, --generate-dv) and your language and + audio codec selection (-l, -vl, -al, -a, -fs), so that the server fetches the right + manifests. Some services fetch one manifest for each audio language.
      • +
      +

      The server uses its own accounts only when the operator lists the service in +serve.server_accounts and gives your API key server_accounts. For any other service, a +client that sends no credentials or cookies logs in with nothing. For a listed service the client +sends no credentials, cookies or cache: the server picks one of its own accounts that works in +your region, and rotates through them. --proxy ca picks a ca account.

      +

      The service listing of the server gives the regions that those accounts cover. When your region is +not one of them and you set no --proxy, the client resolves a proxy for the first of those +regions itself, so both sides are in a region that the account works in. This is a bare region +query, so it skips Control D. A server-account service does not accept a Control D resolver from +the client.

      +
      +
      +

      Some services need a one-time code, a PIN or a device confirmation. When the login on the server +asks for input, the server sends the prompt to the client. The client shows it to you, and sends +your answer back.

      +
      Enter the 6-digit code sent to your email: 483920
      +
      +

      The server also sends each record of the service's own log to the client, which prints it, so you +see the reason when a step fails on the server.

      +
      +
      +

      The client gets the title list, then the tracks of the title that you select. The server sends +the manifests, and the client parses them again to download the segments itself. The client +uses the HTTP headers and cookies that the server used. Each cookie keeps its domain, path and +secure flag, so it goes only to its own hosts.

      +
      +
      +

      For a DRM-protected title, the licensing mode of the remote session +decides who licenses each track.

      +
      +
      +

      The client downloads, decrypts and muxes locally. While it works, the remote session stays open, +so a long download does not let it expire. When the run ends, also early (--list, Ctrl+C, an +error), the client ends the remote session (see +When the client ends a remote session).

      +

      When the login belongs to the client, the server returns the changed cache files (for example +a refreshed token), and the client saves them, so the next remote session can skip the +interactive login. The login belongs to the client when it succeeds and the remote session uses +no server account. This includes a pair code that you approve on another device. A server-account +login never belongs to the client, and neither does a remote session on the server's device (see +below). The client saves only the returned files that pass the same profile check as before it +sent them, so a file for another profile cannot overwrite that profile's local file.

      +
      +
      +
      +
      +

      Rename remote titles locally

      +

      To rename titles of a remote service that you do not have installed locally, add a title_map +under that service in remote_services.<name>.services. The server sends the titles exactly as +the service returns them, and applies no title_map of its own. The client applies your map, +so the output name stays under your control.

      +
      +
      +

      Who licenses the tracks

      +

      When the server creates the remote session, it fixes the licensing mode: who licenses the tracks +for the whole remote session. There are four licensing modes:

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Licensing modeWho licensesWhen
      Server CDMThe server's device, up to the licence cap of your API key. The client needs no CDM.Your API key has the server_cdm grant for the service, and your client did not decline it.
      Client deviceYour local CDM, through a licence relay on the server. With the server_vault grant (or server_cdm), the server vault answers first, and a track that no server vault holds goes back to your device.Your client declined the server CDM, the API key has no server CDM for the service, or -q asks for more than the licence cap.
      Lent deviceNobody licenses live. The content keys come from the server vault (with the grant) or from your own vaults.A service option runs the remote session on the server's device.
      No deviceNobody licenses: only your own key vaults can give the content keys. The service on the server sees no device.No server CDM, and your client has no local CDM.
      +

      The server CDM

      +

      The server checks its key vaults, loads the device for your API key, licenses, and returns the +content keys. When the server's cdm entry for the service has a widevine and a playready +device, the server loads the device of your local CDM's DRM system. See +cdm.

      +
        +
      • Set server_cdm: true in the server entry to ask for it.
      • +
      • A content key from a server vault is unproven. The client decrypts with it and checks that the + output decodes, and reports a wrong pair to the server. The server flags the pair, and the next + licence for that KID reaches the CDM. The client never learns the server vault names.
      • +
      • A content key in your own vaults goes first, also when the server already answered. The client + proves it, and a server key waits as the next candidate.
      • +
      • When the server licence fails, or the server gives a track no content key, your own device + licenses the track only when the cdm entry for the service gives the loaded device (see + remote_services). Otherwise, or when + that device also fails, the run stops at the licence step of that track with one DRM_ERROR line.
      • +
      +
      +

      The licence cap

      +

      An API key with server_cdm_max_height gets the server CDM only up to that height. Above it, +the client reads its own key vaults first, then licenses the track with its own local CDM. When +the track has no DRM of that CDM's system, the client uses the device that its own cdm entry +names for the DRM system of the track. With no such device, the download of that track stops. See +server_cdm_max_height.

      +
      +

      Your own device

      +

      Your local CDM makes the licence challenge. The server sends it to the service, and returns the +licence for your CDM to parse.

      +
        +
      • Your client declines the server CDM in the cases that + remote_services gives + (server_cdm: false, dl --cdm, a cdm entry for the service). The server then builds the service on your + device, also when the API key has the server CDM.
      • +
      • A service option that the service lists in SERVER_DEVICE_OPTIONS keeps the server CDM, and the + service gets the server's device whatever device you have. The client shows a warning when the + server did not apply its choice.
      • +
      • The service on the server sees your device, not the server's. See + Your own device identity.
      • +
      +

      The lent device

      +

      A service can offer an option that builds the remote session on the server's own device and +identity, for the quality that device reaches. The remote session then makes no live licence: each +content key comes from the server vault or your own vaults, and a content key that no vault holds +stops the download with an error that names its KID, when the client knows it. The service uses the +server's own config: your identity values do not apply, but your preferences do (see +Your preferences). The client reads the server vault only when the API key has +the server_vault grant (or server_cdm). The login tokens of such a remote session hold the +server's device identity, so the server keeps them and returns no cache files.

      +
      +

      A DRM type that the client does not know

      +

      The client rebuilds the DRM of each track from the track list of the server. When the server +sends a DRM type that the client does not know, the client stops the title with one DRM_ERROR +line that names the type. Update the client to the version of the server.

      +
      +

      Your own device identity

      +

      A service can need more than a licence challenge from your device: an ESN, model keys, or a +session-key exchange that runs on the CDM. The device never leaves your machine. Only these cross +to the server:

      +
        +
      • Device facts. The client sends its DRM system, security level, system ID and device type. The + service sees a stand-in with these facts.
      • +
      • CDM calls. When the service calls the CDM, the server sends the call to the client and waits. + The client makes the challenge, or parses the licence, on its own CDM. When the service closes a + CDM session, the server tells the client, because a CDM holds only a few sessions.
      • +
      • Session keys only. The client returns only the Widevine OPERATOR_SESSION and SIGNING keys. + It never returns a content key, and it refuses a PlayReady keys call. Thus a server cannot use your + device to license titles for itself.
      • +
      • Identity config. A service lists the config keys that a client may send (for example a device + serial, device keys, or a map of serials). The client sends only those keys, from its own services: <TAG>: block in + unshackle.yaml. When the client sends an identity, the server drops its own value for each of + those keys, so the two identities never mix. A mapping merges the client's + entries over the server's. A client entry replaces a server entry with the same key, also when the + server's key is a number. The server keeps these values in the memory of the remote session only.
      • +
      +

      Your preferences

      +

      The preferences block of a service is the place for user choices, such as a metadata language or +a subtitle format. It is not an identity, so it crosses --remote in every licensing mode, whatever +CDM the client has, and no service declares anything for it:

      +
        +
      • The client sends each entry of its own services: <TAG>: preferences: block in unshackle.yaml + that is a string, a number or a boolean. It leaves out other entries and logs one debug line for + each.
      • +
      • The server merges the entries key by key over its own preferences block for that service. An + entry that the client sends replaces the server's value, and a config key that the client does not + send keeps the server's value. The entries never count as an identity, and they stay when the + service builds the remote session on the server's device.
      • +
      • The server refuses a preferences value that is not an object of strings, numbers and booleans + with INVALID_INPUT.
      • +
      +

      A service reads its preferences from self.config["preferences"], locally and over --remote +alike. Keep a value that changes the server's account (a profile, an account type) out of +preferences unless every client of the server may choose it: a server account is shared, and the +service can store the choice in its cache.

      +
      +

      When the server restarts

      +

      The server keeps remote sessions in memory only, so a restart loses them all. The client recovers +in two ways:

      +
        +
      • A drain. The operator can announce a restart. The client then finishes the current title, + ends its remote session so that the refreshed cache comes back, waits until the server is back, + opens a new remote session and continues with the next title.
      • +
      • A lost remote session. After a connection error, an answer cut off after its headers, a timeout, + a closed tunnel or a gateway error page, the client waits for the server and checks the old remote + session. A live remote session takes the call again only after a connection error, because a call + that timed out can already have run. A cut-off answer counts as a connection error, so the server + can run that call twice. The client replaces a lost remote session: it opens a new one, gets the + titles and the tracks of the current title again, and sends the failed call again. It matches a + title by season and episode number, and a track by its attributes, so a new ID on the server + changes nothing for the run.
      • +
      +

      The client waits up to 30 minutes for the server, which covers the drain of a deploy. A Ctrl+C ends +this wait. The client stops with an error when the new remote session licenses differently from the +old one, for example after a change to the server_cdm grant of the API key. An interactive login +asks for its input again.

      +

      When the client ends a remote session

      +

      The client ends the remote session, closes its tunnel, and saves the returned cache:

      +
        +
      • when dl has finished every title, before the run post-scripts
      • +
      • when the process exits: --list, an error, or Ctrl+C in any step, also before the server answers + the create request
      • +
      • when a signal or a closed console stops the process, or the cancel of a download job stops its + worker
      • +
      • when the login or any other step of the opening fails, or the create request times out or its + answer is cut off
      • +
      • when a server that relays for a REST client closes its pooled remote session, or stops
      • +
      +

      The end request has a connect and read timeout of 15s each. The client sends it again only once, +when a gateway answers with an error page or asks for the API key in the other header. It does not +wait for a rate limit.

      +

      A Ctrl+C during the downloads cancels the run. The client waits for the download threads and for +the content keys that still go to the vaults, and then ends the remote session. The cancel ends each +wait of a download thread within 0.5s: the wait for a server that restarts, for a rate limit and +for a login. A cancelled thread opens no new remote session. The cancel does not stop a request +that the server already has: the client waits for its answer. A failed track is not a cancel, so +the next title can open a new remote session.

      +

      While the client ends a remote session, it ignores the first Ctrl+C, so it does not lose the +returned cache. The next Ctrl+C stops the wait at once. On Windows, a Ctrl+C counts when the network +read that blocks returns, so the 15s timeout limits the wait.

      +

      SIGHUP (a closed terminal) and SIGTERM stop dl, search and tunnel-test as Ctrl+C does, +with an exit code other than 0. Three things are different:

      +
        +
      • The end request goes first: before the wait for the download threads, for a CDM call and for the + remote session channel.
      • +
      • The process ends 8s after the first signal at the latest, also when the server does not answer.
      • +
      • A later signal changes nothing, and Ctrl+C keeps its own count.
      • +
      +

      After SIGHUP the process writes nothing more to a terminal. A redirected output gets each line. +nohup keeps its effect.

      +

      On Windows, a closed console window and Ctrl+Break send the end request and then end the process, +without the rest of the Ctrl+C steps. The system gives a closed window about 5s. A kill +(SIGKILL, a Windows task end, the cancel of a download job on Windows) sends no end request, so +only the server ends the remote session, at its own limits (see +Remote session lifetime). A cancelled +job that uses a remote server sends the end request for at most 4s, then its worker ends.

      +
      +

      Troubleshooting

      +
      +

      \"Could not connect to remote server at ...\"

      +

      The client could not reach the URL. Make sure that unshackle serve runs on the server, that +the url and port in remote_services are correct (default port 8786), and that each firewall +or reverse proxy allows the connection.

      +
      +
      +

      Remote server <url> rejected the API key (HTTP 401)

      +

      The server does not know the api_key of the remote_services entry. Ask the operator for a +valid API key, or set auth_headers when a gateway in front of the server reads another header.

      +
      +
      +

      403 FORBIDDEN during a download

      +

      The request came from a different IP address than the one that created the remote session. +Remote sessions are bound to that address. Do not move between networks (or NAT egress +addresses) during a remote session.

      +
      +
      +

      The login times out or the prompt never resolves

      +

      An interactive login has a time limit (see +Login states). After that time the login +fails and the server ends the remote session. Start the download again. If the server never prompts you, make +sure that the credentials and cookies that the client sent are valid for the service.

      +
      +
      +

      \"Multiple remote services configured, pick one with --server: ...\"

      +

      You have more than one entry under remote_services. Pass --server <name> to select one.

      +
      + + + + + + + + + + + + + +
      +
      + + + + + +
      + + + +
      + + + +
      +
      +
      +
      + + + + + + + + + + + + + \ No newline at end of file diff --git a/guide/subtitles/index.html b/guide/subtitles/index.html index 51e630db..ad5d97fe 100644 --- a/guide/subtitles/index.html +++ b/guide/subtitles/index.html @@ -347,28 +347,6 @@ - - - - - - - -
    1. - - - - - - - API Reference - - -
    2. - - - -
      @@ -616,6 +594,8 @@ + + @@ -1177,6 +1157,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    3. + + + + + + + + + + +
    4. + + + + @@ -1369,7 +1517,7 @@ - Output & Naming + Output & Naming Options @@ -1453,7 +1601,7 @@ - Key Vaults + Key Vault Options @@ -1573,6 +1721,8 @@ + + @@ -1684,14 +1834,6 @@ - - - - - - - - @@ -1717,9 +1859,8 @@ - + + + + + + + + -
    5. - - - - - - - - Error Responses - - - - - - - - -
    6. - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1998,17 +2068,17 @@ - + -