mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-01 21:45:10 +00:00
Deployed 6e99812e with MkDocs version: 1.6.1
This commit is contained in:
@@ -3135,7 +3135,7 @@
|
||||
<li><strong>CORS.</strong> Every response carries permissive CORS headers, and the server answers <code>OPTIONS</code> preflight requests automatically.</li>
|
||||
<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="#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-sessions/">Remote sessions</a>). <code>GET /api/config</code> lists their names in <code>remote_services</code>, and <code>GET /api/services?remote=<name></code> lists that server's services, each with <code>remote</code> set to the name. Add <code>"remote": "<name>"</code> to <code>POST /api/search</code>, <code>/api/list-titles</code>, <code>/api/list-tracks</code> or <code>/api/download</code>, and the server opens a remote session with its own key for that server: the remote 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. An unknown name is <code>400 INVALID_PARAMETERS</code>, a server that does not answer is <code>SERVICE_UNAVAILABLE</code>, and a tag it does not offer is <code>INVALID_SERVICE</code>. 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. An optional <code>client_name</code> names your client on the remote server's dashboard as <code>serve (<client_name>)</code>. A relayed search opens no remote session. The server sends its own credentials, cookies and cache for the <code>profile</code> with the search. A service that searches with no login gets none of them. A <code>--remote-only</code> server does not relay. A remote login that waits on you (a pair code or URL to approve on another device) cannot answer through a list call, so poll <code>GET /api/remote/logins</code> alongside it: each entry carries the login's <code>notice</code>, its <code>qr</code> (the text of a QR code to scan, or null), and its <code>prompt</code> when it asks a question (an OTP), which you answer with <code>POST /api/remote/logins/{id}/input</code> and <code>{"response": "..."}</code>. A remote download job shows the same text as its own <code>notice</code>, and asks a question (an OTP) through <code>input_prompt</code> as a local job does.</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-sessions/">Remote sessions</a>). <code>GET /api/config</code> lists their names in <code>remote_services</code>, and <code>GET /api/services?remote=<name></code> lists that server's services, each with <code>remote</code> set to the name. Add <code>"remote": "<name>"</code> to <code>POST /api/search</code>, <code>/api/list-titles</code>, <code>/api/list-tracks</code> or <code>/api/download</code>, and the server opens a remote session with its own key for that server: the remote 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. An unknown name is <code>400 INVALID_PARAMETERS</code>, a server that does not answer is <code>SERVICE_UNAVAILABLE</code>, and a tag it does not offer is <code>INVALID_SERVICE</code>. 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 <code>SERVER_DRAINING</code> (409). A call that opens a lost remote session again can be cut too: <code>list-titles</code> then gets <code>SERVER_DRAINING</code>, and <code>list-tracks</code> that or <code>SERVICE_ERROR</code> (422). An optional <code>client_name</code> names your client on the remote server's dashboard as <code>serve (<client_name>)</code>. A relayed search opens no remote session. The server sends its own credentials, cookies and cache for the <code>profile</code> with the search. A service that searches with no login gets none of them. A <code>--remote-only</code> server does not relay. A remote login that waits on you (a pair code or URL to approve on another device) cannot answer through a list call, so poll <code>GET /api/remote/logins</code> alongside it: each entry carries the login's <code>notice</code>, its <code>qr</code> (the text of a QR code to scan, or null), and its <code>prompt</code> when it asks a question (an OTP), which you answer with <code>POST /api/remote/logins/{id}/input</code> and <code>{"response": "..."}</code>. A remote download job shows the same text as its own <code>notice</code>, and asks a question (an OTP) through <code>input_prompt</code> as a local job does.</li>
|
||||
</ul>
|
||||
<div class="admonition warning">
|
||||
<p class="admonition-title">Error responses have two shapes</p>
|
||||
@@ -4968,7 +4968,7 @@ answers the prompt within 10 minutes.</p>
|
||||
<p class="admonition-title">Developer feature</p>
|
||||
<p>The <code>/api/session/*</code> endpoints power unshackle's <strong>remote download</strong> 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 <code>--remote-only</code> mode, and they are what the built-in <code>RemoteService</code> client drives. Most end users never call them directly.</p>
|
||||
</div>
|
||||
<p>The server holds remote sessions in memory. They expire after <code>serve.session_ttl</code> (default 300s) without a request, except while the login runs, which can stay idle for the larger of <code>session_ttl</code> and 600s. A remote session binds to the IP that made it, so the server rejects a request from a different IP with <code>403 FORBIDDEN</code>.</p>
|
||||
<p>The server holds remote sessions in memory. They expire after <code>serve.session_ttl</code> (default 300s) without a request, except while the login runs, which can stay idle for the larger of <code>session_ttl</code> and 600s. A remote session whose client is gone ends sooner: see <a href="../remote-sessions/#client-presence">Client presence</a>. A remote session binds to the IP that made it, so the server rejects a request from a different IP with <code>403 FORBIDDEN</code>.</p>
|
||||
<h3 id="remote-session-lifecycle-overview">Remote session lifecycle overview<a class="headerlink" href="#remote-session-lifecycle-overview" title="Permanent link">¶</a></h3>
|
||||
<div class="language-text highlight"><pre><span></span><code><span id="__span-30-1"><a id="__codelineno-30-1" name="__codelineno-30-1" href="#__codelineno-30-1"></a>POST /api/session/create → returns session_id, status "authenticating"
|
||||
</span><span id="__span-30-2"><a id="__codelineno-30-2" name="__codelineno-30-2" href="#__codelineno-30-2"></a>GET /api/session/{id}/channel → WebSocket: prompts, CDM calls, logs, login state, drain
|
||||
@@ -4998,7 +4998,8 @@ Use <code>error_code</code> and <code>retryable</code> to decide what to do.</p>
|
||||
<p>A slow response is not gzip-compressed. Gzip output cannot start before the body is ready, and
|
||||
the newlines must go out at once.</p>
|
||||
<h3 id="post-apisessioncreate"><code>POST /api/session/create</code><a class="headerlink" href="#post-apisessioncreate" title="Permanent link">¶</a></h3>
|
||||
<p>Make a remote session for a service and title. Authentication runs asynchronously in the background. This call returns immediately with <code>status: "authenticating"</code>, and you then poll the prompt endpoint. The body accepts <code>service</code> and <code>title_id</code> (both required). It also accepts a broad set of optional keys, because the body allows <code>additionalProperties</code>. These are <code>credentials</code> (<code>{username, password, extra?}</code>), <code>cookies</code> (base64 of zlib-compressed Netscape cookie file), <code>proxy</code>, <code>no_proxy</code>, <code>profile</code>, <code>cache</code> (map of forwarded cache files, keyed by the file path relative to the service cache directory with <code>/</code> separators and no <code>.json</code> suffix, so a nested key such as <code>session_web/<sha1></code> lands in a subdirectory), <code>client_region</code>, <code>proxy_region</code>, <code>cdm_type</code>, <code>range_</code>, <code>vcodec</code>, <code>quality</code>, <code>best_available</code>, <code>dl_params</code>, <code>client</code>, and any service CLI options. <code>proxy_region</code> is the country code the client resolved <code>proxy</code> from; the server matches it against its own accounts. <code>client</code> is a freeform object the dashboard shows as sent (the CLI puts <code>version</code>, <code>code_hash</code>, <code>platform</code> and a redacted <code>argv</code> in it); the server ignores it above 4096 bytes of JSON.</p>
|
||||
<p>Make a remote session for a service and title. Authentication runs asynchronously in the background. This call returns immediately with <code>status: "authenticating"</code>, and you then poll the prompt endpoint. The body accepts <code>service</code> and <code>title_id</code> (both required). It also accepts a broad set of optional keys, because the body allows <code>additionalProperties</code>. These are <code>session_id</code>, <code>credentials</code> (<code>{username, password, extra?}</code>), <code>cookies</code> (base64 of zlib-compressed Netscape cookie file), <code>proxy</code>, <code>no_proxy</code>, <code>profile</code>, <code>cache</code> (map of forwarded cache files, keyed by the file path relative to the service cache directory with <code>/</code> separators and no <code>.json</code> suffix, so a nested key such as <code>session_web/<sha1></code> lands in a subdirectory), <code>client_region</code>, <code>proxy_region</code>, <code>cdm_type</code>, <code>range_</code>, <code>vcodec</code>, <code>quality</code>, <code>best_available</code>, <code>dl_params</code>, <code>client</code>, and any service CLI options. <code>proxy_region</code> is the country code the client resolved <code>proxy</code> from; the server matches it against its own accounts. <code>client</code> is a freeform object the dashboard shows as sent (the CLI puts <code>version</code>, <code>code_hash</code>, <code>platform</code> and a redacted <code>argv</code> in it); the server ignores it above 4096 bytes of JSON.</p>
|
||||
<p><code>session_id</code> 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.</p>
|
||||
<p><code>dl_params</code> is an object with the <code>dl</code> track selection: <code>lang</code>, <code>v_lang</code>, <code>a_lang</code> and <code>s_lang</code> (arrays of language strings), <code>acodec</code> (an array of audio codec names or <code>dl -a</code> aliases such as <code>ddp</code>), and <code>forced_subs</code> and <code>exact_lang</code> (booleans). The service reads these values from <code>ctx.parent.params</code>. The server uses the <code>dl</code> 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 <code>INVALID_PARAMETERS</code>. The flat <code>range_</code>, <code>vcodec</code>, <code>quality</code>, <code>best_available</code> and <code>generate_dv</code> keys are <code>dl</code> values on this route. On the list and search routes they are <code>dl</code> values only when the body has <code>service_params</code>.</p>
|
||||
<p>Service CLI options also travel in a nested <code>service_params</code> object. When the body has <code>service_params</code>, the server reads service options only from it, and a flat key with the same name stays a <code>dl</code> value. <code>profile</code> at the top level always means the credentials profile, never a service's own <code>--profile</code> option.</p>
|
||||
<p>The <code>proxy</code> value must be a full proxy URI, unless the operator gives your API key <code>server_proxy</code> in the <code>serve.users</code> config. Without <code>server_proxy</code>, a proxy URI gets <code>INVALID_PROXY</code> when its host is not a public address, does not resolve, or is not a plain host name or IP address. Without <code>server_proxy</code>, the server does not resolve country codes with its own proxy providers. It rejects the request with <code>INVALID_PROXY</code> when no <code>proxy</code> is set and the reported <code>client_region</code> differs from the server's region. A request that reports no <code>client_region</code> is not blocked. Pass <code>proxy</code> with your own proxy, or <code>no_proxy</code> to accept the server's own connection. With <code>server_proxy</code>, the server resolves a country code and picks a proxy for your <code>client_region</code> itself. A Control D resolver, <code>controld://<resolver>@dns.controld.com</code>, 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 <code>http</code>, <code>https</code> or <code>socks</code> scheme: the server answers <code>INVALID_PROXY</code> to a <code>host:port</code> value, also with <code>server_proxy</code>.</p>
|
||||
@@ -5033,7 +5034,7 @@ the newlines must go out at once.</p>
|
||||
<tr>
|
||||
<td><code>400</code></td>
|
||||
<td><code>INVALID_INPUT</code></td>
|
||||
<td>Missing <code>service</code> or <code>title_id</code>.</td>
|
||||
<td>Missing <code>service</code> or <code>title_id</code>, or a <code>session_id</code> that is not the canonical text of a version 4 UUID.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>400</code></td>
|
||||
@@ -5041,6 +5042,16 @@ the newlines must go out at once.</p>
|
||||
<td>Invalid <code>range_</code>, <code>vcodec</code>, <code>quality</code> or <code>dl_params</code> value.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>403</code></td>
|
||||
<td><code>FORBIDDEN</code></td>
|
||||
<td>Another API key or another IP has the <code>session_id</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>404</code></td>
|
||||
<td><code>SESSION_NOT_FOUND</code></td>
|
||||
<td>A <code>DELETE</code> or a newer create with the same <code>session_id</code> ended this create.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>400</code></td>
|
||||
<td><code>INVALID_SERVICE</code></td>
|
||||
<td>Unknown or disallowed service.</td>
|
||||
@@ -5212,6 +5223,7 @@ A slow answer arrives as a <a href="#slow-responses">slow response</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p><code>collection</code> is present only when the service returned a music collection. It holds the facts of the collection itself: <code>kind</code>, <code>title</code>, <code>artist</code>, <code>year</code>, <code>total_tracks</code>, <code>total_discs</code>, <code>artwork_url</code>, <code>total_duration</code>, <code>owner</code> and <code>description</code>, for example <code>"collection": { "kind": "playlist", "title": "Example Playlist", "total_tracks": 93 }</code>. A fact that the collection does not have is absent.</p>
|
||||
<p>Requires an authenticated remote session. Otherwise it returns <code>404 SESSION_NOT_FOUND</code>.</p>
|
||||
<h3 id="post-apisessionsession_idtracks"><code>POST /api/session/{session_id}/tracks</code><a class="headerlink" href="#post-apisessionsession_idtracks" title="Permanent link">¶</a></h3>
|
||||
<p>Get tracks and chapters for a specific title within the remote session. Body: <code>{ "title_id": "..." }</code> (required). Unlike <code>list-tracks</code>, track objects here <strong>include</strong> download URLs, along with session headers/cookies and manifest data the client needs to download directly. A slow answer arrives as a <a href="#slow-responses">slow response</a>.</p>
|
||||
@@ -5580,7 +5592,7 @@ A slow answer arrives as a <a href="#slow-responses">slow response</a>.</p>
|
||||
</div>
|
||||
<p><code>404 SESSION_NOT_FOUND</code> if the remote session does not exist or has expired.</p>
|
||||
<h3 id="delete-apisessionsession_id"><code>DELETE /api/session/{session_id}</code><a class="headerlink" href="#delete-apisessionsession_id" title="Permanent link">¶</a></h3>
|
||||
<p>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.</p>
|
||||
<p>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 <code>404 SESSION_NOT_FOUND</code>. If no remote session exists yet, the <code>DELETE</code> answers <code>200</code> with no <code>cache</code>.</p>
|
||||
<div class="tabbed-set tabbed-alternate" data-tabs="31:1"><input checked="checked" id="__tabbed_31_1" name="__tabbed_31" type="radio" /><div class="tabbed-labels"><label for="__tabbed_31_1">Response <code>200</code></label></div>
|
||||
<div class="tabbed-content">
|
||||
<div class="tabbed-block">
|
||||
|
||||
@@ -2526,7 +2526,7 @@ while the server restarts.</p>
|
||||
<tr>
|
||||
<td><code>SERVER_DRAINING</code></td>
|
||||
<td>409</td>
|
||||
<td>The server is about to restart and starts no new remote session or download job. Open work continues. Retryable after the restart. A <code>dl --remote</code> client waits for the restart and opens a new remote session.</td>
|
||||
<td>The server is about to restart or stops, and starts no new remote session, remote login or download job. Open work continues. Retryable after the restart. A <code>dl --remote</code> client waits for the restart and opens a new remote session.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>SERVICE_ERROR</code></td>
|
||||
|
||||
@@ -2948,7 +2948,9 @@ it repackages and muxes. A track counts as done when it reaches a terminal state
|
||||
to <code>cancelled</code>. The polling loop notices the event, <code>terminate()</code>s the job worker
|
||||
subprocess (escalating to <code>kill()</code> 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.</li>
|
||||
immediate stop rather than a cooperative one. A job with the <code>remote</code> parameter first ends its
|
||||
<a href="../remote-sessions/#when-the-client-ends-a-remote-session">remote session</a>, in at most 4
|
||||
seconds, and runs no post-script after the cancel.</li>
|
||||
</ul>
|
||||
<h3 id="secret-handling-in-serialized-jobs">Secret handling in serialized jobs<a class="headerlink" href="#secret-handling-in-serialized-jobs" title="Permanent link">¶</a></h3>
|
||||
<p>Job parameters may carry secrets: a raw <code>user:pass</code> credential, or a proxy URL with
|
||||
|
||||
@@ -1856,6 +1856,17 @@
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#client-presence" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
Client presence
|
||||
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -1889,6 +1900,17 @@
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#when-the-client-ends-a-remote-session" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
When the client ends a remote session
|
||||
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
@@ -2372,6 +2394,17 @@
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#client-presence" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
Client presence
|
||||
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -2405,6 +2438,17 @@
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#when-the-client-ends-a-remote-session" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
When the client ends a remote session
|
||||
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
@@ -2656,6 +2700,11 @@ re-parses that instead. The client skips the same DASH periods as the server. An
|
||||
client's local HTTP session. Each cookie in <code>session_cookie_jar</code> keeps its
|
||||
domain, path and <code>secure</code> flag, so it goes only to its own hosts. <code>session_cookies</code> carries
|
||||
the same cookies as names and values only, for older clients.</p>
|
||||
<p>For a music collection (an album, a playlist, an artist listing), the title list reply also
|
||||
has <code>collection</code>, with the facts of the collection itself, such as its kind, title, artist
|
||||
and totals. The client builds its collection with them. It ignores the keys of
|
||||
<code>collection</code> that it does not know, and stops with an error on a value of the wrong type.
|
||||
Without <code>collection</code>, for example from an older server, the client has the songs only.</p>
|
||||
<p>The tracks response repeats the title. A service can rewrite title fields inside
|
||||
<code>get_tracks</code>, so the client takes this copy in place of the one from the title
|
||||
list. Each track carries the full local field set. After the manifest re-parse the
|
||||
@@ -2674,7 +2723,8 @@ and return the content keys directly. See
|
||||
<a href="#the-remote-session-channel">remote session channel</a> keeps the remote session alive,
|
||||
so a long download does not let the remote session expire. On
|
||||
completion, and also when <code>dl</code> exits early (<code>--list</code>, Ctrl+C, an error), it
|
||||
deletes the remote session. If the login belongs to the client, the <code>DELETE</code>
|
||||
deletes the remote session (see <a href="#when-the-client-ends-a-remote-session">When the client ends a remote session</a>).
|
||||
If the login belongs to the client, the <code>DELETE</code>
|
||||
request returns the updated cache files (for example a refreshed token) and the
|
||||
client saves them locally, so the <strong>next</strong> remote session can skip interactive
|
||||
authentication. The login belongs to the client when it succeeds and the
|
||||
@@ -2813,7 +2863,7 @@ vault first. A track that no server vault holds goes back to your device. See
|
||||
</div>
|
||||
<hr />
|
||||
<h2 id="remote-session-lifecycle-and-expiry">Remote session lifecycle and expiry<a class="headerlink" href="#remote-session-lifecycle-and-expiry" title="Permanent link">¶</a></h2>
|
||||
<p>Remote sessions live in an <strong>in-memory store on the server</strong> and expire on a timer. You
|
||||
<p>Remote sessions live in an <strong>in-memory store on the server</strong>. They expire on a timer, or when their client is gone. You
|
||||
generally never touch this directly, but it explains behaviour you might observe.</p>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -2827,7 +2877,12 @@ generally never touch this directly, but it explains behaviour you might observe
|
||||
<tr>
|
||||
<td>Idle session TTL</td>
|
||||
<td><strong>300s</strong> (5 min) default</td>
|
||||
<td>Refreshed on every request to the session and when a <code>titles</code> or <code>tracks</code> request ends. A remote session does not expire while a request works on it or while its remote session channel is open</td>
|
||||
<td>Refreshed on every request to the session and when a <code>titles</code> or <code>tracks</code> request ends. A remote session does not reach this limit while a request works on it or while its remote session channel is open</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Client presence</td>
|
||||
<td><strong>180s</strong>, <strong>150s</strong> or <strong>90s</strong></td>
|
||||
<td>The time that a client can be silent after it lost its channel, after <code>create</code>, or after it closed its channel. See <a href="#client-presence">Client presence</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max concurrent sessions</td>
|
||||
@@ -2837,11 +2892,11 @@ generally never touch this directly, but it explains behaviour you might observe
|
||||
<tr>
|
||||
<td>Auth/input timeout</td>
|
||||
<td><strong>600s</strong> (10 min)</td>
|
||||
<td>A remote session that still logs in, a prompt included, can stay idle for the larger of the TTL and this value</td>
|
||||
<td>A remote session that still logs in, a prompt included, can stay idle for the larger of the TTL and this value, unless its client is gone</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cleanup sweep</td>
|
||||
<td>every 60s</td>
|
||||
<td>every 5s</td>
|
||||
<td>Expired sessions are removed and their input prompts cancelled</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -2850,7 +2905,8 @@ generally never touch this directly, but it explains behaviour you might observe
|
||||
<p class="admonition-title">Auth is never rushed</p>
|
||||
<p>A remote session that is still <code>authenticating</code> or waiting on <code>pending_input</code> can stay
|
||||
idle for the larger of <code>session_ttl</code> and 600s. This gives you time to enter an interactive
|
||||
code without the remote session vanishing mid-prompt.</p>
|
||||
code without the remote session vanishing mid-prompt. The client must stay: it keeps its
|
||||
channel open, or it polls.</p>
|
||||
</div>
|
||||
<p>The TTL and max-session limits are read from server config:</p>
|
||||
<div class="language-yaml highlight"><span class="filename">unshackle.yaml (server)</span><pre><span></span><code><span id="__span-6-1"><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><span class="nt">serve</span><span class="p">:</span>
|
||||
@@ -3002,7 +3058,9 @@ from a browser origin, not when you want only the local HTTP API.</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="create-request-and-response">Create: request and response<a class="headerlink" href="#create-request-and-response" title="Permanent link">¶</a></h3>
|
||||
<p><code>POST /api/session/create</code> requires <code>service</code> and <code>title_id</code>. It also accepts
|
||||
<p><code>POST /api/session/create</code> requires <code>service</code> and <code>title_id</code>. It also accepts <code>session_id</code> (the ID of the remote session,
|
||||
as the canonical text of a version 4 UUID; a create of the same API key and IP with the same ID replaces that remote
|
||||
session when the new one is stored, and the server answers the ID of another API key or IP with <code>403 FORBIDDEN</code>),
|
||||
<code>credentials</code>, <code>cookies</code> (base64 of zlib-compressed Netscape cookie file), <code>proxy</code>,
|
||||
<code>no_proxy</code>, <code>profile</code>, <code>cache</code> (a map of <code>filename → base64(zlib(bytes))</code>),
|
||||
<code>client_region</code>, <code>server_cdm</code> (<code>false</code> when the user picked the local CDM), <code>cdm_type</code>, <code>cdm_security_level</code>, <code>cdm_relay</code> (<code>true</code> when the client
|
||||
@@ -3059,7 +3117,7 @@ layer.</p>
|
||||
fails then, because no client is listening. A fetched call waits 60 seconds for its answer.
|
||||
The call leaves the auth status as it was. An answer never marks the remote session as client-authenticated.</li>
|
||||
<li><code>AUTH_INPUT_TIMEOUT = 600.0</code> seconds. An <code>AUTHENTICATING</code> remote session expires in the store after
|
||||
the larger of <code>session_ttl</code> and this value. A remote session that waits on a prompt stays <code>AUTHENTICATING</code>.</li>
|
||||
the larger of <code>session_ttl</code> and this value, or when its client is gone. A remote session that waits on a prompt stays <code>AUTHENTICATING</code>.</li>
|
||||
</ul>
|
||||
<p><code>GET /api/session/{id}/prompt</code> returns one of:</p>
|
||||
<div class="language-json highlight"><pre><span></span><code><span id="__span-8-1"><a id="__codelineno-8-1" name="__codelineno-8-1" href="#__codelineno-8-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"authenticated"</span><span class="w"> </span><span class="p">}</span>
|
||||
@@ -3154,22 +3212,38 @@ request finds the remote session gone.</p>
|
||||
<li><strong>Config-driven limits.</strong> <code>serve.session_ttl</code> (default <code>300</code>) and
|
||||
<code>serve.max_sessions</code> (default <code>100</code>) are read as properties, so config changes
|
||||
take effect without recreating the store.</li>
|
||||
<li><strong><code>creating()</code></strong> holds the ID of a remote session while its <code>create</code> handler works, and refuses an ID that another API
|
||||
key or IP has. <strong><code>end_pending()</code></strong> ends such a create for a <code>DELETE</code>, and then <code>create()</code> stores nothing.</li>
|
||||
<li><strong><code>create()</code></strong> evicts the least-recently-accessed remote session of the API key that holds the most when at capacity,
|
||||
then stores a complete <code>SessionEntry</code> from the fields of the <code>create</code> handler and publishes the <code>create</code> event.</li>
|
||||
<li><strong>Expiry.</strong> <code>get()</code> and <code>cleanup_expired()</code> use one rule. A remote session that no request holds
|
||||
expires when it is idle for longer than <code>ttl</code>. While its login runs (<code>AUTHENTICATING</code>), the limit is
|
||||
<li><strong>Expiry.</strong> <code>get()</code> and <code>cleanup_expired()</code> use one rule. A remote session expires when its client is gone
|
||||
(<a href="#client-presence">Client presence</a>), also while a request holds it. A remote session that no request holds
|
||||
also expires when it is idle for longer than <code>ttl</code>. While its login runs (<code>AUTHENTICATING</code>), the limit is
|
||||
the larger of <code>ttl</code> and <code>AUTH_INPUT_TIMEOUT</code>.</li>
|
||||
<li><strong><code>get()</code></strong> refreshes <code>last_accessed</code> through <code>touch()</code>. It returns <code>None</code> and
|
||||
<li><strong><code>get()</code></strong> refreshes <code>last_accessed</code> and <code>idle_since</code> through <code>touch()</code>. It returns <code>None</code> and
|
||||
deletes the entry when the remote session has expired.</li>
|
||||
<li><strong><code>cleanup_expired()</code></strong> runs every 60s and removes each expired remote session.</li>
|
||||
<li><strong><code>cleanup_expired()</code></strong> runs every 5s and removes each expired remote session.</li>
|
||||
<li><strong>Removal.</strong> Eviction, expiry and <code>delete()</code> end the remote session the same way: they cancel its
|
||||
<code>InputBridge</code>, close its channel, send the <code>delete</code> dashboard event, schedule a staged service reload
|
||||
and delete its cache directory (pruning empty parent dirs up to, but not including, the cache root).</li>
|
||||
<li><strong><code>track_login(task)</code></strong> keeps each login task of <code>session/create</code> until it ends.</li>
|
||||
<li>The server calls <strong><code>close()</code></strong> on shutdown. It ends each open remote session, which
|
||||
unblocks any waiting auth threads, and deletes the cache directory of each one. It sends no dashboard event
|
||||
and schedules no reload. It then waits up to 5 seconds for each login that still runs, and stops the sweep.
|
||||
A login that ends after the shutdown deletes its cache directory again.</li>
|
||||
and delete its cache directory (pruning empty parent dirs up to, but not including, the cache root). A request
|
||||
that waits for the remote session then answers <code>SESSION_NOT_FOUND</code> and starts no service code. So does a request
|
||||
whose service code waits on the client for a prompt or a CDM call, whatever that code does next. A service thread
|
||||
that runs can still write to the cache directory, so a task deletes the directory again after the last request.</li>
|
||||
<li><strong><code>track_login(task)</code></strong> keeps each login task of <code>session/create</code>, and each task that deletes a cache directory
|
||||
again, until it ends.</li>
|
||||
<li><strong>Shutdown.</strong> First, <code>close_channels()</code> cancels each <code>InputBridge</code> and closes each channel, so no request waits
|
||||
for a client while the server waits for its requests. Then the server calls <strong><code>close()</code></strong>. It ends each open
|
||||
remote session and deletes the cache directory of each one. It sends no dashboard event
|
||||
and schedules no reload. It then waits up to 5 seconds for each tracked task that still runs, and stops the sweep.
|
||||
Within that time, a login that ends deletes its cache directory again.</li>
|
||||
<li><strong>Relay.</strong> A server that relays to a <code>remote_services</code> server runs <strong><code>end_remote_pool()</code></strong> after <code>close_channels()</code>.
|
||||
It starts the end of each remote login that waits, and of all idle pooled remote sessions at the same time. A list
|
||||
call whose login it ends, or whose login comes later, gets <code>SERVER_DRAINING</code>. A request in flight finishes first. Every
|
||||
5 seconds until it has stopped, the server ends each request that opens its lost remote session again. Then
|
||||
<strong><code>close_remote_pool()</code></strong> ends the rest and waits up to 5 seconds for each <code>DELETE</code> request. The exit of the process
|
||||
waits for an end that still runs.</li>
|
||||
<li><strong>Signals.</strong> The first <code>SIGTERM</code> starts the shutdown, and the server ignores each later one. A second Ctrl+C forces
|
||||
the end. On Windows only Ctrl+C starts the shutdown.</li>
|
||||
</ul>
|
||||
<p><code>SessionEntry</code> fields:</p>
|
||||
<table>
|
||||
@@ -3182,7 +3256,7 @@ request finds the remote session gone.</p>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>session_id</code></td>
|
||||
<td>UUID4 string</td>
|
||||
<td>UUID4 string: the one of the create request, else one that the server makes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>service_tag</code></td>
|
||||
@@ -3217,15 +3291,75 @@ request finds the remote session gone.</p>
|
||||
<td>Current <code>AuthStatus</code>, read from <code>input_bridge</code> (<code>AUTHENTICATED</code> without one), and last error message</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>presence</code></td>
|
||||
<td><code>ClientPresence</code>: the state of the client and its last sign of life</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>created_at</code> / <code>last_accessed</code></td>
|
||||
<td>Timestamps; <code>last_accessed</code> drives TTL and LRU eviction</td>
|
||||
<td>Timestamps; <code>last_accessed</code> drives LRU eviction</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>idle_since</code></td>
|
||||
<td>Monotonic time of the last access; it drives the TTL, so a step of the system clock expires no remote session</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="client-presence">Client presence<a class="headerlink" href="#client-presence" title="Permanent link">¶</a></h3>
|
||||
<p>Source: <code>unshackle/core/api/client_presence.py</code>. The server knows a client by its channel, its requests and its
|
||||
<code>create</code>. Each state has a limit for the silence of the client. At the limit, the server ends the remote session.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>State</th>
|
||||
<th>When</th>
|
||||
<th>Limit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>awaited</td>
|
||||
<td>The client gave the remote session its ID in <code>create</code>, and has sent no request and opened no channel since</td>
|
||||
<td>150s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>polling</td>
|
||||
<td>The client has had no channel</td>
|
||||
<td>The TTL rule only</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>present</td>
|
||||
<td>The channel is open</td>
|
||||
<td>None</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>away</td>
|
||||
<td>The channel closed with any code except 1000, the connection broke, or the server closed the channel</td>
|
||||
<td>180s, or half of <code>session_ttl</code> when that is more</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>left</td>
|
||||
<td>The client closed the channel with code 1000</td>
|
||||
<td>90s</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul>
|
||||
<li><strong>Sign of life.</strong> A request of the client for the remote session, or a new channel, starts the time again. The end
|
||||
of a request does not. A request after the state left makes the state away.</li>
|
||||
<li><strong>Work in progress.</strong> A request that still works for the client does not keep the remote session past the limit.</li>
|
||||
<li><strong>Login.</strong> A client that is away or left does not get the 600s of a login. Its login ends with the remote session.</li>
|
||||
<li><strong>TTL.</strong> The limit never makes a remote session stay for longer than the TTL rule lets it.</li>
|
||||
<li><strong>The <code>DELETE</code>.</strong> The client closes its channel and then sends the <code>DELETE</code>, whose answer has the login cache.
|
||||
Thus the close does not end the remote session at once.</li>
|
||||
<li><strong>A silent loss.</strong> A client that the network cuts off sends no close. The server sends a ping after 20s without
|
||||
data, and counts the client as away when no answer comes in 10s.</li>
|
||||
</ul>
|
||||
<h3 id="per-session-cache-namespacing">Per-session cache namespacing<a class="headerlink" href="#per-session-cache-namespacing" title="Permanent link">¶</a></h3>
|
||||
<p>The <code>create</code> handler builds a <code>Cacher</code> namespaced as:</p>
|
||||
<div class="language-text highlight"><pre><span></span><code><span id="__span-9-1"><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a>_sessions/<pbkdf2_hmac(sha256, X-Secret-Key, "unshackle-session-ns", 100000)[:12]>/<session_id>/<service>
|
||||
<div class="language-text highlight"><pre><span></span><code><span id="__span-9-1"><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a>_sessions/<pbkdf2_hmac(sha256, X-Secret-Key, "unshackle-session-ns", 100000)[:12]>/<uuid4>/<service>
|
||||
</span></code></pre></div>
|
||||
<p>The server makes a new UUID for each <code>create</code>, so a <code>create</code> that takes over a session ID never shares a directory
|
||||
with the one before it.</p>
|
||||
<p>The handler writes forwarded <code>cache</code> files into that directory before authentication.
|
||||
On <code>DELETE</code>, when the login belongs to the client (<code>client_auth</code>) and the remote
|
||||
session does not run on the server's device, the handler harvests updated cache files from the whole directory tree (compressing each
|
||||
@@ -3295,12 +3429,14 @@ the error codes and the request and reply shapes that it shares with the server
|
||||
(merging returned <code>session_headers</code>/<code>session_cookie_jar</code>, re-parsing <code>manifests</code>) →
|
||||
get the licence in proxy mode or <code>server_cdm</code> mode → <code>close()</code> (<code>DELETE</code>, saving any returned
|
||||
<code>cache</code>).</li>
|
||||
<li><strong>ID.</strong> The client gives the remote session its ID: a version 4 UUID in the <code>session_id</code> of <code>create</code>. It uses
|
||||
the ID of the reply, so a server that ignores the field also works.</li>
|
||||
<li>
|
||||
<p><strong>Server restarts.</strong> The server keeps remote sessions in memory only, so a restart
|
||||
loses them all. The client recovers in two ways:</p>
|
||||
<ul>
|
||||
<li>A drain announced through <code>draining</code>: the client finishes the current title, then
|
||||
closes its remote session, so the drain can end and the refreshed cache comes back.
|
||||
deletes its remote session, so the drain can end and the refreshed cache comes back.
|
||||
It waits until <code>/api/health</code> reports the restarted server without <code>draining</code>,
|
||||
opens a new remote session, and continues with the next title.</li>
|
||||
<li>A lost remote session (<code>SESSION_NOT_FOUND</code>, a connection error, an answer cut off
|
||||
@@ -3308,13 +3444,14 @@ the error codes and the request and reply shapes that it shares with the server
|
||||
for <code>/api/health</code>, then checks the old remote session. A live remote session takes the
|
||||
call again only after a connection error, because a timed-out call can already have run.
|
||||
A cut-off answer counts as a connection error, so the server can run that call twice. A lost one is replaced: the
|
||||
client opens a new remote session, sends <code>titles</code> and the current title's <code>tracks</code>
|
||||
client deletes the old one when the server did not answer <code>SESSION_NOT_FOUND</code> for the call, and
|
||||
saves the cache that comes back. It then opens a new remote session, sends <code>titles</code> and the current title's <code>tracks</code>
|
||||
again, and then sends the failed call again. A title or track that the new remote session
|
||||
gives another ID keeps its old ID on the client, and the client sends the new ID. The client matches a title by season and episode number, and a track by its
|
||||
attributes.</li>
|
||||
</ul>
|
||||
<p>The client waits up to 30 minutes for the server, which covers a deploy's drain. It
|
||||
stops with an error if the new remote session licenses differently from the old one,
|
||||
<p>The client waits up to 30 minutes for the server, which covers a deploy's drain. A Ctrl+C
|
||||
ends this wait. The client stops with an error if the new remote session licenses differently from the old one,
|
||||
for example after a change to the API key's <code>server_cdm</code> grant. An interactive login
|
||||
asks for its input again.
|
||||
- <strong>Server resolution.</strong> <code>resolve_server()</code> reads <code>config.remote_services.<name></code>
|
||||
@@ -3326,6 +3463,46 @@ asks for its input again.
|
||||
server stops the track download, and the client never keeps every segment in its place.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<h3 id="when-the-client-ends-a-remote-session">When the client ends a remote session<a class="headerlink" href="#when-the-client-ends-a-remote-session" title="Permanent link">¶</a></h3>
|
||||
<p>Source: <code>unshackle/core/remote_lifetime.py</code>. One owner holds the remote session, its tunnel and its channel
|
||||
from before the first request until the server answers the <code>DELETE</code>. It closes the channel, sends the <code>DELETE</code>,
|
||||
saves the returned cache and then stops the tunnel. It does so:</p>
|
||||
<ul>
|
||||
<li>when <code>dl</code> has finished every title, before the run post-scripts</li>
|
||||
<li>when the process exits: <code>--list</code>, an error, or Ctrl+C in any step, also before <code>create</code> answers</li>
|
||||
<li>when a signal or a closed console stops the process, or the cancel of a download job stops its worker</li>
|
||||
<li>when the login or any other step of the opening fails, or <code>create</code> times out or its answer is cut off</li>
|
||||
<li>when a serve that relays for a REST client closes its pooled remote session</li>
|
||||
<li>when such a serve stops: each remote login that waits, and all idle pooled remote sessions at the same time</li>
|
||||
</ul>
|
||||
<p>The <code>DELETE</code> 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.</p>
|
||||
<p>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,
|
||||
and the client deletes a remote session that a thread opens at that moment. The cancel does not stop a request that the
|
||||
server already has: the client waits for its answer. A failed track is no cancel, so the next title can open
|
||||
a new remote session.</p>
|
||||
<p>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, and the process then waits for no other end. The count of Ctrl+C is one for the process.
|
||||
When the run itself called the end, after the last title, that Ctrl+C also stops the run. On Windows, a Ctrl+C
|
||||
counts when the network read that blocks returns, so the 15s timeout limits the wait. After the end, no thread of the
|
||||
client opens a remote session again.</p>
|
||||
<p><code>SIGHUP</code> (a closed terminal) and <code>SIGTERM</code> stop <code>dl</code>, <code>search</code> and <code>tunnel-test</code> as Ctrl+C does, with an exit code other
|
||||
than 0. Three things are different:</p>
|
||||
<ul>
|
||||
<li>The <code>DELETE</code> goes first: before the wait for the download threads, for a CDM call and for the channel.</li>
|
||||
<li>The process ends 8s after the first signal at the latest, also when the server does not answer.</li>
|
||||
<li>A later signal changes nothing, and Ctrl+C keeps its own count.</li>
|
||||
</ul>
|
||||
<p>After <code>SIGHUP</code> the process writes nothing more to a terminal. A redirected output gets each line. <code>nohup</code> keeps its effect.
|
||||
Source: <code>unshackle/core/process_exit.py</code>.</p>
|
||||
<p>On Windows, a closed console window and Ctrl+Break send the <code>DELETE</code> and then end the process, without the rest of the
|
||||
Ctrl+C steps. The system gives a closed window about 5s. A kill (<code>SIGKILL</code>, a Windows task end, the cancel of a download
|
||||
job on Windows) sends no <code>DELETE</code>, so only the server ends the remote session, at its own limits.</p>
|
||||
<p>A cancelled job that uses a remote server sends the <code>DELETE</code> for at most 4s, then its worker ends.</p>
|
||||
<p>The <code>DELETE</code> can arrive while the server still works on <code>create</code>. The server then answers <code>200</code> with no cache, and
|
||||
the <code>create</code> makes no remote session, starts no login and answers <code>404 SESSION_NOT_FOUND</code>.</p>
|
||||
<hr />
|
||||
<h2 id="troubleshooting">Troubleshooting<a class="headerlink" href="#troubleshooting" title="Permanent link">¶</a></h2>
|
||||
<div class="admonition example">
|
||||
|
||||
@@ -2944,6 +2944,13 @@ from 1) to every song. The track list, the download order and <code>-w</code> th
|
||||
tags, the file name and the folder keep <code>track</code>, <code>disc</code> and <code>album</code>. Set it in <code>get_titles()</code>,
|
||||
because a remote client does not read it again after the listing. Such a song also needs an <code>id</code> that
|
||||
stays the same in each listing: <code>position</code> does not identify it.</p>
|
||||
<p><code>Album</code> and <code>Music</code> take the facts of the collection itself: <code>kind</code>, <code>title</code>, <code>artist</code>, <code>year</code>,
|
||||
<code>total_tracks</code>, <code>total_discs</code>, <code>artwork_url</code>, <code>total_duration</code>, <code>owner</code> and <code>description</code>. A
|
||||
remote client gets all of them. When every song has the same <code>album</code> and <code>album_artist</code>, the listing
|
||||
takes a <code>title</code>, <code>artist</code> or <code>year</code> that you do not give, and the release date, quality, genre and
|
||||
label, from the first song. The listing of any other collection, such as a playlist of single songs,
|
||||
has no line for them. <code>build_music_from_songs</code> uses the same test before it takes the title, artist, year, artwork or
|
||||
totals from the songs.</p>
|
||||
<p>The tagger also falls back to <code>Song.data</code> for fields the constructor did not get, such
|
||||
as the composer or a full release date. It reads the top level of that dict and a
|
||||
nested <code>metadata</code> sub-dict, with the nested keys winning, so either shape works. The keys
|
||||
@@ -3133,9 +3140,13 @@ least one and no track is left.</p>
|
||||
<h3 id="segment-filtering-hooks">Segment-filtering hooks<a class="headerlink" href="#segment-filtering-hooks" title="Permanent link">¶</a></h3>
|
||||
<ul>
|
||||
<li><strong>HLS</strong>: set <code>track.OnSegmentFilter(segment)</code> to drop unwanted segments (ads/bumpers).
|
||||
A dropped segment is invisible to the whole download: unshackle ignores its <code>EXT-X-KEY</code>
|
||||
and its <code>EXT-X-DISCONTINUITY</code>, so a clear ad break inside an encrypted track does
|
||||
not disturb decryption.</li>
|
||||
An <code>EXT-X-KEY</code> applies to each later segment until the next <code>EXT-X-KEY</code>, also when the
|
||||
filter or <code>--sample</code> drops the segment that carries it. unshackle ignores an <code>EXT-X-KEY</code> that
|
||||
applies to dropped segments only: no licence, no request and no new decryption. It also
|
||||
ignores the <code>EXT-X-DISCONTINUITY</code> of a dropped segment. A dropped ad break thus does not
|
||||
disturb decryption when the playlist repeats the <code>EXT-X-KEY</code> of the title after the break.
|
||||
Without the repeat, the segments after the break take the <code>EXT-X-KEY</code> of the ads, and
|
||||
<code>METHOD=NONE</code> there makes them clear.</li>
|
||||
<li><strong>DASH</strong>: pass a <code>period_filter</code> callable to <code>to_tracks</code> to drop whole periods.
|
||||
unshackle automatically drops the caching-breadth periods that some services send, and the non-<code>content</code> segment types.</li>
|
||||
</ul>
|
||||
@@ -3273,7 +3284,24 @@ that needs a process on the server also works for a remote client.</p>
|
||||
<h3 id="a-playlist-whose-key-tag-unshackle-cannot-license">A playlist whose key tag unshackle cannot license<a class="headerlink" href="#a-playlist-whose-key-tag-unshackle-cannot-license" title="Permanent link">¶</a></h3>
|
||||
<p>A media playlist can name only a key system that unshackle does not read, such as an <code>skd://</code> key
|
||||
over cbcs media, while the licence server of the platform also issues the same content key over
|
||||
PlayReady or Widevine. To license such a track through one of those systems:</p>
|
||||
PlayReady or Widevine. <code>HLS.download_track</code> licenses such a track with no service code when all of
|
||||
these conditions are true:</p>
|
||||
<ul>
|
||||
<li>The track has no DRM object.</li>
|
||||
<li>Every <code>EXT-X-KEY</code> of its media playlist is <code>SAMPLE-AES</code> or <code>SAMPLE-AES-CTR</code> for a DRM system
|
||||
unshackle cannot license.</li>
|
||||
<li>The configured CDM is a PlayReady or Widevine CDM.</li>
|
||||
<li>The init segment (<code>EXT-X-MAP</code>) of the track names a key ID in its <code>tenc</code> box. When the <code>tenc</code> key ID is all
|
||||
zeros, its <code>pssh</code> boxes must name exactly one key ID, and the encrypted segments must have one init
|
||||
segment and the playlist one key URI. MPEG-TS media has no init segment.</li>
|
||||
<li>The init segment does not change without an <code>EXT-X-DISCONTINUITY</code>.</li>
|
||||
</ul>
|
||||
<p>The download reads the key ID from the init segment, builds a DRM object for the DRM system of the
|
||||
CDM with <code>drm_stub</code>, and sends the challenge to the licence callback of the service. Over <code>--remote</code>
|
||||
the server reads the same key ID at the licence step, so it accepts the DRM object of the client. A
|
||||
licence that gives no content key stops the track before it downloads a segment.</p>
|
||||
<p>A service that must choose the DRM system itself, or one that knows the key ID, puts the DRM object
|
||||
on the track:</p>
|
||||
<ol>
|
||||
<li>Read the key ID from the init segment of the track. <code>HLS.get_track_kid_from_init</code> returns it.</li>
|
||||
<li>Put a DRM object that names the key ID on the track: <code>drm_stub</code> from <code>unshackle.core.drm.cenc</code>
|
||||
@@ -3287,8 +3315,9 @@ content key of one package of a title and refuse another. When a track carries a
|
||||
object and every <code>EXT-X-KEY</code> of its playlist is <code>SAMPLE-AES</code> or <code>SAMPLE-AES-CTR</code> for a key system
|
||||
unshackle cannot license, <code>HLS.drop_unsupported_keys</code> 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. A track with no such
|
||||
DRM object stops with <code>None of the key systems are supported</code> before it downloads a segment.</p>
|
||||
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
|
||||
<code>None of the key systems are supported</code> before it downloads a segment.</p>
|
||||
<h3 id="how-unshackle-chooses-a-cdm-and-finds-keys">How unshackle chooses a CDM and finds keys<a class="headerlink" href="#how-unshackle-chooses-a-cdm-and-finds-keys" title="Permanent link">¶</a></h3>
|
||||
<p>CDM selection is config-driven: the <code>cdm</code> map resolves a service tag (and optionally the
|
||||
track quality or DRM type) to a device name, which <code>load_cdm</code> instantiates as a local
|
||||
|
||||
@@ -3984,7 +3984,9 @@ and <code>-w</code> takes it. The tags and the file name keep the album track nu
|
||||
</div>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Read the track list first</p>
|
||||
<p><code>--list-titles</code> prints the release with the numbers that <code>-w</code> takes.</p>
|
||||
<p><code>--list-titles</code> prints the release with the numbers that <code>-w</code> takes. The lines above the track
|
||||
list describe the release. For songs of different releases, such as a playlist or an artist
|
||||
listing, they show only what the service gives for the collection.</p>
|
||||
</div>
|
||||
<h3 id="daily-and-date-based-content">Daily and date-based content<a class="headerlink" href="#daily-and-date-based-content" title="Permanent link">¶</a></h3>
|
||||
<p>Talk shows, news and sports have no official episode numbering, so unshackle names them
|
||||
|
||||
@@ -2722,6 +2722,13 @@ The differences that matter to you are:</p>
|
||||
<p>To download a Widevine-protected title you need a <code>.wvd</code> device. For PlayReady you
|
||||
need a <code>.prd</code> device. You can hold both, and unshackle automatically selects the
|
||||
appropriate one for each track.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">HLS tracks with only a FairPlay key tag</p>
|
||||
<p>unshackle has no FairPlay CDM. When each <code>EXT-X-KEY</code> of an fMP4 playlist is sample encryption
|
||||
for a DRM system that unshackle cannot license, such as FairPlay, unshackle reads the key ID from
|
||||
the init segment and asks for the licence with your PlayReady or Widevine device. This works
|
||||
only when the licence server of the platform also issues that content key for that DRM system. MPEG-TS SAMPLE-AES stops with an error.</p>
|
||||
</div>
|
||||
<div class="admonition info">
|
||||
<p class="admonition-title">Obtaining device files</p>
|
||||
<p>A <code>.wvd</code> or <code>.prd</code> encodes the private keys of a real client device. unshackle
|
||||
@@ -3143,6 +3150,8 @@ systems can list different sets of KIDs, and unshackle keeps the content keys of
|
||||
system does not license, so the title fails unless you use <code>--best-available</code>.</li>
|
||||
<li>An HLS playlist that changes its <code>EXT-X-KEY</code> entries part-way: only the first set
|
||||
licenses with the second system.</li>
|
||||
<li>An HLS playlist with only FairPlay key tags: the DRM system of the configured CDM
|
||||
licenses it.</li>
|
||||
<li>A remote session that the server CDM licenses, and <code>unshackle import</code>. unshackle
|
||||
shows a warning and ignores the flag.</li>
|
||||
<li>A remote CDM that stores content keys can answer without a challenge to the service.</li>
|
||||
|
||||
@@ -8952,13 +8952,14 @@ of <code>get_init_segment</code> to find the Key ID.</p>
|
||||
|
||||
|
||||
<a href="#unshackle.core.tracks.Track.load_drm_from_playlist" class="headerlink" title="Permanent link">¶</a></h3>
|
||||
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">load_drm_from_playlist</span><span class="p">(</span><span class="n">session</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
|
||||
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">load_drm_from_playlist</span><span class="p">(</span><span class="n">session</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">bridge</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
</span></code></pre></div>
|
||||
|
||||
<div class="doc doc-contents ">
|
||||
|
||||
<p>Load the Widevine and PlayReady DRM of the EXT-X-KEY and EXT-X-SESSION-KEY tags of this track's playlist.</p>
|
||||
<p>It skips a tag that gives no DRM, and raises ValueError when the fetch fails or when every such tag fails.</p>
|
||||
<p>It skips a tag that gives no DRM, and raises ValueError when the fetch fails or when every such tag fails.
|
||||
With <code>bridge</code> it builds both stubs for the key ID that <code>HLS.get_bridge_kid</code> finds when no tag gives a DRM.</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -2285,7 +2285,7 @@ is the <a href="../../../dev/rest-api/">REST API</a> section. These are the conf
|
||||
<td><code>session_ttl</code></td>
|
||||
<td>int (s)</td>
|
||||
<td><code>300</code></td>
|
||||
<td>Seconds a remote session can stay idle before it expires. A remote client sends keep-alive requests to its remote session during a download, so the remote session does not expire during a long download. A remote session that still logs in can stay idle for the larger of this value and 600 seconds.</td>
|
||||
<td>Seconds a remote session can stay idle before it expires. A remote client sends keep-alive requests to its remote session during a download, so the remote session does not expire during a long download. A remote session that still logs in can stay idle for the larger of this value and 600 seconds. A client that closes or loses its channel and does not come back loses its remote session sooner: see <a href="../../../dev/rest-api/remote-sessions/#client-presence">Client presence</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>max_sessions</code></td>
|
||||
|
||||
File diff suppressed because one or more lines are too long
+38
-38
@@ -2,154 +2,154 @@
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/creating-a-service/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/service-architecture/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/authentication/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/dashboard/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/endpoints/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/errors/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/job-lifecycle/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/quickstart/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/dev/rest-api/remote-sessions/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/getting-started/configuration-file/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/getting-started/installation/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/getting-started/quickstart/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/cli-reference/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/downloading/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/drm-and-cdm/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/output-and-naming/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/proxies-and-vpn/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/subtitles/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/troubleshooting/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/guide/vaults/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/api/config/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/api/drm/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/api/service/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/api/titles/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/api/tracks/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/directories/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/download/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/drm/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/example/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/misc/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/network/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/output/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/post-scripts/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/services/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://docs.unshackle.dev/reference/configuration/vaults/</loc>
|
||||
<lastmod>2026-11-30</lastmod>
|
||||
<lastmod>2026-12-01</lastmod>
|
||||
</url>
|
||||
</urlset>
|
||||
Binary file not shown.
Reference in New Issue
Block a user