spotify_private_api/
lib.rs

1//! Spotify private api library
2//!
3//! Supports adding, removing and moving of spotify folders/playlists
4//!
5//! # Examples
6//! ```no_run
7//! use spotify_private_api::Session;
8//!
9//! #[tokio::main]
10//! async fn main() {
11//!     let dc = "SP_DC".to_string();
12//!     let key = "SP_KEY".to_string();
13//!     let user_id = "USER_ID".to_string();
14//!
15//!     let s = Session::new(&dc, &key, &user_id)
16//!         .await
17//!         .expect("Failed to create session");
18//!
19//!     let root_list = s.get_root_list()
20//!         .await
21//!         .expect("failed to get root list");
22//!
23//!     let changes = root_list
24//!         .new_request()
25//!         .add("New Folder", &root_list.generate_folder_uri(), 0, 2)
26//!         .build();
27//!
28//!     s.send_changes(&changes)
29//!         .await
30//!         .expect("failed to send changes");
31//! }
32//! ```
33//!
34//! # How to generate dc and key (valid for 1 year)
35//! - Open a new Incognito window in your browser at and [login to spotify](https://accounts.spotify.com/en/login?continue=https:%2F%2Fopen.spotify.com%2F)
36//!  - Open Developer Tools in your browser (might require developer menu to be enabled in some browsers)
37//!  - In the Network tab, enable "Preserve log"
38//!  - Login to Spotify.
39//!  - In the Network tab, search/Filter for `password`
40//!  - Under cookies for the request save the values for `sp_dc` and `sp_key`.
41//!  - Close the window without logging out (Otherwise the cookies are made invalid).
42//!
43//! # How to get your user id
44//! - Click on your account name at the top right corner in the [spotify web player](https://open.spotify.com/)
45//! - Choose `Profile`
46//! - The last part of the link is your user id, e.g: `https://open.spotify.com/user/{user_id}`
47
48mod api;
49mod session;
50
51use std::error;
52
53pub type Session = session::Session;
54type Result<T> = std::result::Result<T, Box<dyn error::Error>>;