Skip to main content

Downloads songs from Spotify My Musicor Spotify Playlist that you provide

Project description

spotify_dl

Downloads songs from any Spotify playlist or from your “My Music” collection.

Tell me more!

I wanted an easy way to grab the songs present in my library so I can download it & use it offline(Spotify still hasn’t launched here. Y U NO COME?). spotify_to_mp3 worked well but it relied on grooveshark, which unfortunately is no more.

So I wrote this script which mimics that library, but instead of downloading from grooveshark, it provides you with a file of youtube URLs which you can then plug into youtube-dl

How do I get this thing running?

Pre-requisite: You need Python 3+

  1. Install using pip sudo pip3 install spotify_dl (use pip if your distro natively provides Python 3)

  2. Create your Spotify app & fetch the client id and client secret from Spotify Developer Console. These keys then need to be assigned as SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET and SPOTIPY_REDIRECT_URI environment variables.

    You can set environment variables in Linux like so:

    export SPOTIPY_CLIENT_ID='your-spotify-client-id'
    export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
    export SPOTIPY_REDIRECT_URI='your-app-redirect-url'

    Windows users, check for this question for details on how you can set environment variables.

    Note the redirect URL can be a valid URL, just ensure it matches with what you have entered in the developer console & in the environment variable above.

  3. Create your YouTube API key & fetch the keys from Google Developer Console. Set the key as YOUTUBE_DEV_KEY environment variable as mentioned above.

  4. Run the script using spotify_dl. spotify_dl accepts different parameters, for more details run spotify_dl -h. For most users spotify_dl -i spotify_URI -o download_directory should do where

  • spotify_URI is Spotify’s unique identifier. You can get it from the 3-dot menu.

image

image

If the Spotify URI is skipped then it will download songs from your “My Music” collection - download_directory is the location where the songs must be downloaded to. If you give a . then it will download to the current directory.

Alternatively, spotify_dl -p playlist_id -u user_name -o download_directory will also work

  • playlist_id is the id of the playlist where songs need to be downloaded. If this is skipped then it will download songs ftom your “My Music” collection

  • user_name is the user name who created the playlist.

  • download_directory is the location where the songs must be downloaded to.

  1. A first time run will require authentication; you will need to click on the URL prompted to authenticate. Once logged in, paste the URL back in.

  2. To retrieve download songs as MP3, you will need to install ffmpeg.

  • Linux users can get them by installing libav-tools by using apt-get (sudo apt-get install -y libav-tools) or a package manager which comes with your distro

  • Windows users can download FFMPEG pre-built binaries from here. Extract the file using 7-zip to a foldrer and add the folder to your PATH environment variable

Credits

Issues, Feedback, Contact details

Feel free to raise any bugs/issues under Github issues. Pull requests are also more than welcome. You can reach me on twitter at [@sathyabhat](https://twitter.com/sathyabhat) or drop a mail sathya at sathyasays dot com

Project details


Download files

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

Source Distribution

spotify_dl-2.1.1.zip (14.8 kB view details)

Uploaded Source

Built Distributions

spotify_dl-2.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

spotify_dl-2.1.1-py2.py3-none-any.whl (11.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file spotify_dl-2.1.1.zip.

File metadata

  • Download URL: spotify_dl-2.1.1.zip
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for spotify_dl-2.1.1.zip
Algorithm Hash digest
SHA256 0f673eff5b4ff87877b020397bee2ab699b56ef464545bbbf2c127d42e3fab03
MD5 1af0f0db0db6d5dd8e6858ff35344b64
BLAKE2b-256 4e25e3162d2010c46d1e8ca9a1c85c991621dcb416aee12779ed50f839336f12

See more details on using hashes here.

File details

Details for the file spotify_dl-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for spotify_dl-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1350342761d49702928fcd090960c4103a98c2e0ac61f68dea418af0ba5c6076
MD5 88d8e144e97057180155633957cdce05
BLAKE2b-256 2a3a6de0de99897ea2106216f8e698972528fc8bd883ccb4b2ccd01fb9963e53

See more details on using hashes here.

File details

Details for the file spotify_dl-2.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for spotify_dl-2.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7c1c7a70ff2e155141603396ac07f43081d066e972a16e68a3d9d2eb7c97ff8b
MD5 c5ed98868a0aaedfaa6d68eafe0b91aa
BLAKE2b-256 0d8180286b2178fa4ea3558586281fe18648dc0cc5b3bb0868c1c6fce9c2932d

See more details on using hashes here.

Supported by

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