#spotify #download #song #account #mp3 #lib #spotifydownloader

spotify_dl_lib

A rust library which allows you to download spotify songs if you have a premium account

3 unstable releases

new 0.2.1 Jun 17, 2024
0.2.0 Jun 17, 2024
0.1.0 May 25, 2024

#123 in Audio

Download history 152/week @ 2024-05-20 23/week @ 2024-05-27 4/week @ 2024-06-03

179 downloads per month

MIT and maybe LGPL-3.0

41KB
952 lines

spotify-dl-lib

A rust library which allows you to download spotify songs if you have a premium account

Features

  • Download tracks, albums, and playlists
  • Supports mp3 (enable the mp3 feature) and flac format
  • Configurable download concurrency and compression (compression only applies to flac!)

How to use this library

get your spotify username (your username is not your display name) and password ready

in case you do not know how to get your spotify username here is a quick tutorial

  1. spotify_screenshot_1
  2. spotify_Screenshot_2
  3. and now you should have your spotify profile url in your clipboard, in my case, this is my profile url: https://open.spotify.com/user/xfvf8ol1ezj9bv5la7ty0vzut?si=8a8b7c4b7c5746df
  4. this is the important part we need from the url: xfvf8ol1ezj9bv5la7ty0vzut, save this for later

if your application uses a UI, a websocket server is exposed at ws://127.0.0.1:4040 :)) an example project will be very soon coming on my github which uses this websocket :D

example

use spotify_dl_lib::SpotifyDownloader;

#[tokio::main]
async fn main() {
    let username = "your username here";
    let password = "your spotify password here";

    let output_folder = PathBuf::from("./spotify-dl-data")

    //first argument is the name of the folder, where your mp3 files will be dropped (folder will be created in your home dir)
    let spotify_dl = SpotifyDownloader::new(&output_folder, &username, &password).await.unwrap();

    //download a playlist, album or track!
    let tracks_to_dl = vec![
       "https://open.spotify.com/playlist/7lzJ7tSe2N6Cvbsjto4lrq?si=09e7c2f655a840c5".to_string()
    ];


    /*
    download the tracks
    (2nd argument = parallelism of how many files can be downloaded concurrently (default value is 5 if None))
    (3rd argument = compression rate (only for flac format), lower = faster! higher = takes longer due of more processing (default value is 4 if None)
    (4th argument = file format, yea the output of your file bruh (only flac and mp3 are supported at the moment)
    */
    spotify_dl.download_tracks(tracks_to_dl, None, None, "mp3").await.unwrap();

    println!("download finished!");

}

Important!!

Using this project is against Spotifys ToS, use it at your own risk. I am not responsible for any damanges/limitations caused to your Spotify Account.

Credits

This project was only possible due of the existence of this amazing project <3 much love to all of you. If you are looking for a CLI solution for just downloading spotify tracks, stick to the mentioned project instead.

Dependencies

~34–51MB
~803K SLoC