summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4691849)
Fixed missing cache directory creation bug
Update documentation
# description: file to log to. Usually used in daemon mode.
# default: unset, logging to stdin/stdout
#logfile =
# description: file to log to. Usually used in daemon mode.
# default: unset, logging to stdin/stdout
#logfile =
## VERBOSITY
# type: string
## VERBOSITY
# type: string
# * warning
# * error
verbosity = info
# * warning
# * error
verbosity = info
#
#######################################################################
#
#######################################################################
# contrib = Scrobble, AwesomePlugin,
# ExperimentalTest, AnotherTest
# default:
# contrib = Scrobble, AwesomePlugin,
# ExperimentalTest, AnotherTest
# default:
+# internal = "Crop, Lastfm, RandomFallBack"
+# contrib =
# description: Plugins list declaration.
# Optional plugin's configuration must be in its own section.
# For instance a "AwesomePlugin" declared here
# description: Plugins list declaration.
# Optional plugin's configuration must be in its own section.
# For instance a "AwesomePlugin" declared here
# Two plugins sources are available, internal and contrib
#
internal = Crop, Lastfm, RandomFallBack
# Two plugins sources are available, internal and contrib
#
internal = Crop, Lastfm, RandomFallBack
## HISTORY_DURATION
# type: integer (in hours)
## HISTORY_DURATION
# type: integer (in hours)
# track/title
#
history_duration = 8
# track/title
#
history_duration = 8
## USER_DB # NOT IMPLEMENTED #
# type: boolean
# description: Load user database to find similar artists
## USER_DB # NOT IMPLEMENTED #
# type: boolean
# description: Load user database to find similar artists
-# User DB is loaded from $XDG_CONFIG_HOME/sima/sima.db
+# User DB is loaded from $XDG_CONFIG_HOME/mpd_sima/sima.db
# Use simadb_cli to edit/add entries.
user_db = false
# Use simadb_cli to edit/add entries.
user_db = false
-##
-
-#####################################################################
-# You do not need to set up options below.
-# But well, you got bored of the way sima is behaving, then go ahead
-# play with it :)
## QUEUE_LENGTH
# type: integer
# default: 1
# description: Queue length triggering tracks addition
queue_length = 1
## QUEUE_LENGTH
# type: integer
# default: 1
# description: Queue length triggering tracks addition
queue_length = 1
######################### PLUGINS #####################################
######################### PLUGINS #####################################
-#
-[placeholder]
-key = Value
# EchoNest or LastFM
#[echonest]
[lastfm]
# EchoNest or LastFM
#[echonest]
[lastfm]
-## QUEUE_MODE # NOT COMPLETED #
# type: string
# description: The default is to queue random tracks from similar artists.
# Possible values:
# track : Will queue tracks from similar artists (default).
# type: string
# description: The default is to queue random tracks from similar artists.
# Possible values:
# track : Will queue tracks from similar artists (default).
-# top : Will queue top tracks from similar artists. # NOT IMPLEMENTED #
+# top : Will queue top tracks from similar artists.
# album : Will queue whole album from similar artists.
queue_mode = track
# album : Will queue whole album from similar artists.
queue_mode = track
# description: how many albums the plugin will try to get
album_to_add = 1
# description: how many albums the plugin will try to get
album_to_add = 1
-#
-#######################################################################
+## CACHE
+# type: boolean
+# description: whether or not to use on-disk persistent http cache
+# * When set to "true", sima will use a persistent cache for its http client.
+# The cache is written along with the dbfile in:
+# $XDG_CONFIG_HOME/mpd_sima/http/<web_service>
+# Toggling http cache is only available for last.fm. EchoNest have rate limits,
+# we must then pay attention to bandwidth and use of caching is required.
+# * If set to "false", caching is still done but in memory.
+# default: True
+cache = True
#
####################### END OF CONFIGURATION ##########################
#
####################### END OF CONFIGURATION ##########################
self.forever = forever
if not os.path.isdir(self.directory):
self.forever = forever
if not os.path.isdir(self.directory):
- os.mkdir(self.directory)
+ os.makedirs(self.directory)
def encode(self, val):
return md5(val.encode('utf-8')).hexdigest()
def encode(self, val):
return md5(val.encode('utf-8')).hexdigest()
self.log.debug(repr(self.player.current))
return None
self.queue_mode()
self.log.debug(repr(self.player.current))
return None
self.queue_mode()
- self.log.debug(self.ws.stats)
+ msg = ' '.join(['{0}: {1:>3d}'.format(k, v) for
+ k, v in sorted(self.ws.stats.items())])
+ self.log.debug(msg)
candidates = self.to_add
self.to_add = list()
if self.plugin_conf.get('queue_mode') != 'album':
candidates = self.to_add
self.to_add = list()
if self.plugin_conf.get('queue_mode') != 'album':
# local import
from ...lib.simafm import SimaFM
from ...lib.webserv import WebService
# local import
from ...lib.simafm import SimaFM
from ...lib.webserv import WebService
-from ...lib.cache import FileCache
+from ...lib.cache import FileCache, DictCache
class Lastfm(WebService):
class Lastfm(WebService):
self.ws = SimaFM
# Set persitent cache
vardir = daemon.config['sima']['var_dir']
self.ws = SimaFM
# Set persitent cache
vardir = daemon.config['sima']['var_dir']
- SimaFM.cache = FileCache(join(vardir, 'http', 'LastFM'))
+ persitent_cache = daemon.config.getboolean('lastfm', 'cache')
+ if persitent_cache:
+ SimaFM.cache = FileCache(join(vardir, 'http', 'LastFM'))
+ else:
+ SimaFM.cache = DictCache()
'verbosity': "info",
'logfile': "",
},
'verbosity': "info",
'logfile': "",
},
+ 'crop': {
+ 'consume': 10,
+ },
'echonest': {
'queue_mode': "track", #TODO control values
'max_art': 15,
'echonest': {
'queue_mode': "track", #TODO control values
'max_art': 15,
'track_to_add': 1,
'album_to_add': 1,
'depth': 1,
'track_to_add': 1,
'album_to_add': 1,
'depth': 1,
},
'randomfallback': {
'flavour': "sensible", # in pure, sensible
},
'randomfallback': {
'flavour': "sensible", # in pure, sensible