feat: show total LB play count on artist detail page
Added GetArtistPlayCount(mbid) — fetches ArtistPopularity from LB for a single MBID and returns the total listen count. Fire-and-forget call on the artist page, displays below the meta line as '1.3M plays on ListenBrainz' (uses existing formatListenCount).
This commit is contained in:
@@ -224,6 +224,17 @@ func (e *Service) SimilarArtists(artistMBID string) ([]LBSimilarArtist, error) {
|
||||
return e.lb.SimilarArtists(e.ctx, artistMBID)
|
||||
}
|
||||
|
||||
// GetArtistPlayCount returns the total LB listen count for an artist.
|
||||
// Returns 0 if unknown.
|
||||
func (e *Service) GetArtistPlayCount(artistMBID string) int {
|
||||
pop, err := e.lb.ArtistPopularity(e.ctx, []string{artistMBID})
|
||||
if err != nil || len(pop) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
return pop[artistMBID]
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Cover Art Archive
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user