X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fplugins%2Finternal%2Flastfm.py;h=457deb564a38e58b67e0f45990cbf49d15a22104;hb=2b3bf3f5cef4ed9ff9e418b27194d89ca7e66b67;hp=2e6fca6b7fdc3c008a41b650338050ae78643484;hpb=24993cd99b847733894f57fd004ed52b5390244a;p=mpd-sima.git diff --git a/sima/plugins/internal/lastfm.py b/sima/plugins/internal/lastfm.py index 2e6fca6..457deb5 100644 --- a/sima/plugins/internal/lastfm.py +++ b/sima/plugins/internal/lastfm.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, 2014 Jack Kaliko +# Copyright (c) 2013, 2014, 2020 kaliko # # This file is part of sima # @@ -22,12 +22,15 @@ Fetching similar artists from last.fm web services """ # standard library import +from os.path import join # third parties components # local import from ...lib.simafm import SimaFM from ...lib.webserv import WebService +from ...lib.cache import FileCache +from ...lib.http import CacheController class Lastfm(WebService): @@ -36,7 +39,15 @@ class Lastfm(WebService): def __init__(self, daemon): WebService.__init__(self, daemon) - self.ws = SimaFM + # Set persitent cache + vardir = daemon.config['sima']['var_dir'] + persitent_cache = daemon.config.getboolean('lastfm', 'cache') + if persitent_cache: + CacheController.CACHE_ANYWAY = True + self.log.debug('Persistant cache enabled in %s', + join(vardir, 'http', 'LastFM')) + SimaFM.cache = FileCache(join(vardir, 'http', 'LastFM')) + self.ws = SimaFM() # VIM MODLINE