kaliko.me - devhttps://kaliko.me/2022-05-09T00:00:00+02:00python-musicpd 0.8.02022-05-09T00:00:00+02:002022-05-09T00:00:00+02:00kalikotag:kaliko.me,2022-05-09:/posts/2022/05/python-musicpd-080/<p>Releasing python-musicpd 0.8.0</p><p>This release adds context management and raised minimum python version to 3.6, see <a href="https://gitlab.com/kaliko/python-musicpd/-/blob/v0.8.0/CHANGES.txt#L4-9">changes</a> for more.</p>
<p>MPDClient instances now support context manager, see <a href="https://kaliko.gitlab.io/python-musicpd/use.html#context-manager">doc</a> for more, thanks to Wonko der Verständige.</p>
<ul>
<li>python-musicpd 0.8.0 is available <a href="https://pypi.org/project/python-musicpd/">on pypi</a>.</li>
<li>Debian/bullseye <a href="https://deb.kaliko.me/debian-backports/pool/main/p/python-musicpd/">backported paclage is available</a>, cf. <a href="https://kaliko.me/debian"><code>deb.kaliko.me</code></a> if you want to use the repo.</li>
<li><a href="https://kaliko.gitlab.io/python-musicpd">Documentation</a></li>
</ul>
<p>Happy Music Player Daemon hacking with python 🐍 :)<br>
Happy listening 🎶!</p>MPD_sima 0.18.02021-11-17T00:00:00+01:002021-11-17T00:00:00+01:00kalikotag:kaliko.me,2021-11-17:/posts/2021/11/MPD_sima-0.18.0/<p>MPD_sima 0.18.0 Release</p><p><a href="https://kaliko.me/mpd-sima">MPD_sima</a> v0.18.0 is available.
The package is available on <a href="https://pypi.org/project/MPD-sima/0.18.0/">pypi.org</a>
and tagged <a href="https://gitlab.com/kaliko/sima/-/tags/0.18.0">0.18.0</a> in git:</p>
<div class="highlight"><pre><span></span><code>pip install MPD-sima<span class="o">==</span><span class="m">0</span>.18.0
<span class="c1"># Or from git</span>
pip install git+https://gitlab.com/kaliko/sima.git@0.18.0#egg<span class="o">=</span>MPD-sima
</code></pre></div>
<p>Please report issue on gitlab: <a href="https://gitlab.com/kaliko/sima/-/issues">gitlab.com/kaliko/sima/-/issues</a></p>
<h2>Main changes</h2>
<p>Changes since <a href="https://kaliko.me/posts/2020/12/sima-0.16.0/">0.16</a>:</p>
<ul>
<li>New offline autoqueue plugin <strong>genre</strong> based on file genre tags only</li>
<li>Major changes in <span class="caps">CLI</span> (<code>simadb_cli</code> command removed)</li>
<li>Add abstract unix socket support</li>
<li>Support socket timeout, behave better on connection lost (require <a href="https://kaliko.me/posts/2021/07/python-musicpd-070/">python-musicpd >= 0.7.0</a>)</li>
<li>Major internal refactoring around database, <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <strong>old database dropped!</strong></li>
</ul>
<p>Cf. <a href="https://gitlab.com/kaliko/sima/-/raw/0.18.0/doc/Changelog">Changelog for the complete list</a>.</p>
<h2>New plugin <strong>Genre</strong></h2>
<p>This plugin permits offline auto-queuing based on files genre tag only.<br>
It will try to queue tracks with similar genres (track’s genre being read from tags). </p>
<div class="highlight"><pre><span></span><code><span class="k">[sima]</span><span class="w"></span>
<span class="na">internal</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Crop, Genre, Random</span><span class="w"></span>
<span class="na">history_duration</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">8</span><span class="w"></span>
<span class="k">[genre]</span><span class="w"></span>
<span class="na">queue_mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">track</span><span class="w"></span>
<span class="na">track_to_add</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">1</span><span class="w"></span>
</code></pre></div>
<p>Fore more please see <a href="https://manpages.debian.org/bookworm/mpd-sima/mpd_sima.cfg.5.en.html">mpd_sima.cfg (5)</a> (select 0.18.0 version).</p>
<h2>Change in <span class="caps">CLI</span></h2>
<p><code>simadb_cli</code> command was merged as <code>mpd-sima</code> command as positional argument:</p>
<div class="highlight"><pre><span></span><code>mpd-sima [bl-view|bl-add-artist|bl-add-track|bl-delete]
</code></pre></div>
<p>New commands also:</p>
<div class="highlight"><pre><span></span><code>mpd-sima [config-test|create-db|generate-config|purge-history]
</code></pre></div>
<p>Please see manual for more <a href="https://manpages.debian.org/bookworm/mpd-sima/mpd-sima.1.en.html">mpd-sima (1)</a> (select 0.18.0 version).</p>
<h2>New database</h2>
<p>The internal SQLite database has been refactored (new schema, new code).<br>
The internal database stores play history (limited to 30 days) and potential users blocklists (artists, albums, tracks).</p>
<p>There are <strong>no migration ensured</strong> when upgrading to v0.18.0. Then if you had set some blocklists in the database you won’t have them in the new version.</p>
<h2>New documentation</h2>
<p>A new documentation is available as html (sphinx behind): <a href="https://media.kaliko.me/sima/">media.kaliko.me/sima/</a><br>
This is a work in progress and it is not exhaustive then.</p>
<p>Happy listening 🎶!<br> k</p>python-musicpd 0.7.02021-07-23T00:00:00+02:002021-07-23T00:00:00+02:00kalikotag:kaliko.me,2021-07-23:/posts/2021/07/python-musicpd-070/<p>Releasing python-musicpd 0.7.0</p><p>This release adds socket timeout (disabled by default) and minor <a href="https://gitlab.com/kaliko/python-musicpd/-/blob/v0.7.0/CHANGES.txt#L4-9">changes</a>.</p>
<p>For socket timeout please read the <a href="https://kaliko.gitlab.io/python-musicpd/use.html#socket-timeout">doc</a> and <a href="https://kaliko.me/posts/2021/07/python-musicpd-socket-timeout/">previous
post</a> on the subject.</p>
<ul>
<li>python-musicpd 0.7.0 is available <a href="https://pypi.org/project/python-musicpd/">on pypi</a>.</li>
<li><a href="https://kaliko.gitlab.io/python-musicpd">Documentation</a></li>
</ul>
<p>Happy Music Player Daemon hacking with python 🐍 :)<br>
Happy listening 🎶!</p>python-musicpd socket timeout2021-07-10T00:00:00+02:002021-07-10T00:00:00+02:00kalikotag:kaliko.me,2021-07-10:/posts/2021/07/python-musicpd-socket-timeout/<p>Add socket timeout in python-musicpd</p><p>Having socket timeout enabled can help to detect “half-open connection”. For
instance loosing connectivity without the server explicitly closing the
connection (switching network, router down, <span class="caps">MPD</span> stuck|crashing, etc…).</p>
<p>A timeout was introduced in v0.6.0 for the initial <span class="caps">MPD</span> connection (connect
command), then the socket is put in blocking mode with no timeout. Its value is
set in musicpd.CONNECTION_TIMEOUT at module level (overridden by MPD_TIMEOUT
environment variable following <a href="https://mpd.readthedocs.io/en/latest/client.html"><span class="caps">MPD</span> recommendations</a>).</p>
<p>Latest commit <a href="https://gitlab.com/kaliko/python-musicpd/-/commit/0c16ca07">0c16ca07</a>
added the possibility to set a socket timeout for the next call/response to <span class="caps">MPD</span>
after the initial connect.</p>
<p>This is not released yet. Please test if you are using this module as part of
your projects. The sphinx documentation is up-to-date, not online though, <a href="https://kaliko.gitlab.io/python-musicpd/index.html#build-documentation">need
to be build</a>.</p>
<p><a href="https://kaliko.me/extra/musicpd-timeout-socket.py">Here are some lines of python</a> to
test the feature using <a href="https://docs.python.org/3/library/select.html#select.select">select.select</a>.</p>
<p>Happy Music Player Daemon hacking with python 🐍 :)<br>
Happy listening 🎶!</p>python-musicpd 0.6.02021-05-28T00:00:00+02:002021-05-28T00:00:00+02:00kalikotag:kaliko.me,2021-05-28:/posts/2021/05/python-musicpd-060/<p>Releasing python-musicpd 0.6.0</p><p>This release adds <a href="https://mpd.readthedocs.io/en/stable/user.html#client-connections">abstract unix
socket</a>
support, new commands (binarylimit and getvol).</p>
<p><a href="https://mpd.readthedocs.io/en/latest/client.html#environment-variables"><code>MPD_TIMEOUT</code></a>
environment variable is now used and the default connection timeout is 30s (previously 5s).</p>
<ul>
<li>python-musicpd 0.6.0 is available <a href="https://pypi.org/project/python-musicpd/">on pypi</a>.</li>
<li><a href="https://kaliko.gitlab.io/python-musicpd">Documentation</a></li>
</ul>
<p>Happy Music Player Daemon hacking with python :)</p>MPD_sima 0.16.12021-01-09T00:00:00+01:002021-01-09T00:00:00+01:00kalikotag:kaliko.me,2021-01-09:/posts/2021/01/sima-0.16.1/<p>MPD_sima 0.16.1 Release</p><p><a href="https://kaliko.me/mpd-sima">MPD_sima</a> v0.16.1 is available.</p>
<p>The package is available on <a href="https://pypi.org/project/MPD-sima/0.16.1/">pypi.org</a>
and tagged 0.16.1 in git:</p>
<div class="highlight"><pre><span></span><code>pip install MPD-sima<span class="o">==</span><span class="m">0</span>.16.1
<span class="c1"># Or from git</span>
pip install git+https://gitlab.com/kaliko/sima.git@0.16.1#egg<span class="o">=</span>MPD-sima
</code></pre></div>
<h2>Main changes</h2>
<p>For changes in 0.16.0 look at <a href="https://kaliko.me/posts/2020/12/sima-0.16.0/">the previous post</a>.</p>
<p>With 0.16.1 there were some important internal plumbing changes in the plugin
system, but no major changes from the user point of view, hence the point release.</p>
<p>These changes allow to share some logic/code between last.fm and tags plugin
(searching/fetching artists/albums). Then the tags plugin introduced in 0.16.0
can now queue whole album instead of single tracks.</p>
<p>Now to listen to the last 30 years of hardcore albums in your music library:</p>
<div class="highlight"><pre><span></span><code><span class="k">[tags]</span><span class="w"></span>
<span class="na">queue_mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">album</span><span class="w"></span>
<span class="na">genre</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Hardcore</span><span class="w"></span>
<span class="na">filter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">(date =~ '(199[0-9]+|20[0-9]+)')</span><span class="w"></span>
<span class="na">album_to_add</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">2</span><span class="w"></span>
</code></pre></div>
<p>Please report issue on gitlab: <a href="https://gitlab.com/kaliko/sima/-/issues">gitlab.com/kaliko/sima/-/issues</a></p>
<p>Happy listening<br> k</p>MPD_sima 0.16.02020-12-16T00:00:00+01:002021-01-09T00:00:00+01:00kalikotag:kaliko.me,2020-12-16:/posts/2020/12/sima-0.16.0/<p>MPD_sima 0.16.0 Release</p><p><a href="https://kaliko.me/mpd-sima">MPD_sima</a> v0.16.0 is available.</p>
<p>The package is available on <a href="https://pypi.org/project/MPD-sima/0.16.0/">pypi.org</a>
and tagged 0.16.0 in git:</p>
<div class="highlight"><pre><span></span><code>pip install MPD-sima<span class="o">==</span><span class="m">0</span>.16.0
<span class="c1"># Or from git</span>
pip install git+https://gitlab.com/kaliko/sima.git@0.16.0#egg<span class="o">=</span>MPD-sima
</code></pre></div>
<h2>Main changes</h2>
<h3>Python 3.6</h3>
<p>This release needs ate least python 3.6.</p>
<h3>New offline autoqueue plugin</h3>
<p>The new <strong>Tags</strong> plugin allows offline autoqueuing (no request to external
service to find similarities). This is the first early release of this plugin,
it still needs some polishing, please be kind and report issues if needed :)</p>
<p>The plugin relies on tags to find similar tracks. Available tags are ‘comment’,
‘date’, ‘genre’, ‘label’ and ‘originaldate’. This queue mode is static though,
once you configured a set of tag to look for MPD_sima will queue tracks
according to these tags only.</p>
<p>For instance, assuming you want to listen to <strong>Rock</strong> from the last century, here is the config for the plugin:</p>
<div class="highlight"><pre><span></span><code><span class="c1"># mpd_sima.cfg</span><span class="w"></span>
<span class="na">...</span><span class="w"></span>
<span class="k">[tags]</span><span class="w"></span>
<span class="na">genre</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Rock, Hard Rock, Punk Rock</span><span class="w"></span>
<span class="na">date</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990</span><span class="w"></span>
</code></pre></div>
<p>This will look for tracks tags with one of the genre set <strong>and</strong> one of the year set in date :<br>
In pseudo code:</p>
<div class="highlight"><pre><span></span><code>track.genre in [ "Rock", "Hard Rock", "Punk Rock" ]
AND
track.date in [ 1980,1981,1982,1983,1984,1985,1986,1987,1988,1989 ]
</code></pre></div>
<p>In addition to supported tag above, you can use <a href="https://www.musicpd.org/doc/html/protocol.html#filters"><span class="caps">MPD</span>
filter</a> as well.</p>
<p>It allows using any tags <span class="caps">MPD</span> exposes and to write more concise expression. For
instance for the example above you can configure the plugin with this filter:</p>
<div class="highlight"><pre><span></span><code><span class="c1"># mpd_sima.cfg</span><span class="w"></span>
<span class="na">...</span><span class="w"></span>
<span class="k">[tags]</span><span class="w"></span>
<span class="na">genre</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Rock, Hard Rock, Punk Rock</span><span class="w"></span>
<span class="na">filter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">( date =~ '198[0-9]+' )</span><span class="w"></span>
</code></pre></div>
<p>An interesting feature with filters is the availability to query extra metadata
like <strong>duration</strong>, <strong>AudioFormat</strong> or <strong>Last-Modified</strong>. For example you queue files modifed
since december 2020 :</p>
<div class="highlight"><pre><span></span><code><span class="k">[tags]</span><span class="w"></span>
<span class="na">filter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">(modified-since '2020-12-01')</span><span class="w"></span>
</code></pre></div>
<p>Testing the plugin configuration is possible with the new executable <code>test-tags-config</code>. Testing your config in <em>/etc/mpd-sima.cfg</em> :</p>
<div class="highlight"><pre><span></span><code>test-tags-config /etc/mpd-sima.cfg
Filter forged: <span class="s2">"((date =~ '199[0-9]+') AND (genre =~ '(Rock|Hardcore|Punk)'))"</span>
<span class="o">{</span><span class="s1">'Swans'</span>, <span class="s1">'Metallica'</span>, <span class="s1">'The Business'</span>, <span class="s1">'The Ejected'</span>, <span class="s1">'Raised Fist'</span>, <span class="s1">'Catharsis'</span>, <span class="s1">'The</span>
<span class="s1">Jesus Lizard'</span>, <span class="s1">'Nada Surf'</span>, <span class="s1">'Mogwai'</span>, <span class="s1">'Jeff Buckley'</span>, <span class="s1">'blink‐182'</span>, <span class="s1">'Korn'</span>, <span class="s1">'Faith No More'</span>,
<span class="s1">'Mr. Bungle'</span>, <span class="s1">'Dodgy'</span>, <span class="s1">'Beck'</span>, <span class="s1">'Soundgarden'</span>, <span class="s1">'Pennywise'</span>, <span class="s1">'Filter'</span>, <span class="s1">'Kyuss'</span>, <span class="s1">'Bad Religion'</span>,
<span class="s1">'Neurosis'</span>, <span class="s1">'Slaughter and The Dogs'</span>, <span class="s1">'GunsN’ Roses'</span>, <span class="s1">'Jimmy Page & Robert Plant'</span>,
<span class="s1">'The Posies'</span>, <span class="s1">'Menace'</span>, <span class="s1">'Body Count'</span>, <span class="s1">'The Smashing Pumpkins'</span>, …<span class="o">}</span>
</code></pre></div>
<h3><span class="caps">MPD</span> client refactoring</h3>
<p>The refactoring will hopefully make the client catch more artists (looking for
last.fm artists in the local music library). It should also behave better in
album mode. Finally the top track mode is also faster (new cache system
speeding up the loop).</p>
<p>Please report issue on gitlab: <a href="https://gitlab.com/kaliko/sima/-/issues">gitlab.com/kaliko/sima/-/issues</a></p>
<p>Happy listening<br> k</p>MPD_sima 0.16.0.dev02020-05-16T00:00:00+02:002020-05-16T00:00:00+02:00kalikotag:kaliko.me,2020-05-16:/posts/2020/05/sima-0.16.0.dev0/<p>MPD_sima 0.16.0.dev0 Development Release</p><p>I just released development version of <a href="https://kaliko.me/mpd-sima">MPD_sima</a>. It’s purpose is to test the
major <span class="caps">MPD</span> client refactoring and spot potential regressions.</p>
<p>The package is available on <a href="https://pypi.org/manage/project/MPD-sima/release/0.16.0.dev0/">pypi.org</a>
and as a dev release tagged 0.16.0.dev0 in git:</p>
<div class="highlight"><pre><span></span><code>pip install MPD-sima<span class="o">==</span><span class="m">0</span>.16.0.dev0
<span class="c1"># Or from git</span>
pip install git+https://gitlab.com/kaliko/sima.git@0.16.0.dev0#egg<span class="o">=</span>MPD-sima
</code></pre></div>
<p>Please report issue on gitlab: <a href="https://gitlab.com/kaliko/sima/-/issues">gitlab.com/kaliko/sima/-/issues</a></p>
<p>The refactoring will hopefully make the client catch more artists (looking for
last.fm artists in the local music library). It should also behave better in
album mode. Finally the top track mode is also faster (new cache system
speeding up the loop).</p>
<p>Happy listening<br> k</p>XMPP bot2020-05-03T00:00:00+02:002020-05-04T00:00:00+02:00kalikotag:kaliko.me,2020-05-03:/posts/2020/05/sid/<p>Releasing a python <span class="caps">XMPP</span> bot</p><p><a href="https://kaliko.me/sid">I’ve revived an <span class="caps">XMPP</span> bot</a> forgotten in my git
repo. It was written back in 2010 fork of another xmpp bot (cf. sid/sid.py for
copyrights). The xmpp client is built on top of <a href="https://slixmpp.readthedocs.io/">slixmpp</a> an async xmpp module.</p>
<p>It was originally written for the Debian chat room at <a href="https://chat.jabberfr.org/">jabberfr</a>. It is still
its main purpose but can be extended for whatever suits you.
Check for the code on <a href="https://kaliko.me/sid">the project page</a>.</p>
<p>Current plugins:</p>
<ul>
<li>archive: show <strong>package versions</strong> in Debian archive</li>
<li>bts: deal with the <strong>Debian <a href="https://www.debian.org/Bugs/">bug tracking system</a></strong></li>
<li>echo: a <strong>poste restante</strong> service, leave a message to be re-delivered latter</li>
<li>feeds: monitors <strong>xml feeds</strong></li>
<li>ping: plain <strong>ping</strong></li>
</ul>
<p>The bot is still in development, you’ll need to write some python to configure/run it, it’s pretty simple though:</p>
<div class="highlight"><pre><span></span><code><span class="ch">#!/usr/bin/env python3</span>
<span class="kn">import</span> <span class="nn">getpass</span>
<span class="kn">from</span> <span class="nn">sid.sid</span> <span class="kn">import</span> <span class="n">MUCBot</span>
<span class="kn">from</span> <span class="nn">sid.ping</span> <span class="kn">import</span> <span class="n">Ping</span>
<span class="n">JID</span> <span class="o">=</span> <span class="s1">'bot@example.org'</span>
<span class="n">NICK</span> <span class="o">=</span> <span class="s1">'sid'</span>
<span class="n">PASS</span> <span class="o">=</span> <span class="n">getpass</span><span class="o">.</span><span class="n">getpass</span><span class="p">(</span><span class="s1">'Password for "</span><span class="si">{}</span><span class="s1">": '</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">JID</span><span class="p">))</span>
<span class="n">ROOM</span> <span class="o">=</span> <span class="s1">'room@conf.example.org'</span>
<span class="n">xmpp</span> <span class="o">=</span> <span class="n">MUCBot</span><span class="p">(</span><span class="n">JID</span><span class="p">,</span> <span class="n">PASS</span><span class="p">,</span> <span class="n">ROOM</span><span class="p">,</span> <span class="n">NICK</span><span class="p">)</span>
<span class="n">xmpp</span><span class="o">.</span><span class="n">register_bot_plugin</span><span class="p">(</span><span class="n">Ping</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">xmpp</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="n">xmpp</span><span class="o">.</span><span class="n">process</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span>
<span class="n">xmpp</span><span class="o">.</span><span class="n">shutdown_plugins</span><span class="p">()</span>
<span class="n">xmpp</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="s1">'Done'</span><span class="p">)</span>
</code></pre></div>
<p>Please refer to <a href="https://kaliko.me/sid">the dedicated page</a> for more. Happy hacking!</p>