libMusicForge
Loading...
Searching...
No Matches
musicforge.providers.lastfm.LastFmAdapter Class Reference

Read-only Last.fm statistics provider. More...

Public Member Functions

None __init__ (self, *, str api_key, httpx.AsyncClient|None client=None)
 Initialize the configured instance.
Self __aenter__ (self)
 Enter the asynchronous context.
None __aexit__ (self, *object _exc)
 Exit the asynchronous context.
None aclose (self)
 Close the HTTP client if owned by this adapter.
list[Statistic] artist_statistics (self, str artist)
 Get global Last.fm listener and scrobble totals for an artist.
list[Statistic] track_statistics (self, str artist, str title)
 Get global Last.fm listener and scrobble totals for a track.

Protected Member Functions

dict[str, Any] _request (self, str method, **str params)

Protected Attributes

 _api_key = api_key
 _client = client or httpx.AsyncClient(timeout=15.0)
 _owns_client = client is None

Detailed Description

Read-only Last.fm statistics provider.

Provide an API key via configuration; never embed credentials in source. The client is closed only if the adapter created it.

Constructor & Destructor Documentation

◆ __init__()

None musicforge.providers.lastfm.LastFmAdapter.__init__ ( self,
* ,
str api_key,
httpx.AsyncClient | None client = None )

Initialize the configured instance.

Parameters
selfCurrent instance.
api_keyNonempty Last.fm API key.
clientOptional externally owned HTTP client.

Member Function Documentation

◆ __aenter__()

Self musicforge.providers.lastfm.LastFmAdapter.__aenter__ ( self)

Enter the asynchronous context.

Parameters
selfCurrent instance.
Returns
Current instance.

◆ __aexit__()

None musicforge.providers.lastfm.LastFmAdapter.__aexit__ ( self,
*object _exc )

Exit the asynchronous context.

Parameters
selfCurrent instance.
_excContext exit exception information.

◆ _request()

dict[str, Any] musicforge.providers.lastfm.LastFmAdapter._request ( self,
str method,
**str params )
protected

◆ aclose()

None musicforge.providers.lastfm.LastFmAdapter.aclose ( self)

Close the HTTP client if owned by this adapter.

Parameters
selfCurrent instance.

◆ artist_statistics()

list[Statistic] musicforge.providers.lastfm.LastFmAdapter.artist_statistics ( self,
str artist )

Get global Last.fm listener and scrobble totals for an artist.

Parameters
selfCurrent instance.
artistArtist name.
Returns
Available Last.fm artist listener and scrobble counts.

◆ track_statistics()

list[Statistic] musicforge.providers.lastfm.LastFmAdapter.track_statistics ( self,
str artist,
str title )

Get global Last.fm listener and scrobble totals for a track.

Parameters
selfCurrent instance.
artistArtist name.
titleTrack title.
Returns
Available provider-attributed track metrics.

Member Data Documentation

◆ _api_key

musicforge.providers.lastfm.LastFmAdapter._api_key = api_key
protected

◆ _client

musicforge.providers.lastfm.LastFmAdapter._client = client or httpx.AsyncClient(timeout=15.0)
protected

◆ _owns_client

musicforge.providers.lastfm.LastFmAdapter._owns_client = client is None
protected

The documentation for this class was generated from the following file: