/usr/share/doc/python-libdiscid-doc/html/usage.html is in python-libdiscid-doc 0.4.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Usage — python-libdiscid 0.4.1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.4.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="python-libdiscid 0.4.1 documentation" href="index.html" />
<link rel="next" title="Miscellaneous" href="misc.html" />
<link rel="prev" title="Installation" href="installation.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="misc.html" title="Miscellaneous"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="installation.html" title="Installation"
accesskey="P">previous</a> |</li>
<li><a href="index.html">python-libdiscid 0.4.1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="usage">
<h1>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h1>
<div class="section" id="disc-id-computation-from-a-disc">
<h2>Disc ID computation from a disc<a class="headerlink" href="#disc-id-computation-from-a-disc" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="api.html#libdiscid.read" title="libdiscid.read"><tt class="xref py py-func docutils literal"><span class="pre">libdiscid.read()</span></tt></a> provides everything needed to read the information
from a disc and compute the disc id:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">libdiscid</span> <span class="kn">import</span> <span class="n">read</span>
<span class="n">disc</span> <span class="o">=</span> <span class="n">read</span><span class="p">()</span>
<span class="k">print</span> <span class="s">"id: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">disc</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="p">)</span>
</pre></div>
</div>
<p>If no additional arguments are passed to <a class="reference internal" href="api.html#libdiscid.read" title="libdiscid.read"><tt class="xref py py-func docutils literal"><span class="pre">libdiscid.read()</span></tt></a>,
it will read from <a class="reference internal" href="api.html#libdiscid.default_device" title="libdiscid.default_device"><tt class="xref py py-func docutils literal"><span class="pre">libdiscid.default_device()</span></tt></a>. If reading is not supported
on your platform, <tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt> will be raised. If anything
goes wrong while reading from the device, <tt class="xref py py-exc docutils literal"><span class="pre">libdiscid.discid.DiscError</span></tt>
will be raised.</p>
<p>To read from a different device than the default one, you can set <tt class="docutils literal"><span class="pre">device</span></tt>
accordingly:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">libdiscid</span> <span class="kn">import</span> <span class="n">read</span>
<span class="n">disc</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="s">u'/dev/cdrom1'</span><span class="p">)</span>
<span class="k">print</span> <span class="s">"id: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">disc</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="p">)</span>
</pre></div>
</div>
<p>Starting with <cite>libdiscid</cite> 0.5.0, it is possible to explicitly state what should
be read. For example, to read the MCN, one would use:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">libdiscid</span> <span class="kn">import</span> <span class="n">read</span><span class="p">,</span> <span class="n">FEATURE_MCN</span>
<span class="n">disc</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">features</span><span class="o">=</span><span class="n">FEATURE_MCN</span><span class="p">)</span>
<span class="c"># disc.id will be available</span>
<span class="k">print</span> <span class="s">"id: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">disc</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="p">)</span>
<span class="c"># if the disc has a MCN and libdiscid is 0.4.0 or later and libdiscid</span>
<span class="c"># supports reading the MCN on this platform, disc.mcn will be non-empty.</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">print</span> <span class="s">"MCN: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">disc</span><span class="o">.</span><span class="n">mcn</span><span class="p">,</span> <span class="p">)</span>
<span class="k">except</span> <span class="ne">NotImplementedError</span><span class="p">:</span>
<span class="k">print</span> <span class="s">"MCN reading not supported on this platform/with this libdiscid"</span>
</pre></div>
</div>
<p>If you only want to get the disc id and do not care about the MCN and the ISCRs,
you can tell that to <a class="reference internal" href="api.html#libdiscid.read" title="libdiscid.read"><tt class="xref py py-func docutils literal"><span class="pre">libdiscid.read()</span></tt></a> by passing <tt class="docutils literal"><span class="pre">0</span></tt> or
<a class="reference internal" href="api.html#libdiscid.FEATURE_READ" title="libdiscid.FEATURE_READ"><tt class="xref py py-data docutils literal"><span class="pre">libdiscid.FEATURE_READ</span></tt></a> to <tt class="docutils literal"><span class="pre">features</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">libdiscid</span> <span class="kn">import</span> <span class="n">read</span>
<span class="n">disc</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">features</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="disc-id-computation-from-data">
<h2>Disc ID computation from data<a class="headerlink" href="#disc-id-computation-from-data" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="api.html#libdiscid.put" title="libdiscid.put"><tt class="xref py py-func docutils literal"><span class="pre">libdiscid.put()</span></tt></a> can be used to compute the disc ID based on the first and
last track, the number of total sectors and track offsets:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">libdiscid</span> <span class="kn">import</span> <span class="n">put</span>
<span class="n">disc</span> <span class="o">=</span> <span class="n">put</span><span class="p">(</span><span class="n">first_track</span><span class="p">,</span> <span class="n">last_track</span><span class="p">,</span> <span class="n">num_sectors</span><span class="p">,</span> <span class="n">offsets</span><span class="p">)</span>
<span class="k">print</span> <span class="s">"id: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">disc</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="p">)</span>
</pre></div>
</div>
<p>Please note that <a class="reference internal" href="api.html#libdiscid.DiscId.mcn" title="libdiscid.DiscId.mcn"><tt class="xref py py-attr docutils literal"><span class="pre">libdiscid.DiscId.mcn</span></tt></a> and
<a class="reference internal" href="api.html#libdiscid.DiscId.track_isrcs" title="libdiscid.DiscId.track_isrcs"><tt class="xref py py-attr docutils literal"><span class="pre">libdiscid.DiscId.track_isrcs</span></tt></a> will be empty after a call to
<a class="reference internal" href="api.html#libdiscid.put" title="libdiscid.put"><tt class="xref py py-func docutils literal"><span class="pre">libdiscid.put()</span></tt></a>.</p>
</div>
<div class="section" id="python-discid-compat-module">
<h2>python-discid compat module<a class="headerlink" href="#python-discid-compat-module" title="Permalink to this headline">¶</a></h2>
<p><tt class="xref py py-mod docutils literal"><span class="pre">libdiscid.compat.discid</span></tt> provides the same API as <tt class="xref py py-mod docutils literal"><span class="pre">discid</span></tt> from
<cite>python-discid</cite> version 1.0.2. This allows applications to only care about one
API and be usable with either of <cite>python-libdiscid</cite> or <cite>python-discid</cite>
installed. Just use the following code to import the module:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">try</span><span class="p">:</span>
<span class="kn">from</span> <span class="nn">libdiscid.compat</span> <span class="kn">import</span> <span class="n">discid</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
<span class="kn">import</span> <span class="nn">discid</span>
</pre></div>
</div>
<p>and then use the <tt class="xref py py-mod docutils literal"><span class="pre">discid</span></tt> interface.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Usage</a><ul>
<li><a class="reference internal" href="#disc-id-computation-from-a-disc">Disc ID computation from a disc</a></li>
<li><a class="reference internal" href="#disc-id-computation-from-data">Disc ID computation from data</a></li>
<li><a class="reference internal" href="#python-discid-compat-module">python-discid compat module</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="installation.html"
title="previous chapter">Installation</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="misc.html"
title="next chapter">Miscellaneous</a></p>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="misc.html" title="Miscellaneous"
>next</a> |</li>
<li class="right" >
<a href="installation.html" title="Installation"
>previous</a> |</li>
<li><a href="index.html">python-libdiscid 0.4.1 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2013, Sebastian Ramacher.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>
|