Code Monkey home page Code Monkey logo

spotify-dl's Introduction

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

    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.
  5. 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.

  6. To retrieve download songs as MP3, you will need to install ffmpeg. If you prefer to skip MP3 conversion, pass -m or --skip_mp3 as a parameter when running the script

  • 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 or drop a mail sathya at sathyasays dot com

spotify-dl's People

Contributors

avinassh avatar bryant1410 avatar doulwyi avatar johnnysedor avatar kracekumar avatar mr-karan avatar rhnvrm avatar sathyabhat avatar shantanugoel avatar sildur avatar tocttou avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.