X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fsimafm.py;h=95f1c5a02f43fe4f22da0bcc626ad8b85b587333;hb=HEAD;hp=bd203f74f3330f1da06a0d7abd5d1f0c741e8a0b;hpb=37dd60538984a3917354b794a5c96b0a025f8e95;p=mpd-sima.git diff --git a/sima/lib/simafm.py b/sima/lib/simafm.py index bd203f7..95f1c5a 100644 --- a/sima/lib/simafm.py +++ b/sima/lib/simafm.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2009-2014 kaliko +# Copyright (c) 2009-2014, 2021 kaliko # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ Consume Last.fm web service """ -__version__ = '0.5.1' +__version__ = '0.5.2' __author__ = 'Jack Kaliko' @@ -61,7 +61,7 @@ class SimaFM: code = ans.get('error') mess = ans.get('message') if code == 6: - raise WSNotFound('{0}: "{1}"'.format(mess, self.artist)) + raise WSNotFound(f'{mess}: "{self.artist}"') raise WSError(mess) return True @@ -76,14 +76,14 @@ class SimaFM: payload = payloads.get(method) payload.update(api_key=LFM.get('apikey'), format='json') if not isinstance(artist, Artist): - raise TypeError('"{0!r}" not an Artist object'.format(artist)) + raise TypeError(f'"{artist!r}" not an Artist object') self.artist = artist if artist.mbid: - payload.update(mbid='{0}'.format(artist.mbid)) + payload.update(mbid=f'{artist.mbid}') else: payload.update(artist=artist.name, autocorrect=1) - payload.update(results=100) + payload.update(limit=100) if method == 'track': payload.update(track=track) # > hashing the URL into a cache key @@ -101,9 +101,9 @@ class SimaFM: ans = self.http(self.root_url, payload) try: ans.json() - except ValueError: + except ValueError as err: # Corrupted/malformed cache? cf. gitlab issue #35 - raise WSError('Malformed json, try purging the cache: %s') + raise WSError('Malformed json, try purging the cache: %s') from err self._controls_answer(ans.json()) # pylint: disable=no-member # Artist might be found but return no 'artist' list… # cf. "Mulatu Astatqe" vs. "Mulatu Astatqé" with autocorrect=0