feat(discover): Last.fm album-popularity helper

LastfmAlbumPopularity.top_albums(conn, name) ranks an artist's albums by
Last.fm playcount (read-through ApiCache, 12h; errors -> []). registry
build_album_popularity returns it only when lastfm.api_key is set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-14 23:36:41 +02:00
parent a09093f798
commit efdd592761
3 changed files with 90 additions and 0 deletions
+8
View File
@@ -13,6 +13,7 @@ from lyra_worker.browser import MbBrowser
from lyra_worker.probe import AudioProbe
from lyra_worker.resolver import MbResolver
from lyra_worker.similarity._lastfm import LastfmSource
from lyra_worker.similarity._lastfm_albums import LastfmAlbumPopularity
from lyra_worker.similarity._listenbrainz import ListenBrainzSource
from lyra_worker.similarity.base import SimilaritySource
from lyra_worker.tagger import Tagger
@@ -67,3 +68,10 @@ def build_similarity_sources(config: dict, dsn: str | None = None) -> list[Simil
if key:
sources.append(LastfmSource(api_key=key, browser=build_browser(dsn)))
return sources
def build_album_popularity(config: dict, dsn: str | None = None):
"""Last.fm album-popularity provider for discovery, or None when no Last.fm key is set
(discovery then surfaces newest albums only)."""
key = config.get("lastfm.api_key")
return LastfmAlbumPopularity(api_key=key) if key else None