]> kaliko git repositories - mpd-sima.git/commitdiff
Add options for album mode (closes #28) issue_28
authorkaliko <kaliko@azylum.org>
Sun, 3 Nov 2019 17:17:05 +0000 (18:17 +0100)
committerkaliko <kaliko@azylum.org>
Sun, 3 Nov 2019 17:17:05 +0000 (18:17 +0100)
 * Allow limiting numbers of tracks to queue from an album
 * Allow shuffling album tracks

Thanks: sacha <sachahony@gmail.com>

data/man/mpd_sima.cfg.5.xml
doc/Changelog
doc/examples/all_settings.cfg
sima/lib/webserv.py
sima/utils/config.py

index 8481c4cf313b89bfb905fa26b460b9e47c13aade..678e4de0d39389fa89b8c1c4b28f7161b64f1167 100644 (file)
@@ -374,9 +374,7 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
                             <option>top</option> and <option>track</option>
                             queue modes. This is actually an upper limit,
                             min(<option>max_art</option>,
-                            <option>track_to_add</option>) will be used, and
-                            <option>max_art</option> might be inferior lower
-                            than value set in config.</para>
+                            <option>track_to_add</option>) will be used.</para>
                     </listitem>
                 </varlistentry>
                 <varlistentry> <!-- lastfm.album_to_add -->
@@ -386,6 +384,14 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
                             <option>album</option> queue modes.</para>
                     </listitem>
                 </varlistentry>
+                <varlistentry> <!-- lastfm.track_to_add_from_album -->
+                    <term><option>track_to_add_from_album=</option><replaceable>0</replaceable></term>
+                    <listitem>
+                        <para>How many track(s) to add from each selected albums. Only relevant in
+                          <option>album</option> queue modes. When set to 0 or lower the whole album is queued.
+                          </para>
+                    </listitem>
+                </varlistentry>
                 <varlistentry> <!-- lastfm.cache -->
                     <term><option>cache=</option><replaceable>True</replaceable></term>
                     <listitem>
index 69be666af4dbdcbff54c67fe85f36241df610874..6fd81251247bd6eb1cc35e731e874241ad09f3eb 100644 (file)
@@ -2,6 +2,8 @@ MPD_sima v0.15.2 UNRELEASED
 
  * Fixed sqlite sqlite3.OperationalError VACUUM Error
  cf. https://bugs.python.org/issue28518
+ * Add option to queue a chosen number of tracks from an album (closes #28)
+ * Add option to shuffle tracks in album mode (Thanks Sacha)
 
 -- kaliko jack <kaliko@azylum.org>
 
index a7203750c6d257e6fcb7cbbf299dec0fc6b17437..2551f34dd5573db344a214e7d3b432aab30605cf 100644 (file)
@@ -193,6 +193,19 @@ track_to_add = 1
 # description: how many albums the plugin will try to get
 album_to_add = 1
 
+## TRACK_TO_ADD_FROM_ALBUM
+# type: integer
+# scope: "album" queue mode
+# description: how many tracks from one album the plugin will try to get
+#              defaults to 0 to queue the whole album
+track_to_add_from_album = 0
+
+## SHUFFLE_ALBUM
+# type: boolean
+# scope: "album" queue mode
+# description: should the tracks of the album be shuffled
+shuffle_album = false
+
 ## CACHE
 # type: boolean
 # description: whether or not to use on-disk persistent http cache
index 2ff88d2224f7c59f7fb8b88296207bd9ff82a0b7..9800b92f32beca530b79502d13f65f5d45fceef0 100644 (file)
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
-# Copyright (c) 2009-2015 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2009-2019 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2019 sacha <sachahony@gmail.com>
 #
 #  This file is part of sima
 #
@@ -344,7 +345,15 @@ class WebService(Plugin):
                 continue
             self.log.info('%s album candidate: %s - %s', self.ws.name, artist, album_to_queue)
             nb_album_add += 1
-            self.to_add.extend(self.player.find_album(artist, album_to_queue))
+            candidates = self.player.find_album(artist, album_to_queue)
+            if self.plugin_conf.getboolean('shuffle_album'):
+                random.shuffle(candidates)
+            # this allows to select a maximum number of track from the album
+            # a value of 0 (default) means keep all
+            nbtracks = self.plugin_conf.getint('track_to_add_from_album')
+            if nbtracks > 0:
+                candidates = candidates[0:nbtracks]
+            self.to_add.extend(candidates)
             if nb_album_add == target_album_to_add:
                 return True
 
index b21b1f9597a2f9470fd7e72a4e16746cb8a5fdea..488eec15a1144c2a53f9711d54f6f8137c6d2b71 100644 (file)
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
-# Copyright (c) 2009, 2010, 2011, 2013, 2014, 2015 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2009, 2010, 2011, 2013, 2014, 2015, 2019 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2019 sacha <sachahony@gmail.com>
 #
 #  This file is part of sima
 #
@@ -57,7 +58,7 @@ DEFAULT_CONF = {
             'single_disable_queue': "true",
             'mopidy_compat': "false",
             },
-        'daemon':{
+        'daemon': {
             'daemon': False,
             'pidfile': "",
             },
@@ -70,17 +71,19 @@ DEFAULT_CONF = {
             'priority': 0,
             },
         'lastfm': {
-            'queue_mode': "track", #TODO control values
+            'queue_mode': "track",  # TODO control values
             'max_art': 10,
             'single_album': "false",
             'track_to_add': 1,
             'album_to_add': 1,
+            'shuffle_album': False,
+            'track_to_add_from_album': 0,  # <=0 means keep all
             'depth': 1,
             'cache': True,
             'priority': 100,
             },
         'random': {
-            'flavour': "sensible", # in pure, sensible
+            'flavour': "sensible",  # in pure, sensible
             'track_to_add': 1,
             'priority': 50,
             },