libMusicForge
Loading...
Searching...
No Matches
musicforge.analytics Namespace Reference

Provider-attributed track comparisons. More...

Classes

class  TrackStatisticsIf
 Contract for track statistics lookup. More...
class  TrackComparison
 Track listener and scrobble counts and derived ratio. More...

Functions

int|None _count (Sequence[Statistic] stats, str metric)
list[TrackComparison] compare_tracks (TrackStatisticsIf provider, Sequence[tuple[str, str]] tracks, *, str sort_by="listeners", bool descending=True)
 Compare track totals from Last.fm.

Detailed Description

Provider-attributed track comparisons.

Ratios describe Last.fm recorded listening, not global streaming popularity.

Function Documentation

◆ _count()

int | None musicforge.analytics._count ( Sequence[Statistic] stats,
str metric )
protected

◆ compare_tracks()

list[TrackComparison] musicforge.analytics.compare_tracks ( TrackStatisticsIf provider,
Sequence[tuple[str, str]] tracks,
* ,
str sort_by = "listeners",
bool descending = True )

Compare track totals from Last.fm.

Parameters
providerTrack statistics provider.
tracksSequence of artist/title pairs.
sort_bySort metric: listeners, scrobbles or ratio.
descendingWhether to sort known values in descending order.
Returns
Sorted comparisons with missing values last.

Uses sequential requests to avoid unnecessary API bursts. Missing values are kept as None, not silently converted to zero.