chore(discover): raise_for_status on Last.fm fetches
A 4xx/5xx (rate limit / auth) now raises instead of parsing an error body; callers already handle it (discovery per-source try/except; album fetch returns []). Closes the last small deferred cleanup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ class LastfmSource:
|
|||||||
params={"method": method, "api_key": self._key, "format": "json", **params},
|
params={"method": method, "api_key": self._key, "format": "json", **params},
|
||||||
timeout=self._timeout,
|
timeout=self._timeout,
|
||||||
)
|
)
|
||||||
|
res.raise_for_status() # a 4xx/5xx (rate limit, auth) → RequestException, handled by callers
|
||||||
return res.json()
|
return res.json()
|
||||||
|
|
||||||
def health(self) -> bool:
|
def health(self) -> bool:
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class LastfmAlbumPopularity:
|
|||||||
"api_key": self._key, "format": "json", "limit": str(self._limit),
|
"api_key": self._key, "format": "json", "limit": str(self._limit),
|
||||||
"autocorrect": "1",
|
"autocorrect": "1",
|
||||||
}, timeout=self._timeout)
|
}, timeout=self._timeout)
|
||||||
|
res.raise_for_status()
|
||||||
return _parse_top_albums(res.json())
|
return _parse_top_albums(res.json())
|
||||||
except Exception: # a Last.fm outage must never abort the sweep
|
except Exception: # a Last.fm outage must never abort the sweep
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user