diff --git a/cogs/lastfm.py b/cogs/lastfm.py index db74958..89d20dc 100644 --- a/cogs/lastfm.py +++ b/cogs/lastfm.py @@ -2381,6 +2381,11 @@ def playcount_mapped( output_start: int = 1, output_end: int = 100, ): + # if everything has the same playcount, give max points + # or else we will run into ZeroDivisionError + if input_start == input_end: + return output_end + score = (x - input_start) / (input_end - input_start) * ( output_end - output_start ) + output_start diff --git a/modules/lastfm.py b/modules/lastfm.py index a986d67..bd2e8d3 100644 --- a/modules/lastfm.py +++ b/modules/lastfm.py @@ -182,6 +182,11 @@ async def api_request(self, method: str, params: dict) -> dict: text = await response.text() raise exceptions.LastFMError(error_code=response.status, message=text) + if content is None: + raise exceptions.LastFMError( + error_code=response.status, message="Unknown error" + ) + error_code = content.get("error") if error_code: raise exceptions.LastFMError(