.\" Title: mpd-sima
.\" Author: Jack Kaliko <kaliko@azylum.org>
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 06/10/2014
+.\" Date: 06/11/2014
.\" Manual: mpd-sima 0.12.0 User Manual
.\" Source: mpd-sima
.\" Language: English
.\"
-.TH "MPD\-SIMA" "1" "06/10/2014" "mpd-sima" "mpd-sima 0.12.0 User Manual"
+.TH "MPD\-SIMA" "1" "06/11/2014" "mpd-sima" "mpd-sima 0.12.0 User Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
-mpd-sima \- mpd\-sima will try to maintain some titles ahead in your play list following different policies\&.
+mpd-sima \- mpd\-sima will try to maintain some titles ahead in the queue following different policies\&.
.SH "SYNOPSIS"
.HP \w'\fBmpd\-sima\fR\ 'u
\fBmpd\-sima\fR [\fB\-\-daemon\fR] [\fB\-\-config=\fR\fIconf_file\fR] [\fB\-\-var_dir=\fR\fIvar_directory\fR] [\fB\-\-pid=\fR\fIpid_file\fR] [\fB\-\-log=\fR\fIlog_file\fR] [\fB\-\-log\-level=\fR\fIlog_level\fR] [\fB\-\-host=\fR\fImpd_host\fR] [\fB\-\-mpd_port=\fR\fImpd_port\fR]
the section called \(lqFILES\(rq) and finally command lines options are honored\&. For instance you can override default MPD_HOST set in defaults (localhost) or in your configuration file with
\fB\-S\ \&my_mpd_server\fR
option\&. For default configuration see
-the section called \(lqCONFIGURATION\(rq\&.
+the section called \(lqCONFIGURATION\(rq\&. See also environment variables special case for MPD host and port in
+the section called \(lqENVIRONMENT\(rq\&.
.SH "EXAMPLE"
.SS "Launch as a system service (d\(aemon)\&."
.PP
to set up configuration instead of looking for the default user configuration file\&.
.br
Default is to look for
-\fB$XDG_CONFIG_HOME/mpd_sima/mpd_sima\&.cfg\fR\&. Concerning this file see also
+\fB$XDG_CONFIG_HOME/mpd_sima/mpd_sima\&.cfg\fR\&.
+.br
+
+CLI option overrides any equivalent mentioned in configuration file, ie\&. launching mpd\-sima with \*(Aq\fB\-\-port\fR\*(Aq CLI option will ignore port setting in configuration file\&.
+.br
+
+For more details on configuration file cf\&.
+\fBmpd_sima.cfg\fR(5), see also
the section called \(lqFILES\(rq\&.
.br
-Pay attention: Because you load a specific configuration file from command line interface
-\fIdoes not mean\fR
-it will override others options pass to mpd_sima\&. In other words launching with
-\fB\-P 6666\fR
-will override port setting whatever the configuration file your using, default or command line specified\&.
+
.RE
.PP
\fB\-\-var_dir=\fR\fB\fIvar_directory\fR\fR
.RS 4
Default is to look for MPD server at localhost:6600 (or MPD_HOST/MPD_PORT env\&. var\&. if set)\&.
.sp
-The default behavior is to add one track, this track is to be chosen among titles from artists similar to the artist of the currently played track\&. MPD_sima will add one track when the play list is one track long\&.
+The default behavior is to add one track, this track is to be chosen among titles from artists similar to the artist of the currently played track\&. MPD_sima will add one track when the unplayed queue is one track long\&.
.sp
To change these defaults, use the configuration file
mpd_sima\&.cfg
</refmeta>
<refnamediv>
<refname>&dhpackage;</refname>
- <refpurpose>&dhpackage; will try to maintain some titles ahead in your play list following different policies.</refpurpose>
+ <refpurpose>&dhpackage; will try to maintain some titles ahead in the queue following different policies.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
command lines options are honored. For instance you can override
default MPD_HOST set in defaults (localhost) or in your configuration
file with <command>-S my_mpd_server</command> option. For default
- configuration see <xref linkend="configuration"/>.</para>
+ configuration see <xref linkend="configuration"/>. See also environment
+ variables special case for MPD host and port in <xref linkend="environment"/>.
+ </para>
</refsect1>
<refsect1 id="example">
<title>EXAMPLE</title>
<para>Verbosity in [debug,info,warning,error].<sbr />Default is to log info messages.</para>
</listitem>
</varlistentry>
- <varlistentry>
+ <varlistentry><!-- config -->
<term><option>-c <replaceable class="parameter">conf_file</replaceable></option></term>
<term><option>--config=<replaceable class="parameter">conf_file</replaceable></option></term>
<listitem>
- <para>Use the specific file <replaceable>conf_file</replaceable> to set up configuration instead of looking for the default user configuration file.<sbr />Default is to look for <envar>$XDG_CONFIG_HOME/mpd_sima/mpd_sima.cfg</envar>. Concerning this file see also <xref linkend="files"/>.<sbr />Pay attention: Because you load a specific configuration file from command line interface <emphasis>does not mean</emphasis> it will override others options pass to mpd_sima. In other words launching with <option>-P 6666</option> will override port setting whatever the configuration file your using, default or command line specified.</para>
+ <para>Use the specific file <replaceable>conf_file</replaceable> to set up
+ configuration instead of looking for the default user
+ configuration file.<sbr />Default is to look for
+ <envar>$XDG_CONFIG_HOME/mpd_sima/mpd_sima.cfg</envar>.<sbr />
+ CLI option overrides any equivalent mentioned in configuration file, ie. launching &dhutils; with '<option>--port</option>' CLI option will ignore port setting in configuration file.<sbr />
+ For more details on configuration file cf.
+ <citerefentry><refentrytitle>mpd_sima.cfg</refentrytitle>
+ <manvolnum>5</manvolnum></citerefentry>, see also <xref linkend="files"/>.<sbr />
+ </para>
</listitem>
</varlistentry>
<varlistentry> <!-- var_dir -->
this track is to be chosen among titles from
artists similar to the artist of the currently
played track. MPD_sima will add one track when the
- play list is one track long.</para>
+ unplayed queue is one track long.</para>
<para>To change these defaults, use the configuration file <filename>mpd_sima.cfg</filename></para>
</listitem>
</varlistentry>
.\" Title: mpd_sima.cfg
.\" Author: Jack Kaliko <kaliko@azylum.org>
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 06/10/2014
+.\" Date: 06/11/2014
.\" Manual: mpd-sima 0.12.0 User Manual
.\" Source: mpd-sima
.\" Language: English
.\"
-.TH "MPD_SIMA\&.CFG" "5" "06/10/2014" "mpd-sima" "mpd-sima 0.12.0 User Manual"
+.TH "MPD_SIMA\&.CFG" "5" "06/11/2014" "mpd-sima" "mpd-sima 0.12.0 User Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
-mpd_sima.cfg \- mpd\-sima will try to maintain some titles ahead in your play list following different policies\&. This manual document the configuration file for mpd\-sima\&.
+mpd_sima.cfg \- mpd\-sima will try to maintain some titles ahead in the queue following different policies\&. This manual document the configuration file for mpd\-sima\&.
.SH "DESCRIPTION"
.PP
This manual page documents briefly
.PP
\fBqueue_length=\fR\fI1\fR
.RS 4
-This value triggers queue process if the play list length is less than specified queue_length\&.
+This value triggers queue process if the queue length is less than specified queue_length\&.
.RE
.PP
\fBuser_db=\fR\fIfalse\fR
.PP
\fBconsume=\fR\fI0\fR
.RS 4
-How many played tracks to keep in the play list\&. Allow to maintain a fixed length play list\&. Set to 0 to keep all played tracks\&.
+How many played tracks to keep in the queue\&. Allow to maintain a fixed length queue\&. Set to 0 to keep all played tracks\&.
.RE
.SS "RandomFallback section"
.PP
.RE
.SH "QUEUE MODES"
.PP
-mpd\-sima offers different queue modes\&. All of them pick up tracks from artists similar to the one currently played\&.
+mpd\-sima offers different queue modes\&. All of them pick up tracks from artists similar to the last track in the queue\&.
.PP
mpd\-sima tries preferably to chose among unplayed artists or at least not recently played artist\&. Concerning track and album queue modes titles are chosen purely at random among unplayed tracks\&.
.PP
</refmeta>
<refnamediv>
<refname>&dhutils;</refname>
- <refpurpose>&dhpackage; will try to maintain some titles ahead in your play
- list following different policies. This manual document the
+ <refpurpose>&dhpackage; will try to maintain some titles ahead in the queue
+ following different policies. This manual document the
configuration file for &dhpackage;.</refpurpose>
</refnamediv>
<refsect1 id="description">
<varlistentry> <!-- sima.queue_length -->
<term><option>queue_length=</option><replaceable>1</replaceable></term>
<listitem>
- <para>This value triggers queue process if the play
- list length is less than specified
+ <para>This value triggers queue process if the queue
+ length is less than specified
queue_length.</para>
</listitem>
</varlistentry>
<varlistentry> <!-- crop.consume -->
<term><option>consume=</option><replaceable>0</replaceable></term>
<listitem>
- <para>How many played tracks to keep in the play list.
- Allow to maintain a fixed length play list.
+ <para>How many played tracks to keep in the queue.
+ Allow to maintain a fixed length queue.
Set to 0 to keep all played tracks.
</para>
</listitem>
<refsect1 id="queue_mode">
<title>QUEUE MODES</title>
<para>&dhpackage; offers different queue modes. All of them pick up
- tracks from artists similar to the one currently played.</para>
+ tracks from artists similar to the last track in the queue.</para>
<para>&dhpackage; tries preferably to chose among unplayed artists or
at least not recently played artist. Concerning track and album
queue modes titles are chosen purely at random among unplayed
configuration file change
internal database remains the same
* Temporarily removed userdb feature
+ * Base artist for similarity is the last track queued
-- kaliko jack <kaliko@azylum.org> UNRELEASED
"""
Retrieve similar artists from WebServive.
"""
- if artist is None:
- curr = self.player.current.__dict__
- name = curr.get('artist')
- mbid = curr.get('musicbrainz_artistid', None)
- current = Artist(name=name, mbid=mbid)
- else:
- current = artist
# initialize artists deque list to construct from DB
as_art = deque()
- as_artists = self.ws().get_similar(artist=current)
- self.log.debug('Requesting {1} for "{0}"'.format(current,
- self.ws.name))
+ as_artists = self.ws().get_similar(artist=artist)
+ self.log.debug('Requesting {1} for "{0}"'.format(artist,
+ self.ws.name))
try:
# TODO: let's propagate Artist type
[as_art.append(str(art)) for art in as_artists]
history = deque(self.history)
history.popleft()
depth = 0
- current = self.player.current
+ last_trk = self.player.playlist[-1]
extra_arts = list()
while depth < self.plugin_conf.getint('depth'):
if len(history) == 0:
break
trk = history.popleft()
if (trk.get_artist() in extra_arts
- or trk.get_artist() == current.get_artist()):
+ or trk.get_artist() == last_trk.get_artist()):
continue
extra_arts.append(trk.get_artist())
depth += 1
if not similar:
return ret_extra
ret_extra.extend(self.get_artists_from_player(similar))
- if current.artist in ret_extra:
- ret_extra.remove(current.artist)
+ if last_trk.artist in ret_extra:
+ ret_extra.remove(last_trk.artist)
return ret_extra
def get_local_similar_artists(self):
"""Check against local player for similar artists
"""
- current = self.player.current
- self.log.info('Looking for artist similar to "{0.artist}"'.format(current))
- similar = self.ws_similar_artists()
+ tolookfor = self.player.playlist[-1].get_artist()
+ self.log.info('Looking for artist similar '
+ 'to "{0.artist}"'.format(self.player.playlist[-1]))
+ similar = self.ws_similar_artists(tolookfor)
if not similar:
self.log.info('Got nothing from {0}!'.format(self.ws.name))
return []
def callback_need_track(self):
self._cleanup_cache()
- if not self.player.current:
- self.log.info('No current track, cannot queue')
+ if len(self.player.playlist) == 0:
+ self.log.info('No last track, cannot queue')
return None
- if not self.player.current.artist:
- self.log.warning('No artist set for the current track')
+ if not self.player.playlist[-1].artist:
+ self.log.warning('No artist set for the last track in queue')
self.log.debug(repr(self.player.current))
return None
self.queue_mode()