Spotube
Spotube is a Python package that allows the user to download local .mp3 copies of Spotify playlists, including cover art, artist information and lyrics.
Description
The package can be used to download Spotify playlists, retrieving and pairing each song with the cover art as seen on Spotify, as well as any relevant metadata. The user provides the link to a public Spotify playlist, optionally API keys for Spotify and Genius, and optionally the directory to save the downloaded songs. The application will then:
- Read each song in the playlist from Spotify, including the official name, artists, release date and album cover art.
- Using the song name and artist(s), search for, and select the most relevant song video on Youtube. If possible, the application will avoid remixes, covers and video clip versions.
- Using the most relevant link, download the video in the highest possible quality, and convert to .mp3 format.
- Query the LyricsGenius API to retrieve the song lyrics, if available.
- Edit the .mp3 tags of the downloaded song to set the artist and album information, add the lyrics and set the cover art.
- Optionally, normalize the volume level of all downloaded
.mp3files with ffmpeg, to even out volume differences between YouTube videos.
API keys (optional)
Spotube works without any API keys, but API keys can optionally be used to enable more features:
| Keys | Effect |
|---|---|
| None | Playlist read from Spotify's public playlist view (first 100 tracks, or all tracks with the Exportify extra below), no lyrics |
| Genius token (free) | Adds lyrics |
| Spotify client ID and secret | Reads playlists of any length through the official Spotify API. Spotify requires the account that owns the app to have an active Premium subscription; if the API refuses a request, Spotube falls back to the public view automatically |
To generate keys, see the Spotify Web API guide and the Genius API guide. Keep keys out of your source code, for example in environment variables.
Playlists over 100 tracks without keys
Without Spotify keys, Spotube can read playlists of any length through Exportify, using in your installed Microsoft Edge or Google Chrome. Install the optional extra:
pip install spotube[exportify]
Sign in to Spotify once. A browser window opens; log in and allow Exportify read access. The session is remembered, so later runs happen in the background. From the command line:
spotube login
Or from Python:
from spotube import DownloadManager
manager = DownloadManager()
manager.login_exportify()
After that, playlists that hit the 100-track limit are exported through Exportify automatically. The playlist must be in your Spotify library (meaning that it is either created by you, or followed); if it is not, Spotube downloads the first 100 tracks and tells you to follow it. To turn this off, pass --no-exportify on the command line or use_exportify=False to DownloadManager.
Dependencies
Spotube needs ffmpeg and ffprobe on your PATH. start_downloader raises FFmpegNotFoundError if they are missing.
| System | Command |
|---|---|
| Windows | winget install ffmpeg |
| macOS | brew install ffmpeg |
| Debian / Ubuntu | sudo apt install ffmpeg |
Alternatively, download a build from the ffmpeg downloads page and add its bin folder to your PATH.
Installation
To install the package using pip:
pip install spotube
Command Line
spotube download "https://open.spotify.com/playlist/..."
Songs are saved as Artist - Title.mp3 in ./Songs. Options:
| Option | Effect |
|---|---|
-o, --output DIR |
Save the songs in DIR |
-n, --limit N |
Only download the first N songs |
--no-normalize |
Skip volume normalization |
--no-exportify |
Never use Exportify, even for playlists over 100 tracks |
API keys are read from the GENIUS_ACCESS_TOKEN, SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET environment variables.
The exit code is 0 when every song downloaded, 1 when some failed or the download could not run, 2 for an invalid playlist link and 130 when cancelled with Ctrl+C.
Python API
Simple Use Case
Create a DownloadManager and call start_downloader with the link of a public Spotify playlist. The download runs in a background thread, and the songs are stored in ./Songs by default.
Without any keys:
from spotube import DownloadManager
manager = DownloadManager()
manager.start_downloader("https://open.spotify.com/playlist/...")
With keys, read from environment variables:
import os
from spotube import DownloadManager
manager = DownloadManager(
os.environ.get("SPOTIPY_CLIENT_ID"),
os.environ.get("SPOTIPY_CLIENT_SECRET"),
os.environ.get("GENIUS_ACCESS_TOKEN"),
)
manager.start_downloader("https://open.spotify.com/playlist/...")
Download Directory
You can set the directory to download the songs to, in one of two ways:
By passing the optional argument directory to the constructor:
manager = DownloadManager(directory="./Songs")
By setting the directory after the object has been created:
manager.set_directory("./Songs")
Stopping the Downloader
You can stop the download process using the cancel_downloader method:
manager.cancel_downloader()
This resets all download information, like the ETA and progress, and removes any half-downloaded files.
Validate Playlist URL
You can check whether a Spotify playlist URL is valid with validate_playlist_url:
manager.validate_playlist_url("https://open.spotify.com/playlist/...")
This returns True for a valid link, False otherwise.
Status Attributes
While a download runs, the manager updates the following attributes:
progress: the number of songs processed.total: the total number of songs in the playlist.success_counterandfailure_counter: songs downloaded and songs that failed.current_song: the title and main artist of the song being downloaded.eta: the estimated time remaining, in seconds.working:Truewhile a download or volume normalization is in progress.normalizingandnormalized_songs: whether volume normalization is running, and how many songs it has processed.
Disclaimer
Spotube is aimed strictly at personal use, as per the YouTube, Spotify and LyricsGenius license agreements. Sharing the content collected by using this application, or using it for profit is strictly prohibited. For more information, please read the LICENSE file included with this distribution.
Metadata
Release files for spotube 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spotube-0.6.0.tar.gz | 19.5 kB | Without provenance | Details for spotube-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spotube-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for spotube-0.6.0-py3-none-any.whl |
Total release size: 39.6 kB
Release files / spotube-0.6.0.tar.gz
| Download URL | spotube-0.6.0.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df586413663c935180cc5f47e190b3c710b739637b6ec8a47117a440db85fad7
|
|
BLAKE2b-256 checksum How to use checksums |
28c100eb57bf844a1d61498ca783a9555fbbda4fe91ab9d948bd2dc4dba4f682
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / spotube-0.6.0-py3-none-any.whl
| Download URL | spotube-0.6.0-py3-none-any.whl |
|---|---|
| Size | 20.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c062acd70a0b336cec254ecc1e0c289f3572183841597fbf5699a33add9fae0c
|
|
BLAKE2b-256 checksum How to use checksums |
d8d3292722814c01511310124d28f1f3faec11a8621d860ccf85e1754c7ced4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for spotube 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.