lastfm
Platypush documentation
lastfm
- class platypush.plugins.lastfm.LastfmPlugin(api_key, api_secret, username, password)[source]
Bases:
Plugin
Plugin to interact with your Last.FM (https://last.fm) account, update your current track and your scrobbles.
Requires:
pylast (
pip install pylast
)
- __init__(api_key, api_secret, username, password)[source]
- Parameters:
api_key (str) – Last.FM API key, see https://www.last.fm/api
api_secret – Last.FM API secret, see https://www.last.fm/api
username – Last.FM username
password – Last.FM password, used to sign the requests
- get_recent_tracks(username: Optional[str] = None, limit: int = 10, time_from: Optional[int] = None, time_to: Optional[int] = None) List[dict] [source]
Get a list of recently played tracks.
- Parameters:
username – Target username (default: the one registered to this plugin).
limit – Maximum number of tracks to be returned (default: 10).
time_from – Return tracks starting from this time (as a UNIX timestamp).
time_to – Return tracks starting up to this time (as a UNIX timestamp).
- Returns:
Example:
[ { "artist": "Led Zeppelin", "title": "Stairway to Heaven", "album": "IV", "timestamp": 1654196137 } ]
- get_similar_tracks(artist: str, title: str, limit: Optional[int] = None) List[dict] [source]
Get the tracks that are similar to a specific track.
- Parameters:
artist – Track artist.
title – Track title.
limit – Maximum number of suggested tracks to be returned (default: None).
- Returns:
A list of similar tracks, each with a
match
score between 0 and 1. Example:[ { "artist": "Led Zeppelin", "title": "Black Dog", "score": 1.0 }, { "artist": "Led Zeppelin", "title": "Rock and Roll", "score": 0.89 }, { "artist": "Eagles", "title": "Hotel California", "score": 0.471 }, { "artist": "Deep Purple", "title": "Smoke on the Water", "score": 0.393 } ]
- get_track(artist: str, title: str) Optional[dict] [source]
Get the information about a track.
- Parameters:
artist – Track artist.
title – Track title.
- Returns:
The retrieved track, with the title corrected if required, if it exists on Last.FM. Example:
{ "artist": "Led Zeppelin", "title": "Stairway to Heaven", "tags": ["rock", "hard rock", "70s"] }