Deployed f10b8dcf with MkDocs version: 1.6.1

This commit is contained in:
2026-12-05 03:15:49 +00:00
parent 6ed040a6dd
commit dfd9978019
16 changed files with 97 additions and 498 deletions
+2 -86
View File
@@ -2067,34 +2067,6 @@
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#error-responses" class="md-nav__link">
<span class="md-ellipsis">
Error responses
</span>
</a>
<nav class="md-nav" aria-label="Error responses">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#error-codes-and-default-status" class="md-nav__link">
<span class="md-ellipsis">
Error codes and default status
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
@@ -2826,34 +2798,6 @@
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#error-responses" class="md-nav__link">
<span class="md-ellipsis">
Error responses
</span>
</a>
<nav class="md-nav" aria-label="Error responses">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#error-codes-and-default-status" class="md-nav__link">
<span class="md-ellipsis">
Error codes and default status
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
@@ -2906,11 +2850,8 @@
<li><strong>Compression.</strong> JSON responses of 256 bytes or more are gzip-compressed when the client sends <code>Accept-Encoding: gzip</code>. A <a href="../remote-sessions/#slow-responses">slow response</a> is not compressed.</li>
<li><strong>Service allowlist.</strong> The effective allowlist for your API key filters the service-facing endpoints (the intersection of the global <code>serve.services</code> list and your per-key list). The server treats services you cannot use as unknown.</li>
<li><strong>Remote services.</strong> A full-mode server can run a service through one of its own <code>remote_services</code> servers. See <a href="#remote-services-relay">Remote services relay</a>.</li>
<li><strong>Errors.</strong> <a href="../errors/">Error Responses</a> gives the <a href="../errors/#the-standard-error-shape">standard error shape</a> and the <a href="../errors/#the-authentication-error-exception">authentication error</a> of the API-key middleware.</li>
</ul>
<div class="admonition warning">
<p class="admonition-title">Error responses have two shapes</p>
<p>Structured application errors (raised inside a handler) return <code>{"status": "error", "error_code": "...", "message": "...", "timestamp": "..."}</code>. The authentication middleware, however, returns a <strong>different</strong> shape: <code>{"status": 401, "message": "..."}</code> with an integer <code>status</code> and no <code>error_code</code>. The same middleware answers <code>429</code> in that shape when an API key goes over its rate limit. Clients must accept both shapes. The <a href="#error-responses">Error responses</a> section at the bottom of this page gives the full error model.</p>
</div>
<hr />
<h2 id="general-endpoints">General endpoints<a class="headerlink" href="#general-endpoints" title="Permanent link">&para;</a></h2>
<p>These endpoints report server state and enumerate what is available. <code>GET /api/health</code>, <code>GET /api/services</code>, and <code>POST /api/search</code> are also exposed in <code>--remote-only</code> mode.</p>
@@ -4171,7 +4112,7 @@ ignore it safely. See <a href="../../creating-a-service/#split-episodes">Split e
</tr>
</tbody>
</table>
<p><strong>Validation.</strong> Invalid values return <code>400 INVALID_PARAMETERS</code>. <code>vcodec</code>, <code>acodec</code> and <code>sub_format</code> take the same spellings as the CLI options of the same name (<code>unshackle dl --help</code> prints each list). The API and the CLI read one list, so they cannot disagree. <code>range</code> must be one of SDR/HDR10/HDR10P/VIVID/DV/HLG/HYBRID, and <code>HDR10+</code> and <code>HDR Vivid</code> are also valid. The bitrate, download worker, and download counts must be positive integers. You cannot combine <code>no_subs</code> with <code>subs_only</code>, or <code>no_audio</code> with <code>audio_only</code>. The server runs the same option checks as <code>unshackle dl</code>, so a request that <code>dl</code> would refuse returns <code>400</code> when you submit it, and the message names the <code>dl</code> option. The language fields (<code>lang</code>, <code>v_lang</code>, <code>a_lang</code>, <code>s_lang</code>, <code>forced_s_lang</code> and the <code>require_*</code> fields) must be arrays of strings: a single string such as <code>"en"</code> returns <code>400</code>. The server checks every other field with the type of its <code>dl</code> option. A <code>null</code> or an empty string gets the default from the table.</p>
<p><strong>Validation.</strong> Invalid values return <code>400 INVALID_PARAMETERS</code>. <code>vcodec</code>, <code>acodec</code> and <code>sub_format</code> take the same spellings as the CLI options of the same name (<code>unshackle dl --help</code> prints each list). The API and the CLI read one list, so they cannot disagree. You cannot combine <code>no_subs</code> with <code>subs_only</code>, or <code>no_audio</code> with <code>audio_only</code>. The server runs the same option checks as <code>unshackle dl</code>, so a request that <code>dl</code> would refuse returns <code>400</code> when you submit it, and the message names the <code>dl</code> option. The language fields (<code>lang</code>, <code>v_lang</code>, <code>a_lang</code>, <code>s_lang</code>, <code>forced_s_lang</code> and the <code>require_*</code> fields) must be arrays of strings: a single string such as <code>"en"</code> returns <code>400</code>. The server checks every other field with the type of its <code>dl</code> option. A <code>null</code> or an empty string gets the default from the table.</p>
<p><strong>Service options.</strong> A service's own CLI options travel in the same body. Send them in a nested
<code>service_params</code> object, or as flat top-level keys. When the body has <code>service_params</code>, the server
reads service options only from it, and every flat key is a <code>dl</code> value. A name in <code>service_params</code>
@@ -5039,31 +4980,6 @@ key.</p>
</tbody>
</table>
<hr />
<h2 id="error-responses">Error responses<a class="headerlink" href="#error-responses" title="Permanent link">&para;</a></h2>
<p>The server serialises every structured error raised inside a handler to the same JSON envelope:</p>
<div class="language-json highlight"><pre><span></span><code><span id="__span-32-1"><a id="__codelineno-32-1" name="__codelineno-32-1" href="#__codelineno-32-1"></a><span class="p">{</span>
</span><span id="__span-32-2"><a id="__codelineno-32-2" name="__codelineno-32-2" href="#__codelineno-32-2"></a><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"error"</span><span class="p">,</span>
</span><span id="__span-32-3"><a id="__codelineno-32-3" name="__codelineno-32-3" href="#__codelineno-32-3"></a><span class="w"> </span><span class="nt">"error_code"</span><span class="p">:</span><span class="w"> </span><span class="s2">"INVALID_PARAMETERS"</span><span class="p">,</span>
</span><span id="__span-32-4"><a id="__codelineno-32-4" name="__codelineno-32-4" href="#__codelineno-32-4"></a><span class="w"> </span><span class="nt">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Invalid video codec: XYZ"</span><span class="p">,</span>
</span><span id="__span-32-5"><a id="__codelineno-32-5" name="__codelineno-32-5" href="#__codelineno-32-5"></a><span class="w"> </span><span class="nt">"timestamp"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2026-07-03T12:00:00+00:00"</span><span class="p">,</span>
</span><span id="__span-32-6"><a id="__codelineno-32-6" name="__codelineno-32-6" href="#__codelineno-32-6"></a><span class="w"> </span><span class="nt">"details"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"field"</span><span class="p">:</span><span class="w"> </span><span class="s2">"vcodec"</span><span class="w"> </span><span class="p">},</span>
</span><span id="__span-32-7"><a id="__codelineno-32-7" name="__codelineno-32-7" href="#__codelineno-32-7"></a><span class="w"> </span><span class="nt">"retryable"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span>
</span><span id="__span-32-8"><a id="__codelineno-32-8" name="__codelineno-32-8" href="#__codelineno-32-8"></a><span class="w"> </span><span class="nt">"debug_info"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"exception_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"APIError"</span><span class="p">,</span><span class="w"> </span><span class="nt">"traceback"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-32-9"><a id="__codelineno-32-9" name="__codelineno-32-9" href="#__codelineno-32-9"></a><span class="p">}</span>
</span></code></pre></div>
<ul>
<li><code>details</code> appears only when non-empty.</li>
<li><code>retryable</code> appears only when the error is retryable (e.g. network errors, rate limiting).</li>
<li><code>debug_info</code> appears only when you start the server with <code>--debug-api</code>.</li>
</ul>
<div class="admonition warning">
<p class="admonition-title">Authentication errors differ</p>
<p>Errors raised by the API-key middleware use a distinct shape (<code>{"status": 401, "message": "Secret Key is Empty."}</code>, <code>{"status": 401, "message": "Secret Key is Invalid."}</code>, or <code>{"status": 429, "message": "Rate limit exceeded."}</code> with a <code>Retry-After</code> header) with an integer <code>status</code> and no <code>error_code</code>, <code>timestamp</code>, or <code>details</code>. A <code>429</code> from the middleware therefore carries no <code>error_code</code>, unlike the <code>RATE_LIMITED</code> code below, which a handler raises for a rate limit the <em>service</em> imposed. A malformed JSON body on any POST, by contrast, returns the standard envelope with <code>error_code: "INVALID_INPUT"</code>.</p>
</div>
<h3 id="error-codes-and-default-status">Error codes and default status<a class="headerlink" href="#error-codes-and-default-status" title="Permanent link">&para;</a></h3>
<p>The <a href="../errors/#error-code-catalogue">error code catalogue</a> gives the default HTTP status of each error code.</p>
<p>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 <code>NETWORK_ERROR</code> (424, retryable), "rate limit" or "429" become <code>RATE_LIMITED</code> (429, retryable), and anything unrecognised collapses to <code>INTERNAL_ERROR</code> (422).</p>
<hr />
<h2 id="see-also">See also<a class="headerlink" href="#see-also" title="Permanent link">&para;</a></h2>
<ul>
<li><a href="../">Server Overview</a>. What the server is and when to use it.</li>
+2 -67
View File
@@ -2220,73 +2220,8 @@ start. See <a href="authentication/">Authentication</a> for how to set <code>api
how the <code>X-Secret-Key</code> header works.</p>
</div>
<h3 id="common-options">Common options<a class="headerlink" href="#common-options" title="Permanent link">&para;</a></h3>
<p>The <code>serve</code> command accepts the following flags:</p>
<table>
<thead>
<tr>
<th>Option</th>
<th>Default</th>
<th>Effect</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>-h</code>, <code>--host</code></td>
<td><code>127.0.0.1</code></td>
<td>Address to bind to. Use <code>0.0.0.0</code> to accept connections from other machines.</td>
</tr>
<tr>
<td><code>-p</code>, <code>--port</code></td>
<td><code>8786</code></td>
<td>Port to bind to.</td>
</tr>
<tr>
<td><code>--api-only</code></td>
<td>off</td>
<td>Serve only the REST API, without the Widevine/PlayReady CDM HTTP endpoints.</td>
</tr>
<tr>
<td><code>--cdm-only</code></td>
<td>off</td>
<td>Serve only the Widevine/PlayReady CDM HTTP endpoints, plus <code>/api/health</code> and the dashboard. No REST API, no remote sessions, no Swagger UI. Cannot be combined with <code>--api-only</code> or <code>--remote-only</code>.</td>
</tr>
<tr>
<td><code>--no-widevine</code></td>
<td>off</td>
<td>Disable the Widevine CDM endpoints. Cannot be combined with <code>--api-only</code>.</td>
</tr>
<tr>
<td><code>--no-playready</code></td>
<td>off</td>
<td>Disable the PlayReady CDM endpoints. Cannot be combined with <code>--api-only</code>.</td>
</tr>
<tr>
<td><code>--no-key</code></td>
<td>off</td>
<td>Disable API-key authentication entirely; every request is allowed.</td>
</tr>
<tr>
<td><code>--remote-only</code></td>
<td>off</td>
<td>Expose only the <a href="remote-sessions/#routes">remote session routes</a>. Implies <code>--api-only</code>.</td>
</tr>
<tr>
<td><code>--debug-api</code></td>
<td>off</td>
<td>Include tracebacks and worker stderr in error responses.</td>
</tr>
<tr>
<td><code>--debug</code></td>
<td>off</td>
<td>Enable debug-level logging.</td>
</tr>
<tr>
<td><code>--caddy</code></td>
<td>off</td>
<td>Also launch <a href="https://caddyserver.com/">Caddy</a> as a reverse proxy, using the <code>Caddyfile</code> in your user-config directory.</td>
</tr>
</tbody>
</table>
<p>The <a href="../../guide/cli-reference/#serve"><code>serve</code> options</a> in the CLI reference give each flag, its
default and the flags that you cannot use together.</p>
<div class="language-shell highlight"><span class="filename">Serve the REST API only, on all interfaces</span><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>unshackle<span class="w"> </span>serve<span class="w"> </span>--api-only<span class="w"> </span>--host<span class="w"> </span><span class="m">0</span>.0.0.0<span class="w"> </span>--port<span class="w"> </span><span class="m">8786</span>
</span></code></pre></div>
<div class="admonition danger">
+6 -140
View File
@@ -2397,58 +2397,7 @@
<div class="language-shell highlight"><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a>unshackle<span class="w"> </span>serve<span class="w"> </span>--api-only
</span></code></pre></div>
<p>By default the server binds to <code>127.0.0.1:8786</code>. The <code>--api-only</code> flag serves only the REST API and omits the Widevine/PlayReady CDM HTTP endpoints. Drop it when you also want those endpoints.</p>
<p>Common options:</p>
<table>
<thead>
<tr>
<th>Option</th>
<th>Default</th>
<th>Effect</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>-h, --host</code></td>
<td><code>127.0.0.1</code></td>
<td>Address to bind to</td>
</tr>
<tr>
<td><code>-p, --port</code></td>
<td><code>8786</code></td>
<td>Port to bind to</td>
</tr>
<tr>
<td><code>--api-only</code></td>
<td>off</td>
<td>Serve only the REST API, no CDM endpoints</td>
</tr>
<tr>
<td><code>--no-key</code></td>
<td>off</td>
<td>Disable API-key authentication (allow all requests)</td>
</tr>
<tr>
<td><code>--debug-api</code></td>
<td>off</td>
<td>Include tracebacks and stderr in error responses</td>
</tr>
<tr>
<td><code>--debug</code></td>
<td>off</td>
<td>Enable DEBUG-level logging</td>
</tr>
<tr>
<td><code>--remote-only</code></td>
<td>off</td>
<td>Expose only the remote session routes: <code>/api/health</code>, <code>/api/services</code>, <code>/api/search</code>, <code>/api/session/*</code>, <code>/api/tunnel</code> and <code>/api/tunnel/check</code>, and the dashboard routes when <code>serve.dashboard.key</code> is set</td>
</tr>
<tr>
<td><code>--caddy</code></td>
<td>off</td>
<td>Also launch Caddy as a reverse proxy (for HTTPS)</td>
</tr>
</tbody>
</table>
<p>The <a href="../../../guide/cli-reference/#serve"><code>serve</code> options</a> in the CLI reference give every flag.</p>
<p>Once it is up you will see the API mounted under <code>/api/</code> and, unless you started in remote-only mode, an interactive Swagger UI:</p>
<div class="language-text highlight"><pre><span></span><code><span id="__span-5-1"><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a>REST API endpoints available at http://127.0.0.1:8786/api/
</span><span id="__span-5-2"><a id="__codelineno-5-2" name="__codelineno-5-2" href="#__codelineno-5-2"></a>Swagger UI available at http://127.0.0.1:8786/api/docs/
@@ -2508,7 +2457,7 @@
</span></code></pre></div>
<div class="admonition warning">
<p class="admonition-title">Two error shapes exist</p>
<p>The authentication middleware returns the short <code>{"status": 401, "message": "..."}</code> shape shown above. Every <strong>other</strong> error the API produces uses the richer structured shape (<code>error_code</code>, <code>timestamp</code>, <code>details</code>, ...) described in <a href="#error-handling">Error handling</a>. Parse both shapes in your client.</p>
<p>The authentication middleware answers with the short shape above, and every other JSON error has the <a href="../errors/#the-standard-error-shape">standard error shape</a>. Parse both shapes in your client.</p>
</div>
<p>The <code>tag</code> value for the service you want is the identifier you pass as <code>service</code> in the calls below.</p>
<hr />
@@ -2716,93 +2665,10 @@
<p>The interactive <strong>Swagger UI at <code>/api/docs/</code></strong> documents every route and lets you try them in the browser (send your <code>X-Secret-Key</code> there too).</p>
<hr />
<h2 id="error-handling">Error handling<a class="headerlink" href="#error-handling" title="Permanent link">&para;</a></h2>
<p>Apart from the auth middleware's short form, every error the API returns uses a single structured envelope:</p>
<div class="language-json highlight"><pre><span></span><code><span id="__span-27-1"><a id="__codelineno-27-1" name="__codelineno-27-1" href="#__codelineno-27-1"></a><span class="p">{</span>
</span><span id="__span-27-2"><a id="__codelineno-27-2" name="__codelineno-27-2" href="#__codelineno-27-2"></a><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"error"</span><span class="p">,</span>
</span><span id="__span-27-3"><a id="__codelineno-27-3" name="__codelineno-27-3" href="#__codelineno-27-3"></a><span class="w"> </span><span class="nt">"error_code"</span><span class="p">:</span><span class="w"> </span><span class="s2">"INVALID_PARAMETERS"</span><span class="p">,</span>
</span><span id="__span-27-4"><a id="__codelineno-27-4" name="__codelineno-27-4" href="#__codelineno-27-4"></a><span class="w"> </span><span class="nt">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Human-readable description"</span><span class="p">,</span>
</span><span id="__span-27-5"><a id="__codelineno-27-5" name="__codelineno-27-5" href="#__codelineno-27-5"></a><span class="w"> </span><span class="nt">"timestamp"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2026-07-03T12:00:00Z"</span><span class="p">,</span>
</span><span id="__span-27-6"><a id="__codelineno-27-6" name="__codelineno-27-6" href="#__codelineno-27-6"></a><span class="w"> </span><span class="nt">"details"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-27-7"><a id="__codelineno-27-7" name="__codelineno-27-7" href="#__codelineno-27-7"></a><span class="p">}</span>
</span></code></pre></div>
<p><code>details</code> appears only when the server has more to add. <code>retryable: true</code> appears only for transient failures. The server includes a <code>debug_info</code> block (exception type and traceback) only when it runs with <code>--debug-api</code>.</p>
<p>The <code>error_code</code> maps to an HTTP status. The ones you will meet most often:</p>
<table>
<thead>
<tr>
<th>Error code</th>
<th>HTTP</th>
<th>Typical cause</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>INVALID_INPUT</code></td>
<td>400</td>
<td>Malformed JSON body or missing required field</td>
</tr>
<tr>
<td><code>INVALID_SERVICE</code></td>
<td>400</td>
<td>Unknown or disallowed service tag</td>
</tr>
<tr>
<td><code>INVALID_PARAMETERS</code></td>
<td>400</td>
<td>A download field failed validation</td>
</tr>
<tr>
<td><code>AUTH_FAILED</code></td>
<td>401</td>
<td>Service login/credential failure</td>
</tr>
<tr>
<td><code>FORBIDDEN</code></td>
<td>403</td>
<td>A gated field was used without server opt-in</td>
</tr>
<tr>
<td><code>NOT_FOUND</code></td>
<td>404</td>
<td>Title or resource does not exist</td>
</tr>
<tr>
<td><code>JOB_NOT_FOUND</code></td>
<td>404</td>
<td>No job with that <code>job_id</code></td>
</tr>
<tr>
<td><code>CONFLICT</code></td>
<td>409</td>
<td>Illegal state transition (e.g. retry a running job)</td>
</tr>
<tr>
<td><code>SERVICE_ERROR</code></td>
<td>422</td>
<td>The service raised an error</td>
</tr>
<tr>
<td><code>RATE_LIMITED</code></td>
<td>429</td>
<td>Upstream throttling (retryable)</td>
</tr>
<tr>
<td><code>INTERNAL_ERROR</code></td>
<td>422</td>
<td>Unexpected server-side failure</td>
</tr>
<tr>
<td><code>NETWORK_ERROR</code></td>
<td>424</td>
<td>Connection/timeout reaching the service (retryable)</td>
</tr>
</tbody>
</table>
<p>The <a href="../errors/#error-code-catalogue">error code catalogue</a> lists every code.</p>
<div class="admonition tip">
<p class="admonition-title">Retry politely</p>
<p>Codes marked retryable (<code>NETWORK_ERROR</code>, <code>RATE_LIMITED</code>, <code>SERVICE_UNAVAILABLE</code>) reflect transient conditions. Back off and retry rather than hammering the server.</p>
</div>
<p>Every JSON error has one of two shapes: the <a href="../errors/#the-standard-error-shape">standard error shape</a>,
or the <a href="../errors/#the-authentication-error-exception">authentication error</a> of the API-key
middleware. The <a href="../errors/#error-code-catalogue">error code catalogue</a> gives the HTTP status of
each code, and <a href="../errors/#the-retryable-hint">the <code>retryable</code> hint</a> marks the errors to retry.</p>
+4 -4
View File
@@ -2720,9 +2720,9 @@
<h1 id="remote-session-protocol">Remote Session Protocol<a class="headerlink" href="#remote-session-protocol" title="Permanent link">&para;</a></h1>
<p>The remote session protocol is the one record of the routes, login states, error codes and message
shapes that a <code>--remote</code> client and the server share. A remote session keeps an authenticated
service on the server between requests. The client logs in one time, then asks for titles, tracks,
<p>This page lists the routes, login states, error codes and message shapes that a <code>--remote</code> client
and the server share. A remote session keeps an authenticated service on the server between
requests. The client logs in one time, then asks for titles, tracks,
segments and licences in the same remote session. The client downloads, decrypts and muxes.</p>
<p>The record is <code>unshackle/core/remote_protocol.py</code>: both the client (<code>unshackle/core/remote_service.py</code>,
the reference client) and the server (<code>unshackle/core/api/</code>) read it. Titles, tracks and DRM cross
@@ -3076,7 +3076,7 @@ limit, the server ends the remote session.</p>
</tr>
<tr>
<td>Remote sessions at the same time</td>
<td><code>serve.max_sessions</code>. A create at the limit ends the least recently used remote session of the API key that holds the most. A remote session that a request works on goes last.</td>
<td><code>serve.max_sessions</code>. A create at the limit ends one remote session: <a href="../../../reference/configuration/services/#serve"><code>max_sessions</code></a> gives which one.</td>
</tr>
<tr>
<td>Sweep</td>