spotifynews
raw JSON → 0.1.4 verified Sat May 09 auth: no python
A small Python library for fetching news about Spotify artists and playlists. Current version 0.1.4, released infrequently. It wraps the Spotify Web API and provides simple data structures for tracks, albums, and artists.
pip install spotifynews Common errors
error ModuleNotFoundError: No module named 'spotifynews' ↓
cause The library is not installed or the virtual environment is not activated.
fix
Run 'pip install spotifynews' and ensure you are in the correct virtual environment.
error AttributeError: 'NoneType' object has no attribute 'name' ↓
cause get_artist() returned None because the URI was incorrect or the artist was not found.
fix
Check that you are using a valid Spotify URI (e.g., 'spotify:artist:0TnOYISbd1XYRBk9myaseg').
error spotifynews.exceptions.SpotifyNewsError: Invalid client credentials ↓
cause Spotify client ID or client secret is missing or incorrect.
fix
Set environment variables SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET or pass them directly to the constructor.
Warnings
gotcha The library expects Spotify URIs (e.g., 'spotify:artist:...'), not Spotify IDs. Passing an ID may fail silently or return None. ↓
fix Always use full URIs like 'spotify:artist:...' or 'spotify:track:...'.
gotcha The library does not handle token refresh. Access tokens expire after 1 hour and the client does not automatically refresh, so long-running scripts may break. ↓
fix Reinitialize the client or manage token refresh manually using a separate Spotify API library.
deprecated The method 'get_new_releases' is deprecated in favor of 'get_spotify_new_releases' since v0.1.2. ↓
fix Use 'get_spotify_new_releases' instead.
gotcha The library does not validate playlist URIs. If you pass a malformed URI, it may raise an unhelpful AttributeError. ↓
fix Ensure URIs follow the format 'spotify:playlist:...' and are URL-encoded if necessary.
Imports
- SpotifyNews
from spotifynews import SpotifyNews
Quickstart
from spotifynews import SpotifyNews
import os
client = SpotifyNews(client_id=os.environ.get('SPOTIFY_CLIENT_ID', ''), client_secret=os.environ.get('SPOTIFY_CLIENT_SECRET', ''))
artist = client.get_artist('spotify:artist:0TnOYISbd1XYRBk9myaseg')
print(artist.name)