spotify_dl_lib

Crates.iospotify_dl_lib
lib.rsspotify_dl_lib
version0.3.21
sourcesrc
created_at2024-05-25 17:47:34.567424
updated_at2024-06-23 15:30:52.224284
descriptionA rust library which allows you to download spotify songs if you have a premium account
homepage
repositoryhttps://github.com/mari-rs/spotify-dl-lib
max_upload_size
id1252097
size42,484
Klover (klover-rs)

documentation

README

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, Some("ws://127.0.0.1:4040/ws".to_string())).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.

Commit count: 27

cargo fmt