X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;ds=sidebyside;f=sima%2Flib%2Fsimafm.py;h=5103aceac9455a9ac5d8a39e8fc10f5812151b3f;hb=a260ebea93f23d72aa6e0178744b0f64c469b7ba;hp=bd203f74f3330f1da06a0d7abd5d1f0c741e8a0b;hpb=37dd60538984a3917354b794a5c96b0a025f8e95;p=mpd-sima.git diff --git a/sima/lib/simafm.py b/sima/lib/simafm.py index bd203f7..5103ace 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 @@ -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,10 +76,10 @@ 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) @@ -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