Deployed 291417db with MkDocs version: 1.6.1

This commit is contained in:
2026-11-26 20:30:10 +00:00
parent 9cb51a4c1f
commit 3efcd59710
7 changed files with 376 additions and 341 deletions
+157 -144
View File
@@ -2691,6 +2691,19 @@ returns a value. <code>check</code> returns <code>None</code> while the approval
when the client deletes the remote session, so the loop does not continue on the
server with no client. The message goes out as a log line, so a remote
session shows it. A REST download job shows it in its <code>notice</code> field until the wait ends.</p>
<p>For a login that the user scans with a phone, give the text of the QR code as <code>qr</code>. Both
<code>wait_for_approval</code> and <code>request_input</code> take it. The terminal that shows the message draws
the code under it, on the client for a remote session. Give the text that the login API puts in
the code, such as the login URL, not an image. Keep the URL or code in the message too: a
terminal that cannot draw the code, or a phone that cannot read it, still shows the text.
<code>EXAMPLE.scan_login</code> in <code>unshackle/services/EXAMPLE/</code> shows the whole flow.</p>
<div class="language-python 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="n">token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wait_for_approval</span><span class="p">(</span>
</span><span id="__span-8-2"><a id="__codelineno-8-2" name="__codelineno-8-2" href="#__codelineno-8-2"></a> <span class="sa">f</span><span class="s2">"Scan the code with the app, or open </span><span class="si">{</span><span class="n">login_url</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span>
</span><span id="__span-8-3"><a id="__codelineno-8-3" name="__codelineno-8-3" href="#__codelineno-8-3"></a> <span class="n">check</span><span class="o">=</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">poll_login</span><span class="p">(</span><span class="n">session_id</span><span class="p">),</span>
</span><span id="__span-8-4"><a id="__codelineno-8-4" name="__codelineno-8-4" href="#__codelineno-8-4"></a> <span class="n">timeout</span><span class="o">=</span><span class="n">expires_in</span><span class="p">,</span>
</span><span id="__span-8-5"><a id="__codelineno-8-5" name="__codelineno-8-5" href="#__codelineno-8-5"></a> <span class="n">qr</span><span class="o">=</span><span class="n">login_url</span><span class="p">,</span>
</span><span id="__span-8-6"><a id="__codelineno-8-6" name="__codelineno-8-6" href="#__codelineno-8-6"></a><span class="p">)</span>
</span></code></pre></div>
<p>The wait sees a cancel only between two <code>check</code> calls, so <code>check</code> must return within a few
seconds. A <code>check</code> that reads a socket keeps the socket open across calls and returns <code>None</code>
after each short idle wait.</p>
@@ -2739,26 +2752,26 @@ identity for you.</p>
<p>Every title carries a <code>language</code> (its <strong>original recorded language</strong>) and an
arbitrary <code>data</code> dict you can use to stash metadata for later methods. You must
return at least one title. If you return none, unshackle treats the ID as invalid.</p>
<div class="language-python 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="k">def</span><span class="w"> </span><span class="nf">get_titles</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="__span-8-2"><a id="__codelineno-8-2" name="__codelineno-8-2" href="#__codelineno-8-2"></a> <span class="n">match</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TITLE_RE</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</span><span id="__span-8-3"><a id="__codelineno-8-3" name="__codelineno-8-3" href="#__codelineno-8-3"></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">match</span><span class="p">:</span>
</span><span id="__span-8-4"><a id="__codelineno-8-4" name="__codelineno-8-4" href="#__codelineno-8-4"></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Could not parse a title ID - is the URL/ID correct?"</span><span class="p">)</span>
</span><span id="__span-8-5"><a id="__codelineno-8-5" name="__codelineno-8-5" href="#__codelineno-8-5"></a> <span class="n">metadata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
</span><span id="__span-8-6"><a id="__codelineno-8-6" name="__codelineno-8-6" href="#__codelineno-8-6"></a> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">title_id</span><span class="o">=</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="s2">"title_id"</span><span class="p">)),</span>
</span><span id="__span-8-7"><a id="__codelineno-8-7" name="__codelineno-8-7" href="#__codelineno-8-7"></a> <span class="n">params</span><span class="o">=</span><span class="p">{</span><span class="s2">"token"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">token</span><span class="p">},</span>
</span><span id="__span-8-8"><a id="__codelineno-8-8" name="__codelineno-8-8" href="#__codelineno-8-8"></a> <span class="p">)</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-8-9"><a id="__codelineno-8-9" name="__codelineno-8-9" href="#__codelineno-8-9"></a> <span class="n">original_lang</span> <span class="o">=</span> <span class="n">Language</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">metadata</span><span class="p">[</span><span class="s2">"languages"</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
</span><span id="__span-8-10"><a id="__codelineno-8-10" name="__codelineno-8-10" href="#__codelineno-8-10"></a>
</span><span id="__span-8-11"><a id="__codelineno-8-11" name="__codelineno-8-11" href="#__codelineno-8-11"></a> <span class="k">return</span> <span class="n">Movies</span><span class="p">([</span>
</span><span id="__span-8-12"><a id="__codelineno-8-12" name="__codelineno-8-12" href="#__codelineno-8-12"></a> <span class="n">Movie</span><span class="p">(</span>
</span><span id="__span-8-13"><a id="__codelineno-8-13" name="__codelineno-8-13" href="#__codelineno-8-13"></a> <span class="n">id_</span><span class="o">=</span><span class="n">metadata</span><span class="p">[</span><span class="s2">"id"</span><span class="p">],</span>
</span><span id="__span-8-14"><a id="__codelineno-8-14" name="__codelineno-8-14" href="#__codelineno-8-14"></a> <span class="n">service</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span>
</span><span id="__span-8-15"><a id="__codelineno-8-15" name="__codelineno-8-15" href="#__codelineno-8-15"></a> <span class="n">name</span><span class="o">=</span><span class="n">metadata</span><span class="p">[</span><span class="s2">"title"</span><span class="p">],</span>
</span><span id="__span-8-16"><a id="__codelineno-8-16" name="__codelineno-8-16" href="#__codelineno-8-16"></a> <span class="n">year</span><span class="o">=</span><span class="n">metadata</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"releaseYear"</span><span class="p">)</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">,</span>
</span><span id="__span-8-17"><a id="__codelineno-8-17" name="__codelineno-8-17" href="#__codelineno-8-17"></a> <span class="n">language</span><span class="o">=</span><span class="n">original_lang</span><span class="p">,</span> <span class="c1"># ORIGINAL audio language, not the -l preference</span>
</span><span id="__span-8-18"><a id="__codelineno-8-18" name="__codelineno-8-18" href="#__codelineno-8-18"></a> <span class="n">data</span><span class="o">=</span><span class="n">metadata</span><span class="p">,</span> <span class="c1"># read later as title.data</span>
</span><span id="__span-8-19"><a id="__codelineno-8-19" name="__codelineno-8-19" href="#__codelineno-8-19"></a> <span class="p">)</span>
</span><span id="__span-8-20"><a id="__codelineno-8-20" name="__codelineno-8-20" href="#__codelineno-8-20"></a> <span class="p">])</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-9-1"><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_titles</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="__span-9-2"><a id="__codelineno-9-2" name="__codelineno-9-2" href="#__codelineno-9-2"></a> <span class="n">match</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TITLE_RE</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</span><span id="__span-9-3"><a id="__codelineno-9-3" name="__codelineno-9-3" href="#__codelineno-9-3"></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">match</span><span class="p">:</span>
</span><span id="__span-9-4"><a id="__codelineno-9-4" name="__codelineno-9-4" href="#__codelineno-9-4"></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Could not parse a title ID - is the URL/ID correct?"</span><span class="p">)</span>
</span><span id="__span-9-5"><a id="__codelineno-9-5" name="__codelineno-9-5" href="#__codelineno-9-5"></a> <span class="n">metadata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
</span><span id="__span-9-6"><a id="__codelineno-9-6" name="__codelineno-9-6" href="#__codelineno-9-6"></a> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">title_id</span><span class="o">=</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="s2">"title_id"</span><span class="p">)),</span>
</span><span id="__span-9-7"><a id="__codelineno-9-7" name="__codelineno-9-7" href="#__codelineno-9-7"></a> <span class="n">params</span><span class="o">=</span><span class="p">{</span><span class="s2">"token"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">token</span><span class="p">},</span>
</span><span id="__span-9-8"><a id="__codelineno-9-8" name="__codelineno-9-8" href="#__codelineno-9-8"></a> <span class="p">)</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-9-9"><a id="__codelineno-9-9" name="__codelineno-9-9" href="#__codelineno-9-9"></a> <span class="n">original_lang</span> <span class="o">=</span> <span class="n">Language</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">metadata</span><span class="p">[</span><span class="s2">"languages"</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
</span><span id="__span-9-10"><a id="__codelineno-9-10" name="__codelineno-9-10" href="#__codelineno-9-10"></a>
</span><span id="__span-9-11"><a id="__codelineno-9-11" name="__codelineno-9-11" href="#__codelineno-9-11"></a> <span class="k">return</span> <span class="n">Movies</span><span class="p">([</span>
</span><span id="__span-9-12"><a id="__codelineno-9-12" name="__codelineno-9-12" href="#__codelineno-9-12"></a> <span class="n">Movie</span><span class="p">(</span>
</span><span id="__span-9-13"><a id="__codelineno-9-13" name="__codelineno-9-13" href="#__codelineno-9-13"></a> <span class="n">id_</span><span class="o">=</span><span class="n">metadata</span><span class="p">[</span><span class="s2">"id"</span><span class="p">],</span>
</span><span id="__span-9-14"><a id="__codelineno-9-14" name="__codelineno-9-14" href="#__codelineno-9-14"></a> <span class="n">service</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span>
</span><span id="__span-9-15"><a id="__codelineno-9-15" name="__codelineno-9-15" href="#__codelineno-9-15"></a> <span class="n">name</span><span class="o">=</span><span class="n">metadata</span><span class="p">[</span><span class="s2">"title"</span><span class="p">],</span>
</span><span id="__span-9-16"><a id="__codelineno-9-16" name="__codelineno-9-16" href="#__codelineno-9-16"></a> <span class="n">year</span><span class="o">=</span><span class="n">metadata</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"releaseYear"</span><span class="p">)</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">,</span>
</span><span id="__span-9-17"><a id="__codelineno-9-17" name="__codelineno-9-17" href="#__codelineno-9-17"></a> <span class="n">language</span><span class="o">=</span><span class="n">original_lang</span><span class="p">,</span> <span class="c1"># ORIGINAL audio language, not the -l preference</span>
</span><span id="__span-9-18"><a id="__codelineno-9-18" name="__codelineno-9-18" href="#__codelineno-9-18"></a> <span class="n">data</span><span class="o">=</span><span class="n">metadata</span><span class="p">,</span> <span class="c1"># read later as title.data</span>
</span><span id="__span-9-19"><a id="__codelineno-9-19" name="__codelineno-9-19" href="#__codelineno-9-19"></a> <span class="p">)</span>
</span><span id="__span-9-20"><a id="__codelineno-9-20" name="__codelineno-9-20" href="#__codelineno-9-20"></a> <span class="p">])</span>
</span></code></pre></div>
<h3 id="optional-availability-metadata">Optional availability metadata<a class="headerlink" href="#optional-availability-metadata" title="Permanent link">&para;</a></h3>
<p>A service may set <code>title.data["availability"]</code> to a dict with two optional fields:</p>
@@ -2775,13 +2788,13 @@ them, and nothing in core reads them to select or authorize downloads.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="1:3"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Movie</label><label for="__tabbed_1_2">Episode</label><label for="__tabbed_1_3">Song</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-python highlight"><pre><span></span><code><span id="__span-9-1"><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a><span class="n">Movie</span><span class="p">(</span><span class="n">id_</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">year</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">language</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-10-1"><a id="__codelineno-10-1" name="__codelineno-10-1" href="#__codelineno-10-1"></a><span class="n">Movie</span><span class="p">(</span><span class="n">id_</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">year</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">language</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
</span></code></pre></div>
</div>
<div class="tabbed-block">
<div class="language-python highlight"><pre><span></span><code><span id="__span-10-1"><a id="__codelineno-10-1" name="__codelineno-10-1" href="#__codelineno-10-1"></a><span class="n">Episode</span><span class="p">(</span><span class="n">id_</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">season</span><span class="p">,</span> <span class="n">number</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">year</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
</span><span id="__span-10-2"><a id="__codelineno-10-2" name="__codelineno-10-2" href="#__codelineno-10-2"></a> <span class="n">language</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">air_date</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
</span><span id="__span-10-3"><a id="__codelineno-10-3" name="__codelineno-10-3" href="#__codelineno-10-3"></a> <span class="n">part</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-11-1"><a id="__codelineno-11-1" name="__codelineno-11-1" href="#__codelineno-11-1"></a><span class="n">Episode</span><span class="p">(</span><span class="n">id_</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">season</span><span class="p">,</span> <span class="n">number</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">year</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
</span><span id="__span-11-2"><a id="__codelineno-11-2" name="__codelineno-11-2" href="#__codelineno-11-2"></a> <span class="n">language</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">air_date</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
</span><span id="__span-11-3"><a id="__codelineno-11-3" name="__codelineno-11-3" href="#__codelineno-11-3"></a> <span class="n">part</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
</span></code></pre></div>
<p>Pass <code>air_date</code> for daily and sports titles to name by date instead of
<code>SxxExx</code>. Return a <code>Series([...])</code> of episodes. Pass <code>part</code> only when the
@@ -2789,8 +2802,8 @@ service splits one episode into several videos, see
<a href="#split-episodes">Split episodes</a>.</p>
</div>
<div class="tabbed-block">
<div class="language-python highlight"><pre><span></span><code><span id="__span-11-1"><a id="__codelineno-11-1" name="__codelineno-11-1" href="#__codelineno-11-1"></a><span class="n">Song</span><span class="p">(</span><span class="n">id_</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">artist</span><span class="p">,</span> <span class="n">album</span><span class="p">,</span> <span class="n">track</span><span class="p">,</span> <span class="n">disc</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">year</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
</span><span id="__span-11-2"><a id="__codelineno-11-2" name="__codelineno-11-2" href="#__codelineno-11-2"></a> <span class="n">language</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-12-1"><a id="__codelineno-12-1" name="__codelineno-12-1" href="#__codelineno-12-1"></a><span class="n">Song</span><span class="p">(</span><span class="n">id_</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">artist</span><span class="p">,</span> <span class="n">album</span><span class="p">,</span> <span class="n">track</span><span class="p">,</span> <span class="n">disc</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">year</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
</span><span id="__span-12-2"><a id="__codelineno-12-2" name="__codelineno-12-2" href="#__codelineno-12-2"></a> <span class="n">language</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
</span></code></pre></div>
<p>Return an <code>Album([...])</code> of songs. <code>disc</code> defaults to 1 and <code>year</code> is optional.
Optional metadata keywords such as <code>album_artist</code>, <code>genre</code>, <code>isrc</code>, <code>label</code>,
@@ -2819,8 +2832,8 @@ when the API errors. It also applies the per-service <code>title_map</code> conf
<p>Some services split one logical episode into several separately playable videos, for
example a variety show that ships episode 1 as <em>Episode 1 (Part 1)</em>, <em>(Part 2)</em> and
<em>(Part 3)</em>. <code>Episode.number</code> stays an <code>int</code>. The optional <code>part</code> carries the index.</p>
<div class="language-python highlight"><pre><span></span><code><span id="__span-12-1"><a id="__codelineno-12-1" name="__codelineno-12-1" href="#__codelineno-12-1"></a><span class="n">Episode</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">season</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">number</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">part</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"The Reckoning"</span><span class="p">)</span>
</span><span id="__span-12-2"><a id="__codelineno-12-2" name="__codelineno-12-2" href="#__codelineno-12-2"></a><span class="n">Episode</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">season</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">number</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">part</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"The Reckoning"</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-13-1"><a id="__codelineno-13-1" name="__codelineno-13-1" href="#__codelineno-13-1"></a><span class="n">Episode</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">season</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">number</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">part</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"The Reckoning"</span><span class="p">)</span>
</span><span id="__span-13-2"><a id="__codelineno-13-2" name="__codelineno-13-2" href="#__codelineno-13-2"></a><span class="n">Episode</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">season</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">number</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">part</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"The Reckoning"</span><span class="p">)</span>
</span></code></pre></div>
<ol>
<li><code>part</code> counts from 1, contiguous. unshackle rejects <code>part=0</code>, and <code>-w</code> can only
@@ -2864,29 +2877,29 @@ has nothing to adopt.</p>
<code>Subtitle</code> tracks. In almost all cases you assemble these by parsing a manifest,
not by hand.</p>
<p>The manifest parsers live in <code>unshackle.core.manifests</code>:</p>
<div class="language-python highlight"><pre><span></span><code><span id="__span-13-1"><a id="__codelineno-13-1" name="__codelineno-13-1" href="#__codelineno-13-1"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.manifests</span><span class="w"> </span><span class="kn">import</span> <span class="n">DASH</span><span class="p">,</span> <span class="n">HLS</span><span class="p">,</span> <span class="n">ISM</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-14-1"><a id="__codelineno-14-1" name="__codelineno-14-1" href="#__codelineno-14-1"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.manifests</span><span class="w"> </span><span class="kn">import</span> <span class="n">DASH</span><span class="p">,</span> <span class="n">HLS</span><span class="p">,</span> <span class="n">ISM</span>
</span></code></pre></div>
<p>Each exposes <code>from_url(url, session=...)</code> (or <code>from_text(text, url)</code>) and then
<code>.to_tracks(language=...)</code>:</p>
<div class="tabbed-set tabbed-alternate" data-tabs="2:3"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><input id="__tabbed_2_3" name="__tabbed_2" type="radio" /><div class="tabbed-labels"><label for="__tabbed_2_1">DASH (.mpd)</label><label for="__tabbed_2_2">HLS (.m3u8)</label><label for="__tabbed_2_3">ISM (Smooth Streaming)</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-python highlight"><pre><span></span><code><span id="__span-14-1"><a id="__codelineno-14-1" name="__codelineno-14-1" href="#__codelineno-14-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-14-2"><a id="__codelineno-14-2" name="__codelineno-14-2" href="#__codelineno-14-2"></a> <span class="k">return</span> <span class="n">DASH</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span><span class="n">manifest_url</span><span class="p">,</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="p">)</span> \
</span><span id="__span-14-3"><a id="__codelineno-14-3" name="__codelineno-14-3" href="#__codelineno-14-3"></a> <span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-15-1"><a id="__codelineno-15-1" name="__codelineno-15-1" href="#__codelineno-15-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-15-2"><a id="__codelineno-15-2" name="__codelineno-15-2" href="#__codelineno-15-2"></a> <span class="k">return</span> <span class="n">DASH</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span><span class="n">manifest_url</span><span class="p">,</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="p">)</span> \
</span><span id="__span-15-3"><a id="__codelineno-15-3" name="__codelineno-15-3" href="#__codelineno-15-3"></a> <span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
</span></code></pre></div>
</div>
<div class="tabbed-block">
<div class="language-python highlight"><pre><span></span><code><span id="__span-15-1"><a id="__codelineno-15-1" name="__codelineno-15-1" href="#__codelineno-15-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-15-2"><a id="__codelineno-15-2" name="__codelineno-15-2" href="#__codelineno-15-2"></a> <span class="k">return</span> <span class="n">HLS</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span><span class="n">manifest_url</span><span class="p">,</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="p">)</span> \
</span><span id="__span-15-3"><a id="__codelineno-15-3" name="__codelineno-15-3" href="#__codelineno-15-3"></a> <span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-16-1"><a id="__codelineno-16-1" name="__codelineno-16-1" href="#__codelineno-16-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-16-2"><a id="__codelineno-16-2" name="__codelineno-16-2" href="#__codelineno-16-2"></a> <span class="k">return</span> <span class="n">HLS</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span><span class="n">manifest_url</span><span class="p">,</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="p">)</span> \
</span><span id="__span-16-3"><a id="__codelineno-16-3" name="__codelineno-16-3" href="#__codelineno-16-3"></a> <span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
</span></code></pre></div>
<p>The URL must be a <strong>variant (master) playlist</strong>, not a media playlist.</p>
</div>
<div class="tabbed-block">
<div class="language-python highlight"><pre><span></span><code><span id="__span-16-1"><a id="__codelineno-16-1" name="__codelineno-16-1" href="#__codelineno-16-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-16-2"><a id="__codelineno-16-2" name="__codelineno-16-2" href="#__codelineno-16-2"></a> <span class="k">return</span> <span class="n">ISM</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span><span class="n">manifest_url</span><span class="p">,</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="p">)</span> \
</span><span id="__span-16-3"><a id="__codelineno-16-3" name="__codelineno-16-3" href="#__codelineno-16-3"></a> <span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-17-1"><a id="__codelineno-17-1" name="__codelineno-17-1" href="#__codelineno-17-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-17-2"><a id="__codelineno-17-2" name="__codelineno-17-2" href="#__codelineno-17-2"></a> <span class="k">return</span> <span class="n">ISM</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span><span class="n">manifest_url</span><span class="p">,</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="p">)</span> \
</span><span id="__span-17-3"><a id="__codelineno-17-3" name="__codelineno-17-3" href="#__codelineno-17-3"></a> <span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
</span></code></pre></div>
</div>
</div>
@@ -2904,11 +2917,11 @@ language token.</p>
provides <code>get_tracks_for_variants(title, fetch_fn)</code> to fan out over every
codec×range in the <code>TrackRequest</code>, including <code>HYBRID</code> (fetch HDR10 + DV and
merge) and <code>--best-available</code> skip-on-error handling:</p>
<div class="language-python highlight"><pre><span></span><code><span id="__span-17-1"><a id="__codelineno-17-1" name="__codelineno-17-1" href="#__codelineno-17-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-17-2"><a id="__codelineno-17-2" name="__codelineno-17-2" href="#__codelineno-17-2"></a> <span class="k">def</span><span class="w"> </span><span class="nf">fetch_variant</span><span class="p">(</span><span class="n">title</span><span class="p">,</span> <span class="n">codec</span><span class="p">,</span> <span class="n">range_</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-17-3"><a id="__codelineno-17-3" name="__codelineno-17-3" href="#__codelineno-17-3"></a> <span class="n">vcodec</span> <span class="o">=</span> <span class="s2">"H265"</span> <span class="k">if</span> <span class="n">codec</span> <span class="o">==</span> <span class="n">Video</span><span class="o">.</span><span class="n">Codec</span><span class="o">.</span><span class="n">HEVC</span> <span class="k">else</span> <span class="s2">"H264"</span>
</span><span id="__span-17-4"><a id="__codelineno-17-4" name="__codelineno-17-4" href="#__codelineno-17-4"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">fetch_dash_manifest</span><span class="p">(</span><span class="n">title</span><span class="p">,</span> <span class="n">vcodec</span><span class="o">=</span><span class="n">vcodec</span><span class="p">,</span> <span class="n">range_</span><span class="o">=</span><span class="n">range_</span><span class="p">)</span>
</span><span id="__span-17-5"><a id="__codelineno-17-5" name="__codelineno-17-5" href="#__codelineno-17-5"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_tracks_for_variants</span><span class="p">(</span><span class="n">title</span><span class="p">,</span> <span class="n">fetch_variant</span><span class="p">)</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-18-1"><a id="__codelineno-18-1" name="__codelineno-18-1" href="#__codelineno-18-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-18-2"><a id="__codelineno-18-2" name="__codelineno-18-2" href="#__codelineno-18-2"></a> <span class="k">def</span><span class="w"> </span><span class="nf">fetch_variant</span><span class="p">(</span><span class="n">title</span><span class="p">,</span> <span class="n">codec</span><span class="p">,</span> <span class="n">range_</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-18-3"><a id="__codelineno-18-3" name="__codelineno-18-3" href="#__codelineno-18-3"></a> <span class="n">vcodec</span> <span class="o">=</span> <span class="s2">"H265"</span> <span class="k">if</span> <span class="n">codec</span> <span class="o">==</span> <span class="n">Video</span><span class="o">.</span><span class="n">Codec</span><span class="o">.</span><span class="n">HEVC</span> <span class="k">else</span> <span class="s2">"H264"</span>
</span><span id="__span-18-4"><a id="__codelineno-18-4" name="__codelineno-18-4" href="#__codelineno-18-4"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">fetch_dash_manifest</span><span class="p">(</span><span class="n">title</span><span class="p">,</span> <span class="n">vcodec</span><span class="o">=</span><span class="n">vcodec</span><span class="p">,</span> <span class="n">range_</span><span class="o">=</span><span class="n">range_</span><span class="p">)</span>
</span><span id="__span-18-5"><a id="__codelineno-18-5" name="__codelineno-18-5" href="#__codelineno-18-5"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_tracks_for_variants</span><span class="p">(</span><span class="n">title</span><span class="p">,</span> <span class="n">fetch_variant</span><span class="p">)</span>
</span></code></pre></div>
<div class="admonition note">
<p class="admonition-title">What the helper merges</p>
@@ -2968,12 +2981,12 @@ sure encrypted tracks carry the correct <code>drm</code> so the core licenses th
<p>Return a <code>Chapters</code> object of 0 or more <code>Chapter</code>s. It sorts by timestamp,
numbers the chapters at mux time, and adds a <code>00:00:00.000</code> chapter if none
exists. Timestamps take <code>"HH:MM:SS[.mmm]"</code>, int milliseconds, or float seconds.</p>
<div class="language-python highlight"><pre><span></span><code><span id="__span-18-1"><a id="__codelineno-18-1" name="__codelineno-18-1" href="#__codelineno-18-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_chapters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Chapters</span><span class="p">:</span>
</span><span id="__span-18-2"><a id="__codelineno-18-2" name="__codelineno-18-2" href="#__codelineno-18-2"></a> <span class="n">chapters</span> <span class="o">=</span> <span class="p">[</span><span class="n">Chapter</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">),</span> <span class="n">timestamp</span><span class="o">=</span><span class="n">c</span><span class="p">[</span><span class="s2">"start"</span><span class="p">])</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">title</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chapters"</span><span class="p">,</span> <span class="p">[])]</span>
</span><span id="__span-18-3"><a id="__codelineno-18-3" name="__codelineno-18-3" href="#__codelineno-18-3"></a> <span class="n">unique</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Chapter</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
</span><span id="__span-18-4"><a id="__codelineno-18-4" name="__codelineno-18-4" href="#__codelineno-18-4"></a> <span class="k">for</span> <span class="n">chapter</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">chapters</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">c</span><span class="p">:</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">named</span><span class="p">):</span>
</span><span id="__span-18-5"><a id="__codelineno-18-5" name="__codelineno-18-5" href="#__codelineno-18-5"></a> <span class="n">unique</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">chapter</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="n">chapter</span><span class="p">)</span>
</span><span id="__span-18-6"><a id="__codelineno-18-6" name="__codelineno-18-6" href="#__codelineno-18-6"></a> <span class="k">return</span> <span class="n">Chapters</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">unique</span><span class="o">.</span><span class="n">values</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">c</span><span class="p">:</span> <span class="n">c</span><span class="o">.</span><span class="n">timestamp</span><span class="p">))</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-19-1"><a id="__codelineno-19-1" name="__codelineno-19-1" href="#__codelineno-19-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_chapters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Chapters</span><span class="p">:</span>
</span><span id="__span-19-2"><a id="__codelineno-19-2" name="__codelineno-19-2" href="#__codelineno-19-2"></a> <span class="n">chapters</span> <span class="o">=</span> <span class="p">[</span><span class="n">Chapter</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">),</span> <span class="n">timestamp</span><span class="o">=</span><span class="n">c</span><span class="p">[</span><span class="s2">"start"</span><span class="p">])</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">title</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chapters"</span><span class="p">,</span> <span class="p">[])]</span>
</span><span id="__span-19-3"><a id="__codelineno-19-3" name="__codelineno-19-3" href="#__codelineno-19-3"></a> <span class="n">unique</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Chapter</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
</span><span id="__span-19-4"><a id="__codelineno-19-4" name="__codelineno-19-4" href="#__codelineno-19-4"></a> <span class="k">for</span> <span class="n">chapter</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">chapters</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">c</span><span class="p">:</span> <span class="ow">not</span> <span class="n">c</span><span class="o">.</span><span class="n">named</span><span class="p">):</span>
</span><span id="__span-19-5"><a id="__codelineno-19-5" name="__codelineno-19-5" href="#__codelineno-19-5"></a> <span class="n">unique</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">chapter</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="n">chapter</span><span class="p">)</span>
</span><span id="__span-19-6"><a id="__codelineno-19-6" name="__codelineno-19-6" href="#__codelineno-19-6"></a> <span class="k">return</span> <span class="n">Chapters</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">unique</span><span class="o">.</span><span class="n">values</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">c</span><span class="p">:</span> <span class="n">c</span><span class="o">.</span><span class="n">timestamp</span><span class="p">))</span>
</span></code></pre></div>
<div class="admonition warning">
<p class="admonition-title">Sort by timestamp before you build the <code>Chapters</code></p>
@@ -3032,17 +3045,17 @@ current <code>title</code> and <code>track</code>:</p>
</tbody>
</table>
<p>A license callback can also declare optional keyword arguments. <code>get_widevine_license</code> can ask for <code>pssh</code> and <code>session_id</code>. <code>get_playready_license</code> can ask for <code>pssh_b64</code> and <code>session_id</code>. <code>session_id</code> is the open CDM session. A callback gets only the arguments that its signature declares.</p>
<div class="language-python highlight"><pre><span></span><code><span id="__span-19-1"><a id="__codelineno-19-1" name="__codelineno-19-1" href="#__codelineno-19-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_widevine_license</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">challenge</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">track</span><span class="p">):</span>
</span><span id="__span-19-2"><a id="__codelineno-19-2" name="__codelineno-19-2" href="#__codelineno-19-2"></a> <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
</span><span id="__span-19-3"><a id="__codelineno-19-3" name="__codelineno-19-3" href="#__codelineno-19-3"></a> <span class="bp">self</span><span class="o">.</span><span class="n">license_data</span><span class="p">[</span><span class="s2">"url"</span><span class="p">],</span>
</span><span id="__span-19-4"><a id="__codelineno-19-4" name="__codelineno-19-4" href="#__codelineno-19-4"></a> <span class="n">data</span><span class="o">=</span><span class="n">challenge</span><span class="p">,</span> <span class="c1"># POST the challenge as-is</span>
</span><span id="__span-19-5"><a id="__codelineno-19-5" name="__codelineno-19-5" href="#__codelineno-19-5"></a> <span class="n">headers</span><span class="o">=</span><span class="p">{</span><span class="s2">"dt-custom-data"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">license_data</span><span class="p">[</span><span class="s2">"data"</span><span class="p">]},</span>
</span><span id="__span-19-6"><a id="__codelineno-19-6" name="__codelineno-19-6" href="#__codelineno-19-6"></a> <span class="p">)</span>
</span><span id="__span-19-7"><a id="__codelineno-19-7" name="__codelineno-19-7" href="#__codelineno-19-7"></a> <span class="n">response</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
</span><span id="__span-19-8"><a id="__codelineno-19-8" name="__codelineno-19-8" href="#__codelineno-19-8"></a> <span class="k">try</span><span class="p">:</span>
</span><span id="__span-19-9"><a id="__codelineno-19-9" name="__codelineno-19-9" href="#__codelineno-19-9"></a> <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()[</span><span class="s2">"license"</span><span class="p">]</span> <span class="c1"># some services wrap it in JSON</span>
</span><span id="__span-19-10"><a id="__codelineno-19-10" name="__codelineno-19-10" href="#__codelineno-19-10"></a> <span class="k">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
</span><span id="__span-19-11"><a id="__codelineno-19-11" name="__codelineno-19-11" href="#__codelineno-19-11"></a> <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">content</span> <span class="c1"># others return raw bytes</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-20-1"><a id="__codelineno-20-1" name="__codelineno-20-1" href="#__codelineno-20-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_widevine_license</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">challenge</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">track</span><span class="p">):</span>
</span><span id="__span-20-2"><a id="__codelineno-20-2" name="__codelineno-20-2" href="#__codelineno-20-2"></a> <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
</span><span id="__span-20-3"><a id="__codelineno-20-3" name="__codelineno-20-3" href="#__codelineno-20-3"></a> <span class="bp">self</span><span class="o">.</span><span class="n">license_data</span><span class="p">[</span><span class="s2">"url"</span><span class="p">],</span>
</span><span id="__span-20-4"><a id="__codelineno-20-4" name="__codelineno-20-4" href="#__codelineno-20-4"></a> <span class="n">data</span><span class="o">=</span><span class="n">challenge</span><span class="p">,</span> <span class="c1"># POST the challenge as-is</span>
</span><span id="__span-20-5"><a id="__codelineno-20-5" name="__codelineno-20-5" href="#__codelineno-20-5"></a> <span class="n">headers</span><span class="o">=</span><span class="p">{</span><span class="s2">"dt-custom-data"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">license_data</span><span class="p">[</span><span class="s2">"data"</span><span class="p">]},</span>
</span><span id="__span-20-6"><a id="__codelineno-20-6" name="__codelineno-20-6" href="#__codelineno-20-6"></a> <span class="p">)</span>
</span><span id="__span-20-7"><a id="__codelineno-20-7" name="__codelineno-20-7" href="#__codelineno-20-7"></a> <span class="n">response</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
</span><span id="__span-20-8"><a id="__codelineno-20-8" name="__codelineno-20-8" href="#__codelineno-20-8"></a> <span class="k">try</span><span class="p">:</span>
</span><span id="__span-20-9"><a id="__codelineno-20-9" name="__codelineno-20-9" href="#__codelineno-20-9"></a> <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()[</span><span class="s2">"license"</span><span class="p">]</span> <span class="c1"># some services wrap it in JSON</span>
</span><span id="__span-20-10"><a id="__codelineno-20-10" name="__codelineno-20-10" href="#__codelineno-20-10"></a> <span class="k">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
</span><span id="__span-20-11"><a id="__codelineno-20-11" name="__codelineno-20-11" href="#__codelineno-20-11"></a> <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">content</span> <span class="c1"># others return raw bytes</span>
</span></code></pre></div>
<div class="admonition warning">
<p class="admonition-title">Return the license untouched</p>
@@ -3089,99 +3102,99 @@ flagged, banned, or downgraded.</p>
account, and when <code>search()</code> does its own setup. A <code>search()</code> that reads a token, a header
or a region from <code>authenticate()</code> fails or gives results for the wrong region.</p>
</div>
<div class="language-python highlight"><pre><span></span><code><span id="__span-20-1"><a id="__codelineno-20-1" name="__codelineno-20-1" href="#__codelineno-20-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">search</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Generator</span><span class="p">[</span><span class="n">SearchResult</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">]:</span>
</span><span id="__span-20-2"><a id="__codelineno-20-2" name="__codelineno-20-2" href="#__codelineno-20-2"></a> <span class="n">results</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"search"</span><span class="p">],</span>
</span><span id="__span-20-3"><a id="__codelineno-20-3" name="__codelineno-20-3" href="#__codelineno-20-3"></a> <span class="n">params</span><span class="o">=</span><span class="p">{</span><span class="s2">"q"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">})</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-20-4"><a id="__codelineno-20-4" name="__codelineno-20-4" href="#__codelineno-20-4"></a> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">results</span><span class="p">[</span><span class="s2">"entries"</span><span class="p">]:</span>
</span><span id="__span-20-5"><a id="__codelineno-20-5" name="__codelineno-20-5" href="#__codelineno-20-5"></a> <span class="k">yield</span> <span class="n">SearchResult</span><span class="p">(</span><span class="n">id_</span><span class="o">=</span><span class="n">r</span><span class="p">[</span><span class="s2">"id"</span><span class="p">],</span> <span class="n">title</span><span class="o">=</span><span class="n">r</span><span class="p">[</span><span class="s2">"title"</span><span class="p">],</span>
</span><span id="__span-20-6"><a id="__codelineno-20-6" name="__codelineno-20-6" href="#__codelineno-20-6"></a> <span class="n">description</span><span class="o">=</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"description"</span><span class="p">),</span> <span class="n">url</span><span class="o">=</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"url"</span><span class="p">))</span>
<div class="language-python highlight"><pre><span></span><code><span id="__span-21-1"><a id="__codelineno-21-1" name="__codelineno-21-1" href="#__codelineno-21-1"></a><span class="k">def</span><span class="w"> </span><span class="nf">search</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Generator</span><span class="p">[</span><span class="n">SearchResult</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">]:</span>
</span><span id="__span-21-2"><a id="__codelineno-21-2" name="__codelineno-21-2" href="#__codelineno-21-2"></a> <span class="n">results</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"search"</span><span class="p">],</span>
</span><span id="__span-21-3"><a id="__codelineno-21-3" name="__codelineno-21-3" href="#__codelineno-21-3"></a> <span class="n">params</span><span class="o">=</span><span class="p">{</span><span class="s2">"q"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">})</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-21-4"><a id="__codelineno-21-4" name="__codelineno-21-4" href="#__codelineno-21-4"></a> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">results</span><span class="p">[</span><span class="s2">"entries"</span><span class="p">]:</span>
</span><span id="__span-21-5"><a id="__codelineno-21-5" name="__codelineno-21-5" href="#__codelineno-21-5"></a> <span class="k">yield</span> <span class="n">SearchResult</span><span class="p">(</span><span class="n">id_</span><span class="o">=</span><span class="n">r</span><span class="p">[</span><span class="s2">"id"</span><span class="p">],</span> <span class="n">title</span><span class="o">=</span><span class="n">r</span><span class="p">[</span><span class="s2">"title"</span><span class="p">],</span>
</span><span id="__span-21-6"><a id="__codelineno-21-6" name="__codelineno-21-6" href="#__codelineno-21-6"></a> <span class="n">description</span><span class="o">=</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"description"</span><span class="p">),</span> <span class="n">url</span><span class="o">=</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"url"</span><span class="p">))</span>
</span></code></pre></div>
<hr />
<h2 id="minimal-service-skeleton">Minimal service skeleton<a class="headerlink" href="#minimal-service-skeleton" title="Permanent link">&para;</a></h2>
<p>A complete, minimal single-manifest service. Save as
<code>services/MYSVC/__init__.py</code> (class name <code>MYSVC</code>), with an optional
<code>services/MYSVC/config.yaml</code> beside it.</p>
<div class="language-python highlight"><span class="filename">services/MYSVC/__init__.py</span><pre><span></span><code><span id="__span-21-1"><a id="__codelineno-21-1" name="__codelineno-21-1" href="#__codelineno-21-1"></a><span class="kn">from</span><span class="w"> </span><span class="nn">__future__</span><span class="w"> </span><span class="kn">import</span> <span class="n">annotations</span>
</span><span id="__span-21-2"><a id="__codelineno-21-2" name="__codelineno-21-2" href="#__codelineno-21-2"></a>
</span><span id="__span-21-3"><a id="__codelineno-21-3" name="__codelineno-21-3" href="#__codelineno-21-3"></a><span class="kn">import</span><span class="w"> </span><span class="nn">re</span>
</span><span id="__span-21-4"><a id="__codelineno-21-4" name="__codelineno-21-4" href="#__codelineno-21-4"></a><span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">Optional</span>
</span><span id="__span-21-5"><a id="__codelineno-21-5" name="__codelineno-21-5" href="#__codelineno-21-5"></a>
</span><span id="__span-21-6"><a id="__codelineno-21-6" name="__codelineno-21-6" href="#__codelineno-21-6"></a><span class="kn">import</span><span class="w"> </span><span class="nn">click</span>
</span><span id="__span-21-7"><a id="__codelineno-21-7" name="__codelineno-21-7" href="#__codelineno-21-7"></a>
</span><span id="__span-21-8"><a id="__codelineno-21-8" name="__codelineno-21-8" href="#__codelineno-21-8"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.manifests</span><span class="w"> </span><span class="kn">import</span> <span class="n">DASH</span>
</span><span id="__span-21-9"><a id="__codelineno-21-9" name="__codelineno-21-9" href="#__codelineno-21-9"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.service</span><span class="w"> </span><span class="kn">import</span> <span class="n">Service</span>
</span><span id="__span-21-10"><a id="__codelineno-21-10" name="__codelineno-21-10" href="#__codelineno-21-10"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.titles</span><span class="w"> </span><span class="kn">import</span> <span class="n">Movie</span><span class="p">,</span> <span class="n">Movies</span><span class="p">,</span> <span class="n">Title_T</span><span class="p">,</span> <span class="n">Titles_T</span>
</span><span id="__span-21-11"><a id="__codelineno-21-11" name="__codelineno-21-11" href="#__codelineno-21-11"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.tracks</span><span class="w"> </span><span class="kn">import</span> <span class="n">Chapters</span><span class="p">,</span> <span class="n">Tracks</span>
</span><span id="__span-21-12"><a id="__codelineno-21-12" name="__codelineno-21-12" href="#__codelineno-21-12"></a>
</span><span id="__span-21-13"><a id="__codelineno-21-13" name="__codelineno-21-13" href="#__codelineno-21-13"></a>
</span><span id="__span-21-14"><a id="__codelineno-21-14" name="__codelineno-21-14" href="#__codelineno-21-14"></a><span class="k">class</span><span class="w"> </span><span class="nc">MYSVC</span><span class="p">(</span><span class="n">Service</span><span class="p">):</span>
</span><span id="__span-21-15"><a id="__codelineno-21-15" name="__codelineno-21-15" href="#__codelineno-21-15"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="__span-21-16"><a id="__codelineno-21-16" name="__codelineno-21-16" href="#__codelineno-21-16"></a><span class="sd"> MyService - https://myservice.com</span>
</span><span id="__span-21-17"><a id="__codelineno-21-17" name="__codelineno-21-17" href="#__codelineno-21-17"></a>
</span><span id="__span-21-18"><a id="__codelineno-21-18" name="__codelineno-21-18" href="#__codelineno-21-18"></a><span class="sd"> \b</span>
</span><span id="__span-21-19"><a id="__codelineno-21-19" name="__codelineno-21-19" href="#__codelineno-21-19"></a><span class="sd"> Usage: unshackle dl MYSVC &lt;title-id-or-url&gt;</span>
</span><span id="__span-21-20"><a id="__codelineno-21-20" name="__codelineno-21-20" href="#__codelineno-21-20"></a><span class="sd"> """</span>
</span><span id="__span-21-21"><a id="__codelineno-21-21" name="__codelineno-21-21" href="#__codelineno-21-21"></a>
</span><span id="__span-21-22"><a id="__codelineno-21-22" name="__codelineno-21-22" href="#__codelineno-21-22"></a> <span class="n">ALIASES</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"MY"</span><span class="p">,)</span>
</span><span id="__span-21-23"><a id="__codelineno-21-23" name="__codelineno-21-23" href="#__codelineno-21-23"></a> <span class="n">GEOFENCE</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"US"</span><span class="p">,)</span>
</span><span id="__span-21-24"><a id="__codelineno-21-24" name="__codelineno-21-24" href="#__codelineno-21-24"></a> <span class="n">TITLE_RE</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">"^(?:https?://myservice\.com/watch/)?(?P&lt;id&gt;[\w-]+)"</span>
</span><span id="__span-21-25"><a id="__codelineno-21-25" name="__codelineno-21-25" href="#__codelineno-21-25"></a>
</span><span id="__span-21-26"><a id="__codelineno-21-26" name="__codelineno-21-26" href="#__codelineno-21-26"></a> <span class="nd">@staticmethod</span>
</span><span id="__span-21-27"><a id="__codelineno-21-27" name="__codelineno-21-27" href="#__codelineno-21-27"></a> <span class="nd">@click</span><span class="o">.</span><span class="n">command</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"MYSVC"</span><span class="p">,</span> <span class="n">short_help</span><span class="o">=</span><span class="s2">"https://myservice.com"</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="vm">__doc__</span><span class="p">)</span>
</span><span id="__span-21-28"><a id="__codelineno-21-28" name="__codelineno-21-28" href="#__codelineno-21-28"></a> <span class="nd">@click</span><span class="o">.</span><span class="n">argument</span><span class="p">(</span><span class="s2">"title"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">)</span>
</span><span id="__span-21-29"><a id="__codelineno-21-29" name="__codelineno-21-29" href="#__codelineno-21-29"></a> <span class="nd">@click</span><span class="o">.</span><span class="n">pass_context</span>
</span><span id="__span-21-30"><a id="__codelineno-21-30" name="__codelineno-21-30" href="#__codelineno-21-30"></a> <span class="k">def</span><span class="w"> </span><span class="nf">cli</span><span class="p">(</span><span class="n">ctx</span><span class="p">:</span> <span class="n">click</span><span class="o">.</span><span class="n">Context</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">"MYSVC"</span><span class="p">:</span>
</span><span id="__span-21-31"><a id="__codelineno-21-31" name="__codelineno-21-31" href="#__codelineno-21-31"></a> <span class="k">return</span> <span class="n">MYSVC</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</span><span id="__span-21-32"><a id="__codelineno-21-32" name="__codelineno-21-32" href="#__codelineno-21-32"></a>
</span><span id="__span-21-33"><a id="__codelineno-21-33" name="__codelineno-21-33" href="#__codelineno-21-33"></a> <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">:</span> <span class="n">click</span><span class="o">.</span><span class="n">Context</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
</span><span id="__span-21-34"><a id="__codelineno-21-34" name="__codelineno-21-34" href="#__codelineno-21-34"></a> <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">title</span>
</span><span id="__span-21-35"><a id="__codelineno-21-35" name="__codelineno-21-35" href="#__codelineno-21-35"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span>
</span><span id="__span-21-36"><a id="__codelineno-21-36" name="__codelineno-21-36" href="#__codelineno-21-36"></a>
</span><span id="__span-21-37"><a id="__codelineno-21-37" name="__codelineno-21-37" href="#__codelineno-21-37"></a> <span class="k">def</span><span class="w"> </span><span class="nf">authenticate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cookies</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">credential</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="__span-21-38"><a id="__codelineno-21-38" name="__codelineno-21-38" href="#__codelineno-21-38"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">authenticate</span><span class="p">(</span><span class="n">cookies</span><span class="p">,</span> <span class="n">credential</span><span class="p">)</span>
</span><span id="__span-21-39"><a id="__codelineno-21-39" name="__codelineno-21-39" href="#__codelineno-21-39"></a> <span class="c1"># obtain any tokens here, e.g. self.token = ...</span>
</span><span id="__span-21-40"><a id="__codelineno-21-40" name="__codelineno-21-40" href="#__codelineno-21-40"></a>
</span><span id="__span-21-41"><a id="__codelineno-21-41" name="__codelineno-21-41" href="#__codelineno-21-41"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_titles</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="__span-21-42"><a id="__codelineno-21-42" name="__codelineno-21-42" href="#__codelineno-21-42"></a> <span class="n">match</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TITLE_RE</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</span><span id="__span-21-43"><a id="__codelineno-21-43" name="__codelineno-21-43" href="#__codelineno-21-43"></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">match</span><span class="p">:</span>
</span><span id="__span-21-44"><a id="__codelineno-21-44" name="__codelineno-21-44" href="#__codelineno-21-44"></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Could not parse a title ID."</span><span class="p">)</span>
</span><span id="__span-21-45"><a id="__codelineno-21-45" name="__codelineno-21-45" href="#__codelineno-21-45"></a> <span class="n">meta</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
</span><span id="__span-21-46"><a id="__codelineno-21-46" name="__codelineno-21-46" href="#__codelineno-21-46"></a> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="s2">"id"</span><span class="p">))</span>
</span><span id="__span-21-47"><a id="__codelineno-21-47" name="__codelineno-21-47" href="#__codelineno-21-47"></a> <span class="p">)</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-21-48"><a id="__codelineno-21-48" name="__codelineno-21-48" href="#__codelineno-21-48"></a> <span class="k">return</span> <span class="n">Movies</span><span class="p">([</span>
</span><span id="__span-21-49"><a id="__codelineno-21-49" name="__codelineno-21-49" href="#__codelineno-21-49"></a> <span class="n">Movie</span><span class="p">(</span>
</span><span id="__span-21-50"><a id="__codelineno-21-50" name="__codelineno-21-50" href="#__codelineno-21-50"></a> <span class="n">id_</span><span class="o">=</span><span class="n">meta</span><span class="p">[</span><span class="s2">"id"</span><span class="p">],</span>
</span><span id="__span-21-51"><a id="__codelineno-21-51" name="__codelineno-21-51" href="#__codelineno-21-51"></a> <span class="n">service</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span>
</span><span id="__span-21-52"><a id="__codelineno-21-52" name="__codelineno-21-52" href="#__codelineno-21-52"></a> <span class="n">name</span><span class="o">=</span><span class="n">meta</span><span class="p">[</span><span class="s2">"title"</span><span class="p">],</span>
</span><span id="__span-21-53"><a id="__codelineno-21-53" name="__codelineno-21-53" href="#__codelineno-21-53"></a> <span class="n">year</span><span class="o">=</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"year"</span><span class="p">)</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">,</span>
</span><span id="__span-21-54"><a id="__codelineno-21-54" name="__codelineno-21-54" href="#__codelineno-21-54"></a> <span class="n">language</span><span class="o">=</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"originalLanguage"</span><span class="p">),</span>
</span><span id="__span-21-55"><a id="__codelineno-21-55" name="__codelineno-21-55" href="#__codelineno-21-55"></a> <span class="n">data</span><span class="o">=</span><span class="n">meta</span><span class="p">,</span>
</span><span id="__span-21-56"><a id="__codelineno-21-56" name="__codelineno-21-56" href="#__codelineno-21-56"></a> <span class="p">)</span>
</span><span id="__span-21-57"><a id="__codelineno-21-57" name="__codelineno-21-57" href="#__codelineno-21-57"></a> <span class="p">])</span>
</span><span id="__span-21-58"><a id="__codelineno-21-58" name="__codelineno-21-58" href="#__codelineno-21-58"></a>
</span><span id="__span-21-59"><a id="__codelineno-21-59" name="__codelineno-21-59" href="#__codelineno-21-59"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-21-60"><a id="__codelineno-21-60" name="__codelineno-21-60" href="#__codelineno-21-60"></a> <span class="n">playback</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
</span><span id="__span-21-61"><a id="__codelineno-21-61" name="__codelineno-21-61" href="#__codelineno-21-61"></a> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"playback"</span><span class="p">]</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">id</span><span class="p">)</span>
</span><span id="__span-21-62"><a id="__codelineno-21-62" name="__codelineno-21-62" href="#__codelineno-21-62"></a> <span class="p">)</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-21-63"><a id="__codelineno-21-63" name="__codelineno-21-63" href="#__codelineno-21-63"></a> <span class="k">return</span> <span class="n">DASH</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span>
</span><span id="__span-21-64"><a id="__codelineno-21-64" name="__codelineno-21-64" href="#__codelineno-21-64"></a> <span class="n">url</span><span class="o">=</span><span class="n">playback</span><span class="p">[</span><span class="s2">"manifest_url"</span><span class="p">],</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span>
</span><span id="__span-21-65"><a id="__codelineno-21-65" name="__codelineno-21-65" href="#__codelineno-21-65"></a> <span class="p">)</span><span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
</span><span id="__span-21-66"><a id="__codelineno-21-66" name="__codelineno-21-66" href="#__codelineno-21-66"></a>
</span><span id="__span-21-67"><a id="__codelineno-21-67" name="__codelineno-21-67" href="#__codelineno-21-67"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_chapters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Chapters</span><span class="p">:</span>
</span><span id="__span-21-68"><a id="__codelineno-21-68" name="__codelineno-21-68" href="#__codelineno-21-68"></a> <span class="k">return</span> <span class="n">Chapters</span><span class="p">()</span>
</span><span id="__span-21-69"><a id="__codelineno-21-69" name="__codelineno-21-69" href="#__codelineno-21-69"></a>
</span><span id="__span-21-70"><a id="__codelineno-21-70" name="__codelineno-21-70" href="#__codelineno-21-70"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_widevine_license</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">challenge</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">track</span><span class="p">):</span>
</span><span id="__span-21-71"><a id="__codelineno-21-71" name="__codelineno-21-71" href="#__codelineno-21-71"></a> <span class="n">res</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"license"</span><span class="p">],</span> <span class="n">data</span><span class="o">=</span><span class="n">challenge</span><span class="p">)</span>
</span><span id="__span-21-72"><a id="__codelineno-21-72" name="__codelineno-21-72" href="#__codelineno-21-72"></a> <span class="n">res</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
</span><span id="__span-21-73"><a id="__codelineno-21-73" name="__codelineno-21-73" href="#__codelineno-21-73"></a> <span class="k">return</span> <span class="n">res</span><span class="o">.</span><span class="n">content</span>
<div class="language-python highlight"><span class="filename">services/MYSVC/__init__.py</span><pre><span></span><code><span id="__span-22-1"><a id="__codelineno-22-1" name="__codelineno-22-1" href="#__codelineno-22-1"></a><span class="kn">from</span><span class="w"> </span><span class="nn">__future__</span><span class="w"> </span><span class="kn">import</span> <span class="n">annotations</span>
</span><span id="__span-22-2"><a id="__codelineno-22-2" name="__codelineno-22-2" href="#__codelineno-22-2"></a>
</span><span id="__span-22-3"><a id="__codelineno-22-3" name="__codelineno-22-3" href="#__codelineno-22-3"></a><span class="kn">import</span><span class="w"> </span><span class="nn">re</span>
</span><span id="__span-22-4"><a id="__codelineno-22-4" name="__codelineno-22-4" href="#__codelineno-22-4"></a><span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">Optional</span>
</span><span id="__span-22-5"><a id="__codelineno-22-5" name="__codelineno-22-5" href="#__codelineno-22-5"></a>
</span><span id="__span-22-6"><a id="__codelineno-22-6" name="__codelineno-22-6" href="#__codelineno-22-6"></a><span class="kn">import</span><span class="w"> </span><span class="nn">click</span>
</span><span id="__span-22-7"><a id="__codelineno-22-7" name="__codelineno-22-7" href="#__codelineno-22-7"></a>
</span><span id="__span-22-8"><a id="__codelineno-22-8" name="__codelineno-22-8" href="#__codelineno-22-8"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.manifests</span><span class="w"> </span><span class="kn">import</span> <span class="n">DASH</span>
</span><span id="__span-22-9"><a id="__codelineno-22-9" name="__codelineno-22-9" href="#__codelineno-22-9"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.service</span><span class="w"> </span><span class="kn">import</span> <span class="n">Service</span>
</span><span id="__span-22-10"><a id="__codelineno-22-10" name="__codelineno-22-10" href="#__codelineno-22-10"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.titles</span><span class="w"> </span><span class="kn">import</span> <span class="n">Movie</span><span class="p">,</span> <span class="n">Movies</span><span class="p">,</span> <span class="n">Title_T</span><span class="p">,</span> <span class="n">Titles_T</span>
</span><span id="__span-22-11"><a id="__codelineno-22-11" name="__codelineno-22-11" href="#__codelineno-22-11"></a><span class="kn">from</span><span class="w"> </span><span class="nn">unshackle.core.tracks</span><span class="w"> </span><span class="kn">import</span> <span class="n">Chapters</span><span class="p">,</span> <span class="n">Tracks</span>
</span><span id="__span-22-12"><a id="__codelineno-22-12" name="__codelineno-22-12" href="#__codelineno-22-12"></a>
</span><span id="__span-22-13"><a id="__codelineno-22-13" name="__codelineno-22-13" href="#__codelineno-22-13"></a>
</span><span id="__span-22-14"><a id="__codelineno-22-14" name="__codelineno-22-14" href="#__codelineno-22-14"></a><span class="k">class</span><span class="w"> </span><span class="nc">MYSVC</span><span class="p">(</span><span class="n">Service</span><span class="p">):</span>
</span><span id="__span-22-15"><a id="__codelineno-22-15" name="__codelineno-22-15" href="#__codelineno-22-15"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="__span-22-16"><a id="__codelineno-22-16" name="__codelineno-22-16" href="#__codelineno-22-16"></a><span class="sd"> MyService - https://myservice.com</span>
</span><span id="__span-22-17"><a id="__codelineno-22-17" name="__codelineno-22-17" href="#__codelineno-22-17"></a>
</span><span id="__span-22-18"><a id="__codelineno-22-18" name="__codelineno-22-18" href="#__codelineno-22-18"></a><span class="sd"> \b</span>
</span><span id="__span-22-19"><a id="__codelineno-22-19" name="__codelineno-22-19" href="#__codelineno-22-19"></a><span class="sd"> Usage: unshackle dl MYSVC &lt;title-id-or-url&gt;</span>
</span><span id="__span-22-20"><a id="__codelineno-22-20" name="__codelineno-22-20" href="#__codelineno-22-20"></a><span class="sd"> """</span>
</span><span id="__span-22-21"><a id="__codelineno-22-21" name="__codelineno-22-21" href="#__codelineno-22-21"></a>
</span><span id="__span-22-22"><a id="__codelineno-22-22" name="__codelineno-22-22" href="#__codelineno-22-22"></a> <span class="n">ALIASES</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"MY"</span><span class="p">,)</span>
</span><span id="__span-22-23"><a id="__codelineno-22-23" name="__codelineno-22-23" href="#__codelineno-22-23"></a> <span class="n">GEOFENCE</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"US"</span><span class="p">,)</span>
</span><span id="__span-22-24"><a id="__codelineno-22-24" name="__codelineno-22-24" href="#__codelineno-22-24"></a> <span class="n">TITLE_RE</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">"^(?:https?://myservice\.com/watch/)?(?P&lt;id&gt;[\w-]+)"</span>
</span><span id="__span-22-25"><a id="__codelineno-22-25" name="__codelineno-22-25" href="#__codelineno-22-25"></a>
</span><span id="__span-22-26"><a id="__codelineno-22-26" name="__codelineno-22-26" href="#__codelineno-22-26"></a> <span class="nd">@staticmethod</span>
</span><span id="__span-22-27"><a id="__codelineno-22-27" name="__codelineno-22-27" href="#__codelineno-22-27"></a> <span class="nd">@click</span><span class="o">.</span><span class="n">command</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"MYSVC"</span><span class="p">,</span> <span class="n">short_help</span><span class="o">=</span><span class="s2">"https://myservice.com"</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="vm">__doc__</span><span class="p">)</span>
</span><span id="__span-22-28"><a id="__codelineno-22-28" name="__codelineno-22-28" href="#__codelineno-22-28"></a> <span class="nd">@click</span><span class="o">.</span><span class="n">argument</span><span class="p">(</span><span class="s2">"title"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">)</span>
</span><span id="__span-22-29"><a id="__codelineno-22-29" name="__codelineno-22-29" href="#__codelineno-22-29"></a> <span class="nd">@click</span><span class="o">.</span><span class="n">pass_context</span>
</span><span id="__span-22-30"><a id="__codelineno-22-30" name="__codelineno-22-30" href="#__codelineno-22-30"></a> <span class="k">def</span><span class="w"> </span><span class="nf">cli</span><span class="p">(</span><span class="n">ctx</span><span class="p">:</span> <span class="n">click</span><span class="o">.</span><span class="n">Context</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="s2">"MYSVC"</span><span class="p">:</span>
</span><span id="__span-22-31"><a id="__codelineno-22-31" name="__codelineno-22-31" href="#__codelineno-22-31"></a> <span class="k">return</span> <span class="n">MYSVC</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</span><span id="__span-22-32"><a id="__codelineno-22-32" name="__codelineno-22-32" href="#__codelineno-22-32"></a>
</span><span id="__span-22-33"><a id="__codelineno-22-33" name="__codelineno-22-33" href="#__codelineno-22-33"></a> <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">:</span> <span class="n">click</span><span class="o">.</span><span class="n">Context</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
</span><span id="__span-22-34"><a id="__codelineno-22-34" name="__codelineno-22-34" href="#__codelineno-22-34"></a> <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">title</span>
</span><span id="__span-22-35"><a id="__codelineno-22-35" name="__codelineno-22-35" href="#__codelineno-22-35"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span>
</span><span id="__span-22-36"><a id="__codelineno-22-36" name="__codelineno-22-36" href="#__codelineno-22-36"></a>
</span><span id="__span-22-37"><a id="__codelineno-22-37" name="__codelineno-22-37" href="#__codelineno-22-37"></a> <span class="k">def</span><span class="w"> </span><span class="nf">authenticate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cookies</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">credential</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="__span-22-38"><a id="__codelineno-22-38" name="__codelineno-22-38" href="#__codelineno-22-38"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">authenticate</span><span class="p">(</span><span class="n">cookies</span><span class="p">,</span> <span class="n">credential</span><span class="p">)</span>
</span><span id="__span-22-39"><a id="__codelineno-22-39" name="__codelineno-22-39" href="#__codelineno-22-39"></a> <span class="c1"># obtain any tokens here, e.g. self.token = ...</span>
</span><span id="__span-22-40"><a id="__codelineno-22-40" name="__codelineno-22-40" href="#__codelineno-22-40"></a>
</span><span id="__span-22-41"><a id="__codelineno-22-41" name="__codelineno-22-41" href="#__codelineno-22-41"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_titles</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="__span-22-42"><a id="__codelineno-22-42" name="__codelineno-22-42" href="#__codelineno-22-42"></a> <span class="n">match</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TITLE_RE</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</span><span id="__span-22-43"><a id="__codelineno-22-43" name="__codelineno-22-43" href="#__codelineno-22-43"></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">match</span><span class="p">:</span>
</span><span id="__span-22-44"><a id="__codelineno-22-44" name="__codelineno-22-44" href="#__codelineno-22-44"></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Could not parse a title ID."</span><span class="p">)</span>
</span><span id="__span-22-45"><a id="__codelineno-22-45" name="__codelineno-22-45" href="#__codelineno-22-45"></a> <span class="n">meta</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
</span><span id="__span-22-46"><a id="__codelineno-22-46" name="__codelineno-22-46" href="#__codelineno-22-46"></a> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"metadata"</span><span class="p">]</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="s2">"id"</span><span class="p">))</span>
</span><span id="__span-22-47"><a id="__codelineno-22-47" name="__codelineno-22-47" href="#__codelineno-22-47"></a> <span class="p">)</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-22-48"><a id="__codelineno-22-48" name="__codelineno-22-48" href="#__codelineno-22-48"></a> <span class="k">return</span> <span class="n">Movies</span><span class="p">([</span>
</span><span id="__span-22-49"><a id="__codelineno-22-49" name="__codelineno-22-49" href="#__codelineno-22-49"></a> <span class="n">Movie</span><span class="p">(</span>
</span><span id="__span-22-50"><a id="__codelineno-22-50" name="__codelineno-22-50" href="#__codelineno-22-50"></a> <span class="n">id_</span><span class="o">=</span><span class="n">meta</span><span class="p">[</span><span class="s2">"id"</span><span class="p">],</span>
</span><span id="__span-22-51"><a id="__codelineno-22-51" name="__codelineno-22-51" href="#__codelineno-22-51"></a> <span class="n">service</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span>
</span><span id="__span-22-52"><a id="__codelineno-22-52" name="__codelineno-22-52" href="#__codelineno-22-52"></a> <span class="n">name</span><span class="o">=</span><span class="n">meta</span><span class="p">[</span><span class="s2">"title"</span><span class="p">],</span>
</span><span id="__span-22-53"><a id="__codelineno-22-53" name="__codelineno-22-53" href="#__codelineno-22-53"></a> <span class="n">year</span><span class="o">=</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"year"</span><span class="p">)</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">,</span>
</span><span id="__span-22-54"><a id="__codelineno-22-54" name="__codelineno-22-54" href="#__codelineno-22-54"></a> <span class="n">language</span><span class="o">=</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"originalLanguage"</span><span class="p">),</span>
</span><span id="__span-22-55"><a id="__codelineno-22-55" name="__codelineno-22-55" href="#__codelineno-22-55"></a> <span class="n">data</span><span class="o">=</span><span class="n">meta</span><span class="p">,</span>
</span><span id="__span-22-56"><a id="__codelineno-22-56" name="__codelineno-22-56" href="#__codelineno-22-56"></a> <span class="p">)</span>
</span><span id="__span-22-57"><a id="__codelineno-22-57" name="__codelineno-22-57" href="#__codelineno-22-57"></a> <span class="p">])</span>
</span><span id="__span-22-58"><a id="__codelineno-22-58" name="__codelineno-22-58" href="#__codelineno-22-58"></a>
</span><span id="__span-22-59"><a id="__codelineno-22-59" name="__codelineno-22-59" href="#__codelineno-22-59"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="__span-22-60"><a id="__codelineno-22-60" name="__codelineno-22-60" href="#__codelineno-22-60"></a> <span class="n">playback</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
</span><span id="__span-22-61"><a id="__codelineno-22-61" name="__codelineno-22-61" href="#__codelineno-22-61"></a> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"playback"</span><span class="p">]</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">id</span><span class="p">)</span>
</span><span id="__span-22-62"><a id="__codelineno-22-62" name="__codelineno-22-62" href="#__codelineno-22-62"></a> <span class="p">)</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
</span><span id="__span-22-63"><a id="__codelineno-22-63" name="__codelineno-22-63" href="#__codelineno-22-63"></a> <span class="k">return</span> <span class="n">DASH</span><span class="o">.</span><span class="n">from_url</span><span class="p">(</span>
</span><span id="__span-22-64"><a id="__codelineno-22-64" name="__codelineno-22-64" href="#__codelineno-22-64"></a> <span class="n">url</span><span class="o">=</span><span class="n">playback</span><span class="p">[</span><span class="s2">"manifest_url"</span><span class="p">],</span> <span class="n">session</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">session</span>
</span><span id="__span-22-65"><a id="__codelineno-22-65" name="__codelineno-22-65" href="#__codelineno-22-65"></a> <span class="p">)</span><span class="o">.</span><span class="n">to_tracks</span><span class="p">(</span><span class="n">language</span><span class="o">=</span><span class="n">title</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
</span><span id="__span-22-66"><a id="__codelineno-22-66" name="__codelineno-22-66" href="#__codelineno-22-66"></a>
</span><span id="__span-22-67"><a id="__codelineno-22-67" name="__codelineno-22-67" href="#__codelineno-22-67"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_chapters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Chapters</span><span class="p">:</span>
</span><span id="__span-22-68"><a id="__codelineno-22-68" name="__codelineno-22-68" href="#__codelineno-22-68"></a> <span class="k">return</span> <span class="n">Chapters</span><span class="p">()</span>
</span><span id="__span-22-69"><a id="__codelineno-22-69" name="__codelineno-22-69" href="#__codelineno-22-69"></a>
</span><span id="__span-22-70"><a id="__codelineno-22-70" name="__codelineno-22-70" href="#__codelineno-22-70"></a> <span class="k">def</span><span class="w"> </span><span class="nf">get_widevine_license</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">challenge</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">track</span><span class="p">):</span>
</span><span id="__span-22-71"><a id="__codelineno-22-71" name="__codelineno-22-71" href="#__codelineno-22-71"></a> <span class="n">res</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">session</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">"endpoints"</span><span class="p">][</span><span class="s2">"license"</span><span class="p">],</span> <span class="n">data</span><span class="o">=</span><span class="n">challenge</span><span class="p">)</span>
</span><span id="__span-22-72"><a id="__codelineno-22-72" name="__codelineno-22-72" href="#__codelineno-22-72"></a> <span class="n">res</span><span class="o">.</span><span class="n">raise_for_status</span><span class="p">()</span>
</span><span id="__span-22-73"><a id="__codelineno-22-73" name="__codelineno-22-73" href="#__codelineno-22-73"></a> <span class="k">return</span> <span class="n">res</span><span class="o">.</span><span class="n">content</span>
</span></code></pre></div>
<div class="language-yaml highlight"><span class="filename">services/MYSVC/config.yaml</span><pre><span></span><code><span id="__span-22-1"><a id="__codelineno-22-1" name="__codelineno-22-1" href="#__codelineno-22-1"></a><span class="nt">endpoints</span><span class="p">:</span>
</span><span id="__span-22-2"><a id="__codelineno-22-2" name="__codelineno-22-2" href="#__codelineno-22-2"></a><span class="w"> </span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://api.myservice.com/v1/metadata/{id}</span>
</span><span id="__span-22-3"><a id="__codelineno-22-3" name="__codelineno-22-3" href="#__codelineno-22-3"></a><span class="w"> </span><span class="nt">playback</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://api.myservice.com/v1/playback/{id}</span>
</span><span id="__span-22-4"><a id="__codelineno-22-4" name="__codelineno-22-4" href="#__codelineno-22-4"></a><span class="w"> </span><span class="nt">license</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://api.myservice.com/v1/license/widevine</span>
<div class="language-yaml highlight"><span class="filename">services/MYSVC/config.yaml</span><pre><span></span><code><span id="__span-23-1"><a id="__codelineno-23-1" name="__codelineno-23-1" href="#__codelineno-23-1"></a><span class="nt">endpoints</span><span class="p">:</span>
</span><span id="__span-23-2"><a id="__codelineno-23-2" name="__codelineno-23-2" href="#__codelineno-23-2"></a><span class="w"> </span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://api.myservice.com/v1/metadata/{id}</span>
</span><span id="__span-23-3"><a id="__codelineno-23-3" name="__codelineno-23-3" href="#__codelineno-23-3"></a><span class="w"> </span><span class="nt">playback</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://api.myservice.com/v1/playback/{id}</span>
</span><span id="__span-23-4"><a id="__codelineno-23-4" name="__codelineno-23-4" href="#__codelineno-23-4"></a><span class="w"> </span><span class="nt">license</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://api.myservice.com/v1/license/widevine</span>
</span></code></pre></div>
<p>Try it with:</p>
<div class="language-bash highlight"><pre><span></span><code><span id="__span-23-1"><a id="__codelineno-23-1" name="__codelineno-23-1" href="#__codelineno-23-1"></a>unshackle<span class="w"> </span>dl<span class="w"> </span>MYSVC<span class="w"> </span>https://myservice.com/watch/abc123
<div class="language-bash highlight"><pre><span></span><code><span id="__span-24-1"><a id="__codelineno-24-1" name="__codelineno-24-1" href="#__codelineno-24-1"></a>unshackle<span class="w"> </span>dl<span class="w"> </span>MYSVC<span class="w"> </span>https://myservice.com/watch/abc123
</span></code></pre></div>
<hr />
<h2 id="checklist">Checklist<a class="headerlink" href="#checklist" title="Permanent link">&para;</a></h2>
+8 -6
View File
@@ -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=&lt;name&gt;</code> lists that server's services, each with <code>remote</code> set to the name. Add <code>"remote": "&lt;name&gt;"</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 (&lt;client_name&gt;)</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>, 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=&lt;name&gt;</code> lists that server's services, each with <code>remote</code> set to the name. Add <code>"remote": "&lt;name&gt;"</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 (&lt;client_name&gt;)</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>
@@ -4364,10 +4364,11 @@ an HTTP caller would be remote code execution. You configure post-scripts only i
</span><span id="__span-14-20"><a id="__codelineno-14-20" name="__codelineno-14-20" href="#__codelineno-14-20"></a><span class="w"> </span><span class="nt">"skipped_subtitles"</span><span class="p">:</span><span class="w"> </span><span class="p">[],</span>
</span><span id="__span-14-21"><a id="__codelineno-14-21" name="__codelineno-14-21" href="#__codelineno-14-21"></a><span class="w"> </span><span class="nt">"skipped_titles"</span><span class="p">:</span><span class="w"> </span><span class="p">[],</span>
</span><span id="__span-14-22"><a id="__codelineno-14-22" name="__codelineno-14-22" href="#__codelineno-14-22"></a><span class="w"> </span><span class="nt">"input_prompt"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span>
</span><span id="__span-14-23"><a id="__codelineno-14-23" name="__codelineno-14-23" href="#__codelineno-14-23"></a><span class="w"> </span><span class="nt">"notice"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span>
</span><span id="__span-14-24"><a id="__codelineno-14-24" name="__codelineno-14-24" href="#__codelineno-14-24"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-14-25"><a id="__codelineno-14-25" name="__codelineno-14-25" href="#__codelineno-14-25"></a><span class="w"> </span><span class="p">]</span>
</span><span id="__span-14-26"><a id="__codelineno-14-26" name="__codelineno-14-26" href="#__codelineno-14-26"></a><span class="p">}</span>
</span><span id="__span-14-23"><a id="__codelineno-14-23" name="__codelineno-14-23" href="#__codelineno-14-23"></a><span class="w"> </span><span class="nt">"notice"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span>
</span><span id="__span-14-24"><a id="__codelineno-14-24" name="__codelineno-14-24" href="#__codelineno-14-24"></a><span class="w"> </span><span class="nt">"qr"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span>
</span><span id="__span-14-25"><a id="__codelineno-14-25" name="__codelineno-14-25" href="#__codelineno-14-25"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-14-26"><a id="__codelineno-14-26" name="__codelineno-14-26" href="#__codelineno-14-26"></a><span class="w"> </span><span class="p">]</span>
</span><span id="__span-14-27"><a id="__codelineno-14-27" name="__codelineno-14-27" href="#__codelineno-14-27"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
@@ -4672,7 +4673,8 @@ example an OTP code, a PIN, or a device-code confirmation. The job then shows th
answer here.</p>
<p>A job that waits for an approval on another device, such as a pair code login, shows the
message in its <code>notice</code> field instead. A notice needs no answer: show it to the user and keep
polling.</p>
polling. When the login is a QR code to scan, the job also sets <code>qr</code> to the text of the code:
draw it as a QR code beside the prompt or notice.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="13:2"><input checked="checked" id="__tabbed_13_1" name="__tabbed_13" type="radio" /><input id="__tabbed_13_2" name="__tabbed_13" type="radio" /><div class="tabbed-labels"><label for="__tabbed_13_1">Request</label><label for="__tabbed_13_2">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
+7 -1
View File
@@ -2699,6 +2699,11 @@ full detail:</p>
<td>string or <code>null</code></td>
<td>A message the service shows while it waits for an approval on another device, such as a pair code. It needs no answer.</td>
</tr>
<tr>
<td><code>qr</code></td>
<td>string or <code>null</code></td>
<td>The text of a QR code that goes with <code>input_prompt</code> or <code>notice</code>, such as a login URL to scan with a phone. Draw it as a QR code.</td>
</tr>
</tbody>
</table>
<p>The full detail adds <code>started_time</code>, <code>completed_time</code>, <code>output_files</code>, the redacted
@@ -2909,7 +2914,8 @@ server process. For each job it spawns a separate Python subprocess:</p>
the prompt to <code>progress.json</code> as <code>input_prompt</code> and waits. The answer from
<code>POST /api/download/jobs/{job_id}/input</code> goes to the job worker on its stdin.
When a service waits for an approval on another device, the job worker writes the message as
<code>notice</code> and sets it back to <code>null</code> when the wait ends.</p>
<code>notice</code> and sets it back to <code>null</code> when the wait ends. A QR code to scan goes out as <code>qr</code>, and
the end of its prompt or notice sets it back to <code>null</code>.</p>
<p>Running each download out-of-process isolates the server from crashes, memory growth,
and blocking work inside the download engine, and makes hard cancellation (killing the
process) reliable.</p>
+8 -7
View File
@@ -3048,7 +3048,7 @@ thread, an <code>InputBridge</code> pauses that thread and exposes the prompt to
layer.</p>
<ul>
<li><code>AuthStatus</code> values: <code>authenticating</code>, <code>pending_input</code>, <code>authenticated</code>, <code>failed</code>.</li>
<li><code>InputBridge.request_input(prompt, timeout=600)</code> blocks the sync auth thread on a
<li><code>InputBridge.request_input(prompt, timeout=600, qr=None)</code> blocks the sync auth thread on a
<code>threading.Event</code> until <code>submit_response()</code> or <code>cancel()</code> fires.</li>
<li>A timeout raises <code>TimeoutError</code>. The remote session becomes <code>FAILED</code> when that error ends the login.</li>
<li>A prompt after authentication (in <code>get_titles()</code>, <code>get_tracks()</code> or licensing) goes to
@@ -3065,8 +3065,9 @@ layer.</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>
</span><span id="__span-8-2"><a id="__codelineno-8-2" name="__codelineno-8-2" href="#__codelineno-8-2"></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">"authenticating"</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-3"><a id="__codelineno-8-3" name="__codelineno-8-3" href="#__codelineno-8-3"></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">"pending_input"</span><span class="p">,</span><span class="w"> </span><span class="nt">"prompt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Enter code: "</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-4"><a id="__codelineno-8-4" name="__codelineno-8-4" href="#__codelineno-8-4"></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">"pending_input"</span><span class="p">,</span><span class="w"> </span><span class="nt">"prompt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"cdm_call"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"op"</span><span class="p">:</span><span class="w"> </span><span class="s2">"challenge"</span><span class="p">,</span><span class="w"> </span><span class="nt">"drm"</span><span class="p">:</span><span class="w"> </span><span class="s2">"widevine"</span><span class="p">,</span><span class="w"> </span><span class="nt">"init_data"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"license_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"OFFLINE"</span><span class="p">,</span><span class="w"> </span><span class="nt">"privacy_mode"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"> </span><span class="nt">"service_certificate"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-5"><a id="__codelineno-8-5" name="__codelineno-8-5" href="#__codelineno-8-5"></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">"failed"</span><span class="p">,</span><span class="w"> </span><span class="nt">"error"</span><span class="p">:</span><span class="w"> </span><span class="s2">"...message..."</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-4"><a id="__codelineno-8-4" name="__codelineno-8-4" href="#__codelineno-8-4"></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">"pending_input"</span><span class="p">,</span><span class="w"> </span><span class="nt">"prompt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Scan the code, then press Enter"</span><span class="p">,</span><span class="w"> </span><span class="nt">"qr"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://login.example/scan"</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-5"><a id="__codelineno-8-5" name="__codelineno-8-5" href="#__codelineno-8-5"></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">"pending_input"</span><span class="p">,</span><span class="w"> </span><span class="nt">"prompt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"cdm_call"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"op"</span><span class="p">:</span><span class="w"> </span><span class="s2">"challenge"</span><span class="p">,</span><span class="w"> </span><span class="nt">"drm"</span><span class="p">:</span><span class="w"> </span><span class="s2">"widevine"</span><span class="p">,</span><span class="w"> </span><span class="nt">"init_data"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"license_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"OFFLINE"</span><span class="p">,</span><span class="w"> </span><span class="nt">"privacy_mode"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"> </span><span class="nt">"service_certificate"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-6"><a id="__codelineno-8-6" name="__codelineno-8-6" href="#__codelineno-8-6"></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">"failed"</span><span class="p">,</span><span class="w"> </span><span class="nt">"error"</span><span class="p">:</span><span class="w"> </span><span class="s2">"...message..."</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
<p>A <code>cdm_call</code> comes first, in any auth state. The client answers it with a JSON object in
<code>response</code>: <code>{"session": "...", "challenge": "&lt;base64&gt;"}</code> for <code>challenge</code>,
@@ -3097,8 +3098,8 @@ other remote session routes.</p>
<tr>
<td><code>prompt</code></td>
<td>server</td>
<td><code>id</code>, <code>prompt</code></td>
<td>The service asks the user for input</td>
<td><code>id</code>, <code>prompt</code>, <code>qr</code></td>
<td>The service asks the user for input; <code>qr</code>, when present, is the text of a QR code to draw with it</td>
</tr>
<tr>
<td><code>cdm_call</code></td>
@@ -3109,8 +3110,8 @@ other remote session routes.</p>
<tr>
<td><code>log</code></td>
<td>server</td>
<td><code>seq</code>, <code>level</code>, <code>message</code>, <code>ts</code></td>
<td>One record of the service log, with the same redaction as <code>GET /logs</code></td>
<td><code>seq</code>, <code>level</code>, <code>message</code>, <code>ts</code>, <code>qr</code></td>
<td>One record of the service log, with the same redaction as <code>GET /logs</code>; <code>qr</code>, when present, is the text of a QR code to draw under the message</td>
</tr>
<tr>
<td><code>status</code></td>
+4 -3
View File
@@ -2762,12 +2762,13 @@ Two kinds of members matter: <strong>class variables</strong> that give the deta
<li><strong>DRM license hooks</strong>: <code>get_widevine_service_certificate</code>, <code>get_widevine_license</code>,
<code>get_playready_license</code> (delegates to Widevine by default), and
<code>get_clearkey_license</code> (returns <code>None</code> by default). See <a href="#drm-hooks">DRM hooks</a> below.</li>
<li><strong><code>request_input(prompt)</code></strong>: prompts the user. It goes through the remote-dl input
<li><strong><code>request_input(prompt, qr=None)</code></strong>: prompts the user. It goes through the remote-dl input
bridge, the REST download job relay, or the rich console.</li>
<li><strong><code>wait_for_approval(message, check, timeout, interval=3.0)</code></strong>: shows a message, then
<li><strong><code>wait_for_approval(message, check, timeout, interval=3.0, qr=None)</code></strong>: shows a message, then
calls <code>check</code> until it returns a value. Use it for a login that the user approves on
another device, such as a pair code. A remote-dl session shows the message as a log
line, and a REST download job shows it as the job's <code>notice</code>.</li>
line, and a REST download job shows it as the job's <code>notice</code>. Both methods take <code>qr</code>, the
text of a QR code to scan, and the terminal or UI that shows the user the message draws it.</li>
<li><strong>Event callbacks</strong>: <code>on_segment_downloaded</code>, <code>on_track_downloaded</code>,
<code>on_track_decrypted</code>, <code>on_track_repacked</code>, <code>on_track_multiplex</code> let a service react to
pipeline events.</li>
+191 -179
View File
@@ -3924,7 +3924,7 @@ the cookies into the service HTTP session.</p>
<a href="#unshackle.core.service.Service.request_input" class="headerlink" title="Permanent link">&para;</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">request_input</span><span class="p">(</span><span class="n">prompt</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">request_input</span><span class="p">(</span><span class="n">prompt</span><span class="p">,</span> <span class="n">qr</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
</span></code></pre></div>
<div class="doc doc-contents ">
@@ -3932,7 +3932,8 @@ the cookies into the service HTTP session.</p>
<p>Request interactive input from the user.</p>
<p>Locally, prompts through the shared rich console so the prompt renders alongside
Live progress. A remote-dl session relays it through its :class:<code>InputBridge</code>, and a
REST download job relays it through <code>prompt_user</code> to the job's <code>input_prompt</code>.</p>
REST download job relays it through <code>prompt_user</code> to the job's <code>input_prompt</code>.
<em>qr</em> is the text of a QR code for the user to scan; the terminal that asks the user draws it.</p>
<details class="mkdocstrings-source">
@@ -3946,16 +3947,18 @@ REST download job relays it through <code>prompt_user</code> to the job's <code>
<span class="normal"><a href="#unshackle.core.service.Service.request_input--source--__codelineno-0-476">476</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.request_input--source--__codelineno-0-477">477</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.request_input--source--__codelineno-0-478">478</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.request_input--source--__codelineno-0-479">479</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.request_input--source--__span-0-470"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-470" name="unshackle.core.service.Service.request_input--source--__codelineno-0-470"></a><span class="k">def</span><span class="w"> </span><span class="nf">request_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prompt</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="normal"><a href="#unshackle.core.service.Service.request_input--source--__codelineno-0-479">479</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.request_input--source--__codelineno-0-480">480</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.request_input--source--__span-0-470"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-470" name="unshackle.core.service.Service.request_input--source--__codelineno-0-470"></a><span class="k">def</span><span class="w"> </span><span class="nf">request_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prompt</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">qr</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-471"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-471" name="unshackle.core.service.Service.request_input--source--__codelineno-0-471"></a><span class="w"> </span><span class="sd">"""Request interactive input from the user.</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-472"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-472" name="unshackle.core.service.Service.request_input--source--__codelineno-0-472"></a>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-473"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-473" name="unshackle.core.service.Service.request_input--source--__codelineno-0-473"></a><span class="sd"> Locally, prompts through the shared rich console so the prompt renders alongside</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-474"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-474" name="unshackle.core.service.Service.request_input--source--__codelineno-0-474"></a><span class="sd"> Live progress. A remote-dl session relays it through its :class:`InputBridge`, and a</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-475"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-475" name="unshackle.core.service.Service.request_input--source--__codelineno-0-475"></a><span class="sd"> REST download job relays it through ``prompt_user`` to the job's ``input_prompt``.</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-476"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-476" name="unshackle.core.service.Service.request_input--source--__codelineno-0-476"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-477"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-477" name="unshackle.core.service.Service.request_input--source--__codelineno-0-477"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-478"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-478" name="unshackle.core.service.Service.request_input--source--__codelineno-0-478"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span><span class="o">.</span><span class="n">request_input</span><span class="p">(</span><span class="n">prompt</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-479"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-479" name="unshackle.core.service.Service.request_input--source--__codelineno-0-479"></a> <span class="k">return</span> <span class="n">prompt_user</span><span class="p">(</span><span class="n">prompt</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-476"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-476" name="unshackle.core.service.Service.request_input--source--__codelineno-0-476"></a><span class="sd"> *qr* is the text of a QR code for the user to scan; the terminal that asks the user draws it.</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-477"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-477" name="unshackle.core.service.Service.request_input--source--__codelineno-0-477"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-478"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-478" name="unshackle.core.service.Service.request_input--source--__codelineno-0-478"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-479"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-479" name="unshackle.core.service.Service.request_input--source--__codelineno-0-479"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span><span class="o">.</span><span class="n">request_input</span><span class="p">(</span><span class="n">prompt</span><span class="p">,</span> <span class="n">qr</span><span class="o">=</span><span class="n">qr</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.request_input--source--__span-0-480"><a id="unshackle.core.service.Service.request_input--source--__codelineno-0-480" name="unshackle.core.service.Service.request_input--source--__codelineno-0-480"></a> <span class="k">return</span> <span class="n">prompt_user</span><span class="p">(</span><span class="n">prompt</span><span class="p">,</span> <span class="n">qr</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
@@ -3970,7 +3973,9 @@ REST download job relays it through <code>prompt_user</code> to the job's <code>
<a href="#unshackle.core.service.Service.wait_for_approval" class="headerlink" title="Permanent link">&para;</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">wait_for_approval</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">check</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="n">interval</span><span class="o">=</span><span class="mf">3.0</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">wait_for_approval</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a> <span class="n">message</span><span class="p">,</span> <span class="n">check</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="n">interval</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="n">qr</span><span class="o">=</span><span class="kc">None</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="p">)</span>
</span></code></pre></div>
<div class="doc doc-contents ">
@@ -3979,13 +3984,13 @@ REST download job relays it through <code>prompt_user</code> to the job's <code>
<p>Use it for a login that the user approves on another device, such as a pair code.
<code>check</code> returns None while the approval is pending, and must return within a few
seconds. Raises TimeoutError after <code>timeout</code> seconds, and RuntimeError when the
remote session no longer exists. A REST download job shows <code>message</code> as its <code>notice</code>.</p>
remote session no longer exists. A REST download job shows <code>message</code> as its <code>notice</code>.
<em>qr</em> is the text of a QR code for the user to scan; a remote client gets it with the log record of <code>message</code>.</p>
<details class="mkdocstrings-source">
<summary>Source code in <code>unshackle/core/service.py</code></summary>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-481">481</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-482">482</a></span>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-482">482</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-483">483</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-484">484</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-485">485</a></span>
@@ -4008,31 +4013,38 @@ remote session no longer exists. A REST download job shows <code>message</code>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-502">502</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-503">503</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-504">504</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-505">505</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-481"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-481" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-481"></a><span class="k">def</span><span class="w"> </span><span class="nf">wait_for_approval</span><span class="p">(</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-482"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-482" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-482"></a> <span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">check</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[[],</span> <span class="n">T</span> <span class="o">|</span> <span class="kc">None</span><span class="p">],</span> <span class="n">timeout</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">interval</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">3.0</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-483"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-483" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-483"></a><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-484"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-484" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-484"></a><span class="w"> </span><span class="sd">"""Show ``message``, then call ``check`` until it returns a value.</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-485"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-485" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-485"></a>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-486"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-486" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-486"></a><span class="sd"> Use it for a login that the user approves on another device, such as a pair code.</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-487"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-487" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-487"></a><span class="sd"> ``check`` returns None while the approval is pending, and must return within a few</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-488"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-488" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-488"></a><span class="sd"> seconds. Raises TimeoutError after ``timeout`` seconds, and RuntimeError when the</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-489"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-489" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-489"></a><span class="sd"> remote session no longer exists. A REST download job shows ``message`` as its ``notice``.</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-490"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-490" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-490"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-491"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-491" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-491"></a> <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-492"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-492" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-492"></a> <span class="n">show_notice</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-493"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-493" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-493"></a> <span class="n">deadline</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">monotonic</span><span class="p">()</span> <span class="o">+</span> <span class="n">timeout</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-494"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-494" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-494"></a> <span class="k">try</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-495"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-495" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-495"></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-496"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-496" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-496"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-497"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-497" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-497"></a> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span><span class="o">.</span><span class="n">ensure_active</span><span class="p">()</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-498"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-498" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-498"></a> <span class="n">result</span> <span class="o">=</span> <span class="n">check</span><span class="p">()</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-499"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-499" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-499"></a> <span class="k">if</span> <span class="n">result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-500"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-500" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-500"></a> <span class="k">return</span> <span class="n">result</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-501"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-501" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-501"></a> <span class="k">if</span> <span class="n">time</span><span class="o">.</span><span class="n">monotonic</span><span class="p">()</span> <span class="o">+</span> <span class="n">interval</span> <span class="o">&gt;=</span> <span class="n">deadline</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-502"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-502" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-502"></a> <span class="k">raise</span> <span class="n">coded</span><span class="p">(</span><span class="ne">TimeoutError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No approval within </span><span class="si">{</span><span class="n">timeout</span><span class="si">:</span><span class="s2">.0f</span><span class="si">}</span><span class="s2">s"</span><span class="p">),</span> <span class="n">APIErrorCode</span><span class="o">.</span><span class="n">AUTH_FAILED</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-503"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-503" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-503"></a> <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-504"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-504" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-504"></a> <span class="k">finally</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-505"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-505" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-505"></a> <span class="n">show_notice</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-505">505</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-506">506</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-507">507</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-508">508</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-509">509</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-482"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-482" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-482"></a><span class="k">def</span><span class="w"> </span><span class="nf">wait_for_approval</span><span class="p">(</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-483"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-483" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-483"></a> <span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">check</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[[],</span> <span class="n">T</span> <span class="o">|</span> <span class="kc">None</span><span class="p">],</span> <span class="n">timeout</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">interval</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">3.0</span><span class="p">,</span> <span class="n">qr</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-484"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-484" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-484"></a><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-485"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-485" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-485"></a><span class="w"> </span><span class="sd">"""Show ``message``, then call ``check`` until it returns a value.</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-486"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-486" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-486"></a>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-487"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-487" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-487"></a><span class="sd"> Use it for a login that the user approves on another device, such as a pair code.</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-488"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-488" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-488"></a><span class="sd"> ``check`` returns None while the approval is pending, and must return within a few</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-489"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-489" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-489"></a><span class="sd"> seconds. Raises TimeoutError after ``timeout`` seconds, and RuntimeError when the</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-490"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-490" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-490"></a><span class="sd"> remote session no longer exists. A REST download job shows ``message`` as its ``notice``.</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-491"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-491" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-491"></a><span class="sd"> *qr* is the text of a QR code for the user to scan; a remote client gets it with the log record of ``message``.</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-492"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-492" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-492"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-493"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-493" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-493"></a> <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">extra</span><span class="o">=</span><span class="p">{</span><span class="s2">"qr"</span><span class="p">:</span> <span class="n">qr</span><span class="p">})</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-494"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-494" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-494"></a> <span class="k">if</span> <span class="n">qr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-495"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-495" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-495"></a> <span class="n">show_qr</span><span class="p">(</span><span class="n">qr</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-496"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-496" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-496"></a> <span class="n">show_notice</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">qr</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-497"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-497" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-497"></a> <span class="n">deadline</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">monotonic</span><span class="p">()</span> <span class="o">+</span> <span class="n">timeout</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-498"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-498" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-498"></a> <span class="k">try</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-499"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-499" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-499"></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-500"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-500" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-500"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-501"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-501" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-501"></a> <span class="bp">self</span><span class="o">.</span><span class="n">_input_bridge</span><span class="o">.</span><span class="n">ensure_active</span><span class="p">()</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-502"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-502" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-502"></a> <span class="n">result</span> <span class="o">=</span> <span class="n">check</span><span class="p">()</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-503"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-503" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-503"></a> <span class="k">if</span> <span class="n">result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-504"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-504" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-504"></a> <span class="k">return</span> <span class="n">result</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-505"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-505" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-505"></a> <span class="k">if</span> <span class="n">time</span><span class="o">.</span><span class="n">monotonic</span><span class="p">()</span> <span class="o">+</span> <span class="n">interval</span> <span class="o">&gt;=</span> <span class="n">deadline</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-506"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-506" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-506"></a> <span class="k">raise</span> <span class="n">coded</span><span class="p">(</span><span class="ne">TimeoutError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No approval within </span><span class="si">{</span><span class="n">timeout</span><span class="si">:</span><span class="s2">.0f</span><span class="si">}</span><span class="s2">s"</span><span class="p">),</span> <span class="n">APIErrorCode</span><span class="o">.</span><span class="n">AUTH_FAILED</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-507"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-507" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-507"></a> <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-508"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-508" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-508"></a> <span class="k">finally</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.wait_for_approval--source--__span-0-509"><a id="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-509" name="unshackle.core.service.Service.wait_for_approval--source--__codelineno-0-509"></a> <span class="n">show_notice</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
@@ -4060,25 +4072,25 @@ Ideally re-use the title ID argument (that is, self.title).</p>
<details class="mkdocstrings-source">
<summary>Source code in <code>unshackle/core/service.py</code></summary>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-507">507</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-508">508</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-509">509</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-510">510</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-511">511</a></span>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-511">511</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-512">512</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-513">513</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-514">514</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-515">515</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-516">516</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.search--source--__span-0-507"><a id="unshackle.core.service.Service.search--source--__codelineno-0-507" name="unshackle.core.service.Service.search--source--__codelineno-0-507"></a><span class="k">def</span><span class="w"> </span><span class="nf">search</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Generator</span><span class="p">[</span><span class="n">SearchResult</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">]:</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-508"><a id="unshackle.core.service.Service.search--source--__codelineno-0-508" name="unshackle.core.service.Service.search--source--__codelineno-0-508"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-509"><a id="unshackle.core.service.Service.search--source--__codelineno-0-509" name="unshackle.core.service.Service.search--source--__codelineno-0-509"></a><span class="sd"> Find titles from the Service by query.</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-510"><a id="unshackle.core.service.Service.search--source--__codelineno-0-510" name="unshackle.core.service.Service.search--source--__codelineno-0-510"></a>
</span><span id="unshackle.core.service.Service.search--source--__span-0-511"><a id="unshackle.core.service.Service.search--source--__codelineno-0-511" name="unshackle.core.service.Service.search--source--__codelineno-0-511"></a><span class="sd"> The Service class must take the query as a CLI argument.</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-512"><a id="unshackle.core.service.Service.search--source--__codelineno-0-512" name="unshackle.core.service.Service.search--source--__codelineno-0-512"></a><span class="sd"> Ideally re-use the title ID argument (that is, self.title).</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-513"><a id="unshackle.core.service.Service.search--source--__codelineno-0-513" name="unshackle.core.service.Service.search--source--__codelineno-0-513"></a>
</span><span id="unshackle.core.service.Service.search--source--__span-0-514"><a id="unshackle.core.service.Service.search--source--__codelineno-0-514" name="unshackle.core.service.Service.search--source--__codelineno-0-514"></a><span class="sd"> unshackle displays the search results in the order yielded.</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-515"><a id="unshackle.core.service.Service.search--source--__codelineno-0-515" name="unshackle.core.service.Service.search--source--__codelineno-0-515"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-516"><a id="unshackle.core.service.Service.search--source--__codelineno-0-516" name="unshackle.core.service.Service.search--source--__codelineno-0-516"></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Search functionality has not been implemented by </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-516">516</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-517">517</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-518">518</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-519">519</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.search--source--__codelineno-0-520">520</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.search--source--__span-0-511"><a id="unshackle.core.service.Service.search--source--__codelineno-0-511" name="unshackle.core.service.Service.search--source--__codelineno-0-511"></a><span class="k">def</span><span class="w"> </span><span class="nf">search</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Generator</span><span class="p">[</span><span class="n">SearchResult</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">]:</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-512"><a id="unshackle.core.service.Service.search--source--__codelineno-0-512" name="unshackle.core.service.Service.search--source--__codelineno-0-512"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-513"><a id="unshackle.core.service.Service.search--source--__codelineno-0-513" name="unshackle.core.service.Service.search--source--__codelineno-0-513"></a><span class="sd"> Find titles from the Service by query.</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-514"><a id="unshackle.core.service.Service.search--source--__codelineno-0-514" name="unshackle.core.service.Service.search--source--__codelineno-0-514"></a>
</span><span id="unshackle.core.service.Service.search--source--__span-0-515"><a id="unshackle.core.service.Service.search--source--__codelineno-0-515" name="unshackle.core.service.Service.search--source--__codelineno-0-515"></a><span class="sd"> The Service class must take the query as a CLI argument.</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-516"><a id="unshackle.core.service.Service.search--source--__codelineno-0-516" name="unshackle.core.service.Service.search--source--__codelineno-0-516"></a><span class="sd"> Ideally re-use the title ID argument (that is, self.title).</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-517"><a id="unshackle.core.service.Service.search--source--__codelineno-0-517" name="unshackle.core.service.Service.search--source--__codelineno-0-517"></a>
</span><span id="unshackle.core.service.Service.search--source--__span-0-518"><a id="unshackle.core.service.Service.search--source--__codelineno-0-518" name="unshackle.core.service.Service.search--source--__codelineno-0-518"></a><span class="sd"> unshackle displays the search results in the order yielded.</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-519"><a id="unshackle.core.service.Service.search--source--__codelineno-0-519" name="unshackle.core.service.Service.search--source--__codelineno-0-519"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.search--source--__span-0-520"><a id="unshackle.core.service.Service.search--source--__codelineno-0-520" name="unshackle.core.service.Service.search--source--__codelineno-0-520"></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Search functionality has not been implemented by </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
@@ -4113,11 +4125,7 @@ This can be useful to store information on each title that you need later, like
<details class="mkdocstrings-source">
<summary>Source code in <code>unshackle/core/service.py</code></summary>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-518">518</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-519">519</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-520">520</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-521">521</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-522">522</a></span>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-522">522</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-523">523</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-524">524</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-525">525</a></span>
@@ -4126,20 +4134,24 @@ This can be useful to store information on each title that you need later, like
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-528">528</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-529">529</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-530">530</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-531">531</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_titles--source--__span-0-518"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-518" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-518"></a><span class="nd">@abstractmethod</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-519"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-519" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-519"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_titles</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-520"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-520" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-520"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-521"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-521" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-521"></a><span class="sd"> Get Titles for the provided title ID.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-522"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-522" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-522"></a>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-523"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-523" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-523"></a><span class="sd"> Return a Movies, Series, or Album objects containing Movie, Episode, or Song title objects respectively.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-524"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-524" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-524"></a><span class="sd"> The returned data must be for the given title ID, or a spawn of the title ID.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-525"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-525" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-525"></a>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-526"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-526" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-526"></a><span class="sd"> You must return at least one object. If you do not, unshackle presumes an invalid</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-527"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-527" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-527"></a><span class="sd"> Title ID.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-528"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-528" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-528"></a>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-529"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-529" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-529"></a><span class="sd"> You can use the `data` dictionary class instance attribute of each Title to store data you may need later on.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-530"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-530" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-530"></a><span class="sd"> This can be useful to store information on each title that you need later, like any sub-asset IDs, or such.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-531"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-531" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-531"></a><span class="sd"> """</span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-531">531</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-532">532</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-533">533</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-534">534</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles--source--__codelineno-0-535">535</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_titles--source--__span-0-522"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-522" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-522"></a><span class="nd">@abstractmethod</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-523"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-523" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-523"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_titles</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-524"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-524" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-524"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-525"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-525" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-525"></a><span class="sd"> Get Titles for the provided title ID.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-526"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-526" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-526"></a>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-527"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-527" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-527"></a><span class="sd"> Return a Movies, Series, or Album objects containing Movie, Episode, or Song title objects respectively.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-528"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-528" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-528"></a><span class="sd"> The returned data must be for the given title ID, or a spawn of the title ID.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-529"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-529" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-529"></a>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-530"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-530" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-530"></a><span class="sd"> You must return at least one object. If you do not, unshackle presumes an invalid</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-531"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-531" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-531"></a><span class="sd"> Title ID.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-532"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-532" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-532"></a>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-533"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-533" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-533"></a><span class="sd"> You can use the `data` dictionary class instance attribute of each Title to store data you may need later on.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-534"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-534" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-534"></a><span class="sd"> This can be useful to store information on each title that you need later, like any sub-asset IDs, or such.</span>
</span><span id="unshackle.core.service.Service.get_titles--source--__span-0-535"><a id="unshackle.core.service.Service.get_titles--source--__codelineno-0-535" name="unshackle.core.service.Service.get_titles--source--__codelineno-0-535"></a><span class="sd"> """</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
@@ -4221,11 +4233,7 @@ fallback to cached data when API calls fail.</p>
<details class="mkdocstrings-source">
<summary>Source code in <code>unshackle/core/service.py</code></summary>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-533">533</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-534">534</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-535">535</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-536">536</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-537">537</a></span>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-537">537</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-538">538</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-539">539</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-540">540</a></span>
@@ -4256,42 +4264,46 @@ fallback to cached data when API calls fail.</p>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-565">565</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-566">566</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-567">567</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-568">568</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-533"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-533" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-533"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_titles_cached</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title_id</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-534"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-534" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-534"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-535"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-535" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-535"></a><span class="sd"> Cached wrapper around get_titles() to reduce redundant API calls.</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-536"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-536" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-536"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-537"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-537" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-537"></a><span class="sd"> This method checks the cache before calling get_titles() and handles</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-538"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-538" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-538"></a><span class="sd"> fallback to cached data when API calls fail.</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-539"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-539" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-539"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-540"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-540" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-540"></a><span class="sd"> Args:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-541"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-541" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-541"></a><span class="sd"> title_id: Optional title ID for cache key generation.</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-542"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-542" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-542"></a><span class="sd"> If not provided, will try to extract from service instance.</span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-568">568</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-569">569</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-570">570</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-571">571</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-572">572</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-537"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-537" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-537"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_titles_cached</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title_id</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-538"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-538" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-538"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-539"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-539" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-539"></a><span class="sd"> Cached wrapper around get_titles() to reduce redundant API calls.</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-540"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-540" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-540"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-541"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-541" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-541"></a><span class="sd"> This method checks the cache before calling get_titles() and handles</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-542"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-542" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-542"></a><span class="sd"> fallback to cached data when API calls fail.</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-543"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-543" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-543"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-544"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-544" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-544"></a><span class="sd"> Returns:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-545"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-545" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-545"></a><span class="sd"> Titles object (Movies, Series, or Album)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-546"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-546" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-546"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-547"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-547" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-547"></a> <span class="n">identity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cache_identity</span><span class="p">()</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-548"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-548" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-548"></a> <span class="k">if</span> <span class="n">title_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-549"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-549" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-549"></a> <span class="n">title_id</span> <span class="o">=</span> <span class="n">identity</span><span class="o">.</span><span class="n">title_id</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-550"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-550" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-550"></a> <span class="k">if</span> <span class="n">title_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-551"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-551" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-551"></a> <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Cannot determine title_id for caching, bypassing cache"</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-552"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-552" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-552"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">apply_title_map</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_titles</span><span class="p">())</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-553"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-553" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-553"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-554"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-554" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-554"></a> <span class="n">no_cache</span> <span class="o">=</span> <span class="kc">False</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-555"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-555" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-555"></a> <span class="n">reset_cache</span> <span class="o">=</span> <span class="kc">False</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-556"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-556" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-556"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span><span class="o">.</span><span class="n">parent</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-557"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-557" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-557"></a> <span class="n">no_cache</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_cache"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-558"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-558" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-558"></a> <span class="n">reset_cache</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"reset_cache"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-559"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-559" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-559"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-560"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-560" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-560"></a> <span class="n">titles</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">title_cache</span><span class="o">.</span><span class="n">get_cached_titles</span><span class="p">(</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-561"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-561" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-561"></a> <span class="n">title_id</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">title_id</span><span class="p">),</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-562"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-562" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-562"></a> <span class="n">fetch_function</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">get_titles</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-563"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-563" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-563"></a> <span class="n">region</span><span class="o">=</span><span class="n">identity</span><span class="o">.</span><span class="n">region</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-564"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-564" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-564"></a> <span class="n">account_hash</span><span class="o">=</span><span class="n">identity</span><span class="o">.</span><span class="n">account_hash</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-565"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-565" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-565"></a> <span class="n">no_cache</span><span class="o">=</span><span class="n">no_cache</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-566"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-566" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-566"></a> <span class="n">reset_cache</span><span class="o">=</span><span class="n">reset_cache</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-567"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-567" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-567"></a> <span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-568"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-568" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-568"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">apply_title_map</span><span class="p">(</span><span class="n">titles</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-544"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-544" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-544"></a><span class="sd"> Args:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-545"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-545" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-545"></a><span class="sd"> title_id: Optional title ID for cache key generation.</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-546"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-546" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-546"></a><span class="sd"> If not provided, will try to extract from service instance.</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-547"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-547" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-547"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-548"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-548" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-548"></a><span class="sd"> Returns:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-549"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-549" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-549"></a><span class="sd"> Titles object (Movies, Series, or Album)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-550"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-550" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-550"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-551"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-551" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-551"></a> <span class="n">identity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cache_identity</span><span class="p">()</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-552"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-552" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-552"></a> <span class="k">if</span> <span class="n">title_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-553"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-553" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-553"></a> <span class="n">title_id</span> <span class="o">=</span> <span class="n">identity</span><span class="o">.</span><span class="n">title_id</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-554"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-554" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-554"></a> <span class="k">if</span> <span class="n">title_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-555"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-555" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-555"></a> <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Cannot determine title_id for caching, bypassing cache"</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-556"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-556" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-556"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">apply_title_map</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_titles</span><span class="p">())</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-557"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-557" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-557"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-558"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-558" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-558"></a> <span class="n">no_cache</span> <span class="o">=</span> <span class="kc">False</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-559"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-559" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-559"></a> <span class="n">reset_cache</span> <span class="o">=</span> <span class="kc">False</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-560"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-560" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-560"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span><span class="o">.</span><span class="n">parent</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-561"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-561" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-561"></a> <span class="n">no_cache</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_cache"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-562"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-562" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-562"></a> <span class="n">reset_cache</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"reset_cache"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-563"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-563" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-563"></a>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-564"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-564" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-564"></a> <span class="n">titles</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">title_cache</span><span class="o">.</span><span class="n">get_cached_titles</span><span class="p">(</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-565"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-565" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-565"></a> <span class="n">title_id</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">title_id</span><span class="p">),</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-566"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-566" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-566"></a> <span class="n">fetch_function</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">get_titles</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-567"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-567" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-567"></a> <span class="n">region</span><span class="o">=</span><span class="n">identity</span><span class="o">.</span><span class="n">region</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-568"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-568" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-568"></a> <span class="n">account_hash</span><span class="o">=</span><span class="n">identity</span><span class="o">.</span><span class="n">account_hash</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-569"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-569" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-569"></a> <span class="n">no_cache</span><span class="o">=</span><span class="n">no_cache</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-570"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-570" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-570"></a> <span class="n">reset_cache</span><span class="o">=</span><span class="n">reset_cache</span><span class="p">,</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-571"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-571" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-571"></a> <span class="p">)</span>
</span><span id="unshackle.core.service.Service.get_titles_cached--source--__span-0-572"><a id="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-572" name="unshackle.core.service.Service.get_titles_cached--source--__codelineno-0-572"></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">apply_title_map</span><span class="p">(</span><span class="n">titles</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
@@ -4319,23 +4331,23 @@ title cache so config edits take effect without a cache reset, and before any
<details class="mkdocstrings-source">
<summary>Source code in <code>unshackle/core/service.py</code></summary>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-570">570</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-571">571</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-572">572</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-573">573</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-574">574</a></span>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-574">574</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-575">575</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-576">576</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-577">577</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-578">578</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-570"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-570" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-570"></a><span class="k">def</span><span class="w"> </span><span class="nf">apply_title_map</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">titles</span><span class="p">:</span> <span class="n">Titles_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-571"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-571" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-571"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-572"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-572" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-572"></a><span class="sd"> Rewrite service-provided titles using the per-service ``title_map`` config.</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-573"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-573" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-573"></a>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-574"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-574" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-574"></a><span class="sd"> ``title_map`` lives under ``services.&lt;TAG&gt;`` in unshackle.yaml. Applied after the</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-575"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-575" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-575"></a><span class="sd"> title cache so config edits take effect without a cache reset, and before any</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-576"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-576" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-576"></a><span class="sd"> ``--enrich`` override so enrich wins. See ``remap_titles`` for the match rules.</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-577"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-577" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-577"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-578"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-578" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-578"></a> <span class="k">return</span> <span class="n">remap_titles</span><span class="p">(</span><span class="n">titles</span><span class="p">,</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span> <span class="ow">or</span> <span class="p">{})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"title_map"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">{})</span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-578">578</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-579">579</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-580">580</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-581">581</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.apply_title_map--source--__codelineno-0-582">582</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-574"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-574" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-574"></a><span class="k">def</span><span class="w"> </span><span class="nf">apply_title_map</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">titles</span><span class="p">:</span> <span class="n">Titles_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Titles_T</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-575"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-575" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-575"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-576"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-576" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-576"></a><span class="sd"> Rewrite service-provided titles using the per-service ``title_map`` config.</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-577"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-577" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-577"></a>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-578"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-578" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-578"></a><span class="sd"> ``title_map`` lives under ``services.&lt;TAG&gt;`` in unshackle.yaml. Applied after the</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-579"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-579" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-579"></a><span class="sd"> title cache so config edits take effect without a cache reset, and before any</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-580"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-580" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-580"></a><span class="sd"> ``--enrich`` override so enrich wins. See ``remap_titles`` for the match rules.</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-581"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-581" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-581"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.apply_title_map--source--__span-0-582"><a id="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-582" name="unshackle.core.service.Service.apply_title_map--source--__codelineno-0-582"></a> <span class="k">return</span> <span class="n">remap_titles</span><span class="p">(</span><span class="n">titles</span><span class="p">,</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">config</span> <span class="ow">or</span> <span class="p">{})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"title_map"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">{})</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
@@ -4382,11 +4394,7 @@ the Track's media data, then do.</p>
<details class="mkdocstrings-source">
<summary>Source code in <code>unshackle/core/service.py</code></summary>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-580">580</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-581">581</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-582">582</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-583">583</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-584">584</a></span>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-584">584</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-585">585</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-586">586</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-587">587</a></span>
@@ -4411,36 +4419,40 @@ the Track's media data, then do.</p>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-606">606</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-607">607</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-608">608</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-609">609</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_tracks--source--__span-0-580"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-580" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-580"></a><span class="nd">@abstractmethod</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-581"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-581" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-581"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-582"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-582" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-582"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-583"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-583" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-583"></a><span class="sd"> Get Track objects of the Title.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-584"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-584" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-584"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-585"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-585" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-585"></a><span class="sd"> Return a Tracks object, which itself can contain Video, Audio, Subtitle or even Chapters.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-586"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-586" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-586"></a><span class="sd"> Tracks.videos, Tracks.audio, Tracks.subtitles, and Track.chapters should be a List of Track objects.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-587"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-587" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-587"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-588"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-588" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-588"></a><span class="sd"> Each Track in the Tracks should represent a Video/Audio track, Representation, or</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-589"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-589" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-589"></a><span class="sd"> Adaptation, or a Subtitle file.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-590"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-590" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-590"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-591"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-591" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-591"></a><span class="sd"> While one Track should only hold information for one downloadable track, try to get as many</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-592"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-592" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-592"></a><span class="sd"> unique Track objects per track type so track selection by the root code can give you more</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-593"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-593" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-593"></a><span class="sd"> options in terms of Resolution, Bitrate, Codecs, Language, and such.</span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-609">609</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-610">610</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-611">611</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-612">612</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_tracks--source--__codelineno-0-613">613</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_tracks--source--__span-0-584"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-584" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-584"></a><span class="nd">@abstractmethod</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-585"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-585" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-585"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_tracks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tracks</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-586"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-586" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-586"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-587"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-587" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-587"></a><span class="sd"> Get Track objects of the Title.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-588"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-588" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-588"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-589"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-589" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-589"></a><span class="sd"> Return a Tracks object, which itself can contain Video, Audio, Subtitle or even Chapters.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-590"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-590" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-590"></a><span class="sd"> Tracks.videos, Tracks.audio, Tracks.subtitles, and Track.chapters should be a List of Track objects.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-591"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-591" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-591"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-592"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-592" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-592"></a><span class="sd"> Each Track in the Tracks should represent a Video/Audio track, Representation, or</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-593"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-593" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-593"></a><span class="sd"> Adaptation, or a Subtitle file.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-594"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-594" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-594"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-595"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-595" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-595"></a><span class="sd"> No decision making or filtering of which Tracks get returned should happen here. It can be</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-596"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-596" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-596"></a><span class="sd"> considered an error to filter for e.g. resolution, codec, and such. All filtering based on</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-597"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-597" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-597"></a><span class="sd"> arguments will be done by the root code automatically when needed.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-595"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-595" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-595"></a><span class="sd"> While one Track should only hold information for one downloadable track, try to get as many</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-596"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-596" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-596"></a><span class="sd"> unique Track objects per track type so track selection by the root code can give you more</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-597"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-597" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-597"></a><span class="sd"> options in terms of Resolution, Bitrate, Codecs, Language, and such.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-598"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-598" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-598"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-599"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-599" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-599"></a><span class="sd"> Make sure you correctly mark which Tracks have encryption, and which DRM System they</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-600"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-600" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-600"></a><span class="sd"> use, with the `drm` property.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-601"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-601" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-601"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-602"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-602" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-602"></a><span class="sd"> If you can get the Track's KID (Key ID) as a 32 char (16 bit) HEX string, give it to the</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-603"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-603" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-603"></a><span class="sd"> Track's `kid` variable, as it will speed up the decryption process later on. The service</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-604"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-604" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-604"></a><span class="sd"> decides whether it is necessary. Generally if you can give it, without downloading any of</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-605"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-605" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-605"></a><span class="sd"> the Track's media data, then do.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-606"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-606" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-606"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-607"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-607" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-607"></a><span class="sd"> :param title: The current `Title` from get_titles that unshackle processes now.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-608"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-608" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-608"></a><span class="sd"> :return: Tracks object containing Video, Audio, Subtitles, and Chapters, if available.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-609"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-609" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-609"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-599"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-599" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-599"></a><span class="sd"> No decision making or filtering of which Tracks get returned should happen here. It can be</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-600"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-600" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-600"></a><span class="sd"> considered an error to filter for e.g. resolution, codec, and such. All filtering based on</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-601"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-601" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-601"></a><span class="sd"> arguments will be done by the root code automatically when needed.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-602"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-602" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-602"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-603"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-603" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-603"></a><span class="sd"> Make sure you correctly mark which Tracks have encryption, and which DRM System they</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-604"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-604" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-604"></a><span class="sd"> use, with the `drm` property.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-605"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-605" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-605"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-606"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-606" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-606"></a><span class="sd"> If you can get the Track's KID (Key ID) as a 32 char (16 bit) HEX string, give it to the</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-607"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-607" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-607"></a><span class="sd"> Track's `kid` variable, as it will speed up the decryption process later on. The service</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-608"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-608" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-608"></a><span class="sd"> decides whether it is necessary. Generally if you can give it, without downloading any of</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-609"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-609" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-609"></a><span class="sd"> the Track's media data, then do.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-610"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-610" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-610"></a>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-611"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-611" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-611"></a><span class="sd"> :param title: The current `Title` from get_titles that unshackle processes now.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-612"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-612" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-612"></a><span class="sd"> :return: Tracks object containing Video, Audio, Subtitles, and Chapters, if available.</span>
</span><span id="unshackle.core.service.Service.get_tracks--source--__span-0-613"><a id="unshackle.core.service.Service.get_tracks--source--__codelineno-0-613" name="unshackle.core.service.Service.get_tracks--source--__codelineno-0-613"></a><span class="sd"> """</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
@@ -4507,11 +4519,7 @@ option <code>chapter_fallback_name</code>. For example, <code>"Chapter {i:02}"</
<details class="mkdocstrings-source">
<summary>Source code in <code>unshackle/core/service.py</code></summary>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-611">611</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-612">612</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-613">613</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-614">614</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-615">615</a></span>
<div class="language-python highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-615">615</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-616">616</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-617">617</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-618">618</a></span>
@@ -4524,24 +4532,28 @@ option <code>chapter_fallback_name</code>. For example, <code>"Chapter {i:02}"</
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-625">625</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-626">626</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-627">627</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-628">628</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_chapters--source--__span-0-611"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-611" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-611"></a><span class="nd">@abstractmethod</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-612"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-612" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-612"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_chapters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Chapters</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-613"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-613" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-613"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-614"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-614" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-614"></a><span class="sd"> Get Chapters for the Title.</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-615"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-615" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-615"></a>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-616"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-616" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-616"></a><span class="sd"> Parameters:</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-617"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-617" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-617"></a><span class="sd"> title: The current Title from `get_titles` that unshackle processes now.</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-618"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-618" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-618"></a>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-619"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-619" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-619"></a><span class="sd"> You must return a Chapters object containing 0 or more Chapter objects.</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-620"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-620" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-620"></a>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-621"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-621" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-621"></a><span class="sd"> You do not need to set a Chapter number or sort/order the chapters in any way as</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-622"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-622" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-622"></a><span class="sd"> the Chapters class automatically handles all of that for you. If there is no</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-623"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-623" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-623"></a><span class="sd"> descriptive name for a Chapter then do not set a name at all.</span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-628">628</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-629">629</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-630">630</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-631">631</a></span>
<span class="normal"><a href="#unshackle.core.service.Service.get_chapters--source--__codelineno-0-632">632</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="unshackle.core.service.Service.get_chapters--source--__span-0-615"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-615" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-615"></a><span class="nd">@abstractmethod</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-616"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-616" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-616"></a><span class="k">def</span><span class="w"> </span><span class="nf">get_chapters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">title</span><span class="p">:</span> <span class="n">Title_T</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Chapters</span><span class="p">:</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-617"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-617" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-617"></a><span class="w"> </span><span class="sd">"""</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-618"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-618" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-618"></a><span class="sd"> Get Chapters for the Title.</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-619"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-619" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-619"></a>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-620"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-620" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-620"></a><span class="sd"> Parameters:</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-621"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-621" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-621"></a><span class="sd"> title: The current Title from `get_titles` that unshackle processes now.</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-622"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-622" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-622"></a>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-623"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-623" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-623"></a><span class="sd"> You must return a Chapters object containing 0 or more Chapter objects.</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-624"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-624" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-624"></a>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-625"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-625" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-625"></a><span class="sd"> You must not set Chapter names to "Chapter {n}" or such. If you (or the user)</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-626"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-626" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-626"></a><span class="sd"> wants "Chapter {n}" style Chapter names (or similar) then they can use the config</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-627"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-627" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-627"></a><span class="sd"> option `chapter_fallback_name`. For example, `"Chapter {i:02}"` for "Chapter 01".</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-628"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-628" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-628"></a><span class="sd"> """</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-625"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-625" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-625"></a><span class="sd"> You do not need to set a Chapter number or sort/order the chapters in any way as</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-626"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-626" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-626"></a><span class="sd"> the Chapters class automatically handles all of that for you. If there is no</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-627"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-627" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-627"></a><span class="sd"> descriptive name for a Chapter then do not set a name at all.</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-628"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-628" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-628"></a>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-629"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-629" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-629"></a><span class="sd"> You must not set Chapter names to "Chapter {n}" or such. If you (or the user)</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-630"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-630" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-630"></a><span class="sd"> wants "Chapter {n}" style Chapter names (or similar) then they can use the config</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-631"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-631" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-631"></a><span class="sd"> option `chapter_fallback_name`. For example, `"Chapter {i:02}"` for "Chapter 01".</span>
</span><span id="unshackle.core.service.Service.get_chapters--source--__span-0-632"><a id="unshackle.core.service.Service.get_chapters--source--__codelineno-0-632" name="unshackle.core.service.Service.get_chapters--source--__codelineno-0-632"></a><span class="sd"> """</span>
</span></code></pre></div></td></tr></table></div>
</details>
</div>
File diff suppressed because one or more lines are too long