forked from kenzuya/unshackle
Deployed 4bcc15df with MkDocs version: 1.6.1
This commit is contained in:
@@ -3495,7 +3495,7 @@
|
||||
<td><code>cdm_type</code></td>
|
||||
<td>string</td>
|
||||
<td>no</td>
|
||||
<td>Preferred CDM type.</td>
|
||||
<td>Preferred CDM type. A request that sets one of the service's <code>SERVER_DEVICE_OPTIONS</code> ignores it: the server loads the first-listed device of its <code>cdm</code> entry.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>credentials</code>, <code>cookies</code>, <code>cache</code></td>
|
||||
@@ -3687,7 +3687,7 @@ ignore it safely. See <a href="../../creating-a-service/#split-episodes">Split e
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="post-apilist-tracks"><code>POST /api/list-tracks</code><a class="headerlink" href="#post-apilist-tracks" title="Permanent link">¶</a></h3>
|
||||
<p>Show the video, audio, and subtitle tracks for a title. For series, you can scope to specific episodes.</p>
|
||||
<p>Show the video, audio, and subtitle tracks for a title. For series, you can scope to specific episodes. Each <code>title</code> in the response has the form of a <a href="#post-apilist-titles"><code>list-titles</code></a> title, with the same service flags (<code>anime</code>, <code>daily</code>, <code>metadata_provider</code>).</p>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Spotting the original-language audio</p>
|
||||
<p>Each audio track carries <code>is_original</code>, which marks the track the default <code>lang</code> of <code>orig</code> selects. unshackle finds it with the same language matcher the downloader uses. Thus it stays correct for regional variants a client cannot separate from tag text alone (<code>pt</code> marks <code>pt-BR</code> rather than <code>pt-PT</code>). Services need not report a title's language, so every track can legitimately come back <code>false</code>.</p>
|
||||
@@ -4971,7 +4971,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 awaiting interactive authentication input, which uses a 600s window. 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 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
|
||||
@@ -5267,7 +5267,7 @@ A slow answer arrives as a <a href="#slow-responses">slow response</a>.</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="post-apisessionsession_idsegments"><code>POST /api/session/{session_id}/segments</code><a class="headerlink" href="#post-apisessionsession_idsegments" title="Permanent link">¶</a></h3>
|
||||
<p>Get the download URL, DRM info, headers, cookies, and raw track data for the selected tracks. Body: <code>{ "track_ids": ["v-1", "a-1"] }</code> (required). A track that the tracks response sent with <code>resolve_url</code> 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 <a href="#slow-responses">Slow responses</a>.</p>
|
||||
<p>Get the download URL, DRM info, headers, cookies, and track data for the selected tracks. Body: <code>{ "track_ids": ["v-1", "a-1"] }</code> (required). A track that the tracks response sent with <code>resolve_url</code> 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 <a href="#slow-responses">Slow responses</a>.</p>
|
||||
<div class="tabbed-set tabbed-alternate" data-tabs="26:1"><input checked="checked" id="__tabbed_26_1" name="__tabbed_26" type="radio" /><div class="tabbed-labels"><label for="__tabbed_26_1">Response <code>200</code></label></div>
|
||||
<div class="tabbed-content">
|
||||
<div class="tabbed-block">
|
||||
@@ -5280,7 +5280,7 @@ A slow answer arrives as a <a href="#slow-responses">slow response</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p><code>cookies</code> gives names and values only. <code>cookie_jar</code> gives the same cookies with their domain, path and <code>secure</code> flag, in the <code>session_cookie_jar</code> form of the tracks response.</p>
|
||||
<p><code>data</code> has the form of the track <code>data</code> in <code>list-tracks</code>: the JSON-safe part of the service-set <code>track.data</code>, without the <code>hls</code>, <code>dash</code>, and <code>ism</code> parser keys. <code>cookies</code> gives names and values only. <code>cookie_jar</code> gives the same cookies with their domain, path and <code>secure</code> flag, in the <code>session_cookie_jar</code> form of the tracks response.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -2676,8 +2676,8 @@ full detail:</p>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>speed</code></td>
|
||||
<td>string</td>
|
||||
<td>Transfer speed of the track in progress, e.g. <code>4.20 MB/s</code>.</td>
|
||||
<td>string or <code>null</code></td>
|
||||
<td>Transfer speed of the track in progress, e.g. <code>4.20 MB/s</code>. <code>null</code> when no track downloads.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>skipped_subtitles</code></td>
|
||||
@@ -2903,7 +2903,8 @@ download, and on finish stamps <code>completed_time</code> and records history.<
|
||||
server process. For each job it spawns a separate Python subprocess:</p>
|
||||
<div class="language-text highlight"><pre><span></span><code><span id="__span-7-1"><a id="__codelineno-7-1" name="__codelineno-7-1" href="#__codelineno-7-1"></a>python -m unshackle.core.api.download_worker <payload.json> <result.json> <progress.json>
|
||||
</span></code></pre></div>
|
||||
<p>Three temporary files bridge the parent and the job worker:</p>
|
||||
<p>Three temporary files bridge the parent and the job worker. <code>unshackle/core/api/job_channel.py</code> defines each file
|
||||
and the stdin answer line:</p>
|
||||
<ul>
|
||||
<li><strong><code>payload.json</code></strong>: the manager writes it before launch. It contains the job ID,
|
||||
service, title ID, and merged parameters.</li>
|
||||
@@ -2920,14 +2921,16 @@ the end of its prompt or notice sets it back to <code>null</code>.</p>
|
||||
and blocking work inside the download engine, and makes hard cancellation (killing the
|
||||
process) reliable.</p>
|
||||
<p>The job worker's exit codes are <code>0</code> for success, <code>1</code> for a download error, and <code>2</code> for bad
|
||||
arguments. Its <code>result.json</code> is either <code>{"status": "success", "output_files": [...]}</code>
|
||||
or <code>{"status": "error", "message", "error_details", "error_code", "traceback"}</code>. If the
|
||||
arguments. Its <code>result.json</code> holds <code>status</code>, <code>output_files</code>, <code>message</code>, <code>error_details</code>, <code>error_code</code> and
|
||||
<code>traceback</code>. The <code>status</code> is <code>success</code> or <code>error</code>, and a success leaves the error fields <code>null</code>. If the
|
||||
process exits non-zero, or the result is missing or not a success, the parent marks the
|
||||
job <code>failed</code> and adopts the job worker's <code>error_code</code> (or derives one by categorising the
|
||||
exception).</p>
|
||||
<h3 id="how-progress-reaches-the-api">How progress reaches the API<a class="headerlink" href="#how-progress-reaches-the-api" title="Permanent link">¶</a></h3>
|
||||
<p>While the job worker operates, the manager polls <code>progress.json</code> every <strong>0.5 s</strong> and copies the
|
||||
fields it finds onto the live <code>DownloadJob</code>. That is what the <code>GET</code> endpoints return.</p>
|
||||
fields it finds onto the live <code>DownloadJob</code>. That is what the <code>GET</code> endpoints return. The file
|
||||
holds the whole progress record each time, so each field in it replaces the job's value, <code>0</code> and
|
||||
<code>null</code> too.</p>
|
||||
<p>The job worker aggregates progress across all selected tracks. It weights each track's
|
||||
completion fraction by its bitrate, so video and audio dominate the bar and subtitles
|
||||
barely move it (subtitles get a small fixed weight). Track fractions are kept
|
||||
|
||||
@@ -2836,7 +2836,7 @@ 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>Sessions still authenticating or awaiting a prompt use this longer window instead of the TTL</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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cleanup sweep</td>
|
||||
@@ -2847,10 +2847,9 @@ generally never touch this directly, but it explains behaviour you might observe
|
||||
</table>
|
||||
<div class="admonition note">
|
||||
<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> is
|
||||
<strong>not</strong> subject to the short 300s TTL. It gets the full 600s auth window. This gives
|
||||
you time to enter an interactive code without the remote session vanishing
|
||||
mid-prompt.</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>
|
||||
</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>
|
||||
@@ -3058,8 +3057,8 @@ layer.</p>
|
||||
channel carries it, or the client polls while its own requests run. A call that no client fetches within 10 seconds
|
||||
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. This is also the TTL granted to
|
||||
<code>AUTHENTICATING</code> sessions in the store. A remote session that waits on a prompt stays <code>AUTHENTICATING</code>.</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>
|
||||
</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>
|
||||
@@ -3156,16 +3155,20 @@ request finds the remote session gone.</p>
|
||||
take effect without recreating the store.</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><code>get()</code></strong> refreshes <code>last_accessed</code> through <code>touch()</code>. It returns <code>None</code> (and
|
||||
deletes the entry) if an authenticated remote session has been idle longer than the
|
||||
TTL. Remote sessions in <code>AUTHENTICATING</code> are exempt from TTL expiry.</li>
|
||||
<li><strong><code>cleanup_expired()</code></strong> runs every 60s: authenticated remote sessions expire at
|
||||
<code>ttl</code>, in-flight-auth remote sessions expire at <code>AUTH_INPUT_TIMEOUT</code>. The removal of
|
||||
a remote session cancels its <code>InputBridge</code> and deletes its cache directory (pruning
|
||||
empty parent dirs up to, but not including, the cache root).</li>
|
||||
<li>The server calls <strong><code>cancel_all_bridges()</code></strong> on shutdown. It ends each open remote session, which
|
||||
unblocks any waiting auth threads, and deletes the cache directory of each one. The server then waits up
|
||||
to 5 seconds for each login that still runs, and deletes its cache directory again when it ends.</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
|
||||
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
|
||||
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>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>
|
||||
</ul>
|
||||
<p><code>SessionEntry</code> fields:</p>
|
||||
<table>
|
||||
|
||||
Reference in New Issue
Block a user