]> kaliko git repositories - mpd-sima.git/blob - sima/plugins/internal/lastfm.py
Get rid of inefficient log string formatting
[mpd-sima.git] / sima / plugins / internal / lastfm.py
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2013, 2014, 2020 kaliko <kaliko@azylum.org>
3 #
4 #  This file is part of sima
5 #
6 #  sima is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  sima is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with sima.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 #
20 """
21 Fetching similar artists from last.fm web services
22 """
23
24 # standard library import
25 from os.path import join
26
27 # third parties components
28
29 # local import
30 from ...lib.simafm import SimaFM
31 from ...lib.webserv import WebService
32 from ...lib.cache import FileCache
33 from ...lib.http import CacheController
34
35
36 class Lastfm(WebService):
37     """last.fm similar artists
38     """
39
40     def __init__(self, daemon):
41         WebService.__init__(self, daemon)
42         # Set persitent cache
43         vardir = daemon.config['sima']['var_dir']
44         persitent_cache = daemon.config.getboolean('lastfm', 'cache')
45         if persitent_cache:
46             CacheController.CACHE_ANYWAY = True
47             self.log.debug('Persistant cache enabled in %s', join(vardir, 'http', 'LastFM'))
48             SimaFM.cache = FileCache(join(vardir, 'http', 'LastFM'))
49         self.ws = SimaFM()
50
51
52 # VIM MODLINE
53 # vim: ai ts=4 sw=4 sts=4 expandtab