https://github.com/spiritualized/lastfmcache
Caching interface for last.fm, written in Python
https://github.com/spiritualized/lastfmcache
cache lastfm lastfm-api python python-library
Last synced: 4 months ago
JSON representation
Caching interface for last.fm, written in Python
- Host: GitHub
- URL: https://github.com/spiritualized/lastfmcache
- Owner: spiritualized
- Created: 2019-04-25T11:46:04.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2023-12-11T02:12:33.000Z (over 2 years ago)
- Last Synced: 2025-09-21T06:13:42.399Z (9 months ago)
- Topics: cache, lastfm, lastfm-api, python, python-library
- Language: Python
- Homepage:
- Size: 49.8 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lastfmcache
lastfmcache is a caching interface library for last.fm, written in Python. It meshes data retrieved from the API (via [pylast]([http://github.com/pylast])) with data retreived directly from the website.
Retrieved data is optionally cached in a local file, using sqlite.
This library bypasses several long-term unfixed issues with the last.fm API, including:
- Missing artist artwork
- Release date not populated
- Release tags not populated
- Certain release tags not populated on the API, others not populated on the website
- Track listing not available
## Usage
```
from lastfmcache import LastfmCache
lastfm_api_key = ""
lastfm_shared_secret = ""
lastfm = LastfmCache(lastfm_api_key, lastfm_shared_secret)
lastfm.enable_file_cache() # optional
artist = lastfm.get_artist("Pink Floyd")
release = lastfm.get_release("Pink Floyd", "Dark Side of the Moon")
top_releases = lastfm.get_top_user_releases("username")
```
### Artist class:
```
artist.artist_name: str
artist.listener_count: int
artist.play_count: int
artist.biography: str
artist.cover_image: str
artist.tags: OrderedDict[str, int] # tag -> weight
```
### Release class:
```
release_name: str
artist_name: str
release_date: datetime
listener_count: int
play_count: int
cover_image: str
has_cover_image: bool
tags = OrderedDict[str, int] # tag -> weight
tracks = OrderedDict[int, Track] # track number -> track
```
### Track class
```
track_number: int
track_name: str
artist_name: str
listener_count: int
```
### Top release class
```
index: int # ranking of the release
scrobbles: int
artist: str
title: str
```
## Installation
`pip install lastfmcache`