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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user