- request = dict({'similar': '?method=artist.getsimilar&artist=%s&' +\
- 'api_key={apikey}'.format(**LFM),
- 'top': '?method=artist.gettoptracks&artist=%s&' +\
- 'api_key={apikey}'.format(**LFM),
- 'track': '?method=track.getsimilar&artist=%s' +\
- '&track=%s' + 'api_key={apikey}'.format(**LFM),
- 'info': '?method=artist.getinfo&artist=%s' +\
- 'api_key={apikey}'.format(**LFM),
- })
- payloads = dict({'similar': {'method':'artist.getsimilar',
- 'artist':None, 'api_key':LFM.get('apikey'),},
- 'top': {'method':'artist.gettoptracks',
- 'artist':None, 'api_key':LFM.get('apikey'),},
- 'track': {'method':'track.getsimilar',
- 'artist':None, 'track':None,
- 'api_key':LFM.get('apikey'),},
- 'info': {'method':'artist.getinfo', 'artist':None,
- 'api_key':LFM.get('apikey'),},
- })
- cache = dict({})
- timestamp = datetime.utcnow()
- count = 0
-
- def __init__(self, artist=None, cache=True):
- self._url = None
- #SimaFM.count += 1
- self.current_element = None
- self.caching = cache
- self.purge_cache()
-
- def _is_in_cache(self):
- """Controls presence of url in cache.
- """
- if self._url in SimaFM.cache:
- #print('already fetch {0}'.format(self.artist))
- return True
- return False