Skip to main content

spoti-dl: download songs, albums and playlists using Spotify links

Project description

spoti-dl

Downloads Downloads

Introduction

spoti-dl(I had a better name but that was already taken on PyPi), is a song downloader app that accepts Spotify links, fetches songs and and their albums' information from Spotify, downloads the song from Youtube. The metadata is then written onto the downloaded song file, including the album art cover.

It supports downloading songs, albums and playlists as podcast episodes cannot be reliably downloaded through Youtube.

Version 2.0.0 Update

The version 2.0.0 update introduces several improvements. I've shifted the app to be predominantly Rust-based, all core functionality is now written in Rust, which should result in about 20-25% performance imprvoement directly.

Albums and playlists are now downloaded in parallel, with 5 songs being downloaded in parallel by default. This has allowed for massive speedups - a 19-song album that earlier took about 115 seconds to download now took me roughly 25 seconds, that's more than a 4.5x speedup. You can get downloade faster if you increase the number of parallel downloads, by setting the -p flag. This fixes a big issue with the app which was the unreasonable download times for albums and playlists, which can easily have 500 or even 1000 songs.

I have also cleaned up the error messages, added error-logging to a file (~/.spotidl.log), color coded output messages and made several other minor improvmeents. All in all, the app should feel much better to use now :)

The main reason to use FFI with Rust was mostly just to code in Rust, and also get some extra performance out of the application. I have been enjoying Rust a lot lately and Python has always been nice to work with too.

Setup

Run pip install spoti-dl to install the app first and foremost.

spoti-dl needs two things to work: FFmpeg and a Spotify developer account.

Steps to make a Spotify developer account:

  1. Go to Spotify Dev Dashboard
  2. Login with your credentials and click on "create an app".
  3. Enter any name of choice, app description, tick the checkbox and proceed.
  4. Now you have access to your client ID. Click on "Show client secret" to get your client secret.
  5. From here, click on "edit settings" and in the "redirect URIs" section add any localhost URL. I personally use http://localhost:8080/callback

Finally, define these three environment variables:

SPOTIPY_CLIENT_ID
SPOTIPY_CLIENT_SECRET
SPOTIPY_REDIRECT_URI

Also note that the first time you run the app you might get a popup window in your browser asking to integrate your account to the app you just created in the Spotify app dashboard. Accept and close the window. The window will automatically close if you've already granted access to the app in the past.

Usage

Note: Please try updating yt-dlp through pip if encountering random download failures.

spoti-dl <spotify URL or URI> 

as an example, running either of the commands would download Rick Astley's 'Never Gonna Give You Up':

spoti-dl https://open.spotify.com/track/4PTG3Z6ehGkBFwjybzWkR8
spoti-dl spotify:track:4PTG3Z6ehGkBFwjybzWkR8

The following audio formats are supported:

  • mp3
  • flac
  • m4a
  • opus (default)

The following bitrates are supported:

  • best (default)
  • 320kbps
  • 256kbps
  • 192kbps (slightly better than Spotify's 'high' audio setting, this is the bare minimum in my opinion to have a good listening experience)
  • 96kbps
  • 32kbps
  • worst

Again, the following link types are supported:

  • song,
  • album, and
  • playlist links

Note: File names (audio files or folder names (eg., playlist's directory name)) are changed to ensure compatibility with the operating systems since many characters like '?' or the '/' are illegal when making files/folders in certain systems and are removed during the downloads.

Flags

Flag Long Flag Usage
-h --help shows all the argument flags and their details
-d --dir the save directory to use while downloading
-c --codec the codec to use for downloads
-b --bitrate set the bitrate to use for downloads
-t --track-number prepend downloaded song names with their track order number
-p --parallel-downloads maximum number of parallel song downloads
-v --version displays the current app version

TODO

  • add tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

spoti_dl-2.1.1-cp38-abi3-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.8+ Windows x86-64

spoti_dl-2.1.1-cp38-abi3-manylinux_2_31_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.31+ x86-64

spoti_dl-2.1.1-cp38-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

File details

Details for the file spoti_dl-2.1.1-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: spoti_dl-2.1.1-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for spoti_dl-2.1.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 bef0111f8d5abcfb078e355d230b315f42f895c8efc8bd72f2477277868e8423
MD5 51910fcaed5a28493f9b038307d14298
BLAKE2b-256 247ccf74f3768f79a83152dc0c3ea61b9be067eb9cd7211ab0349d3f78eb3248

See more details on using hashes here.

File details

Details for the file spoti_dl-2.1.1-cp38-abi3-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for spoti_dl-2.1.1-cp38-abi3-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 e76a896ccfde7abb43165bdbc759e8e3d1852d0e1e818b03e6bcc9f3b92e4afd
MD5 361787313d703797118a7da7450eb03f
BLAKE2b-256 24c6a07950e9492567139b309c8fe9e913faf48e19734fece91a2335d3da5cf6

See more details on using hashes here.

File details

Details for the file spoti_dl-2.1.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spoti_dl-2.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9738909a725cb18e3eaeaabc40243775158470e3e2afeef514f1459c6b18a463
MD5 9d717cdc3c6a7775aa359e22629c7a2b
BLAKE2b-256 8a246e830fe819f5347495e885bcda9bb38f0068d4cac77821de1a9197cbb389

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page