spotify-random-saved-album

raw JSON →
0.0.8 verified Sat May 09 auth: no python

A CLI tool that retrieves a URL to a random album from a user's Spotify saved albums. Version 0.0.8 requires Python >=3.7, uses the Spotify Web API, and is released on PyPI. Development is sporadic.

pip install spotify-random-saved-album
error spotipy.exceptions.SpotifyException: http status: 400, code: -1 - Bad request: ...
cause Usually missing or invalid environment variables, or the redirect URI mismatch.
fix
Verify that SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, SPOTIPY_REDIRECT_URI are set and that the redirect URI is exactly as registered in the Spotify Developer Dashboard.
error ModuleNotFoundError: No module named 'spotify_random_saved_album'
cause Package not installed or wrong import path (hyphen vs underscore).
fix
Install with 'pip install spotify-random-saved-album' and import using underscores: 'from spotify_random_saved_album import get_random_album_url'.
gotcha The library expects SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, and SPOTIPY_REDIRECT_URI environment variables to be set; otherwise it raises a configuration error.
fix Set these environment variables before calling any function.
gotcha The redirect URI must match exactly one of the URIs registered in the Spotify Developer Dashboard (including localhost for local development).
fix Ensure SPOTIPY_REDIRECT_URI is registered in the Spotify Developer Dashboard for your app.

Import the function and call it after setting Spotify API credentials as environment variables.

from spotify_random_saved_album import get_random_album_url
import os

# Requires SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, SPOTIPY_REDIRECT_URI env vars
url = get_random_album_url()
print(url)