2 releases
0.1.1 | Nov 13, 2019 |
---|---|
0.1.0 | Nov 13, 2019 |
#1191 in Audio
17KB
53 lines
spotify-genres-rs
Analysing spotify genres in a playlist
Building a histogram of used genres
Things you need to get started:
- Register a new application at Spotify's dashboard
- Get the
client_id
andclient_secret
- Get the playlist's
id
. You can find it it its uri: spotify:playlist:37i9dQZEVXbMDoHDwVN2tF
Example code
use spotify_genres::{auth_spotify, get_genres_for_playlist};
fn main() {
let top_50 = vec![
"37i9dQZEVXbMDoHDwVN2tF", // GLOBAL
"37i9dQZEVXbJiZcmkrIHGU", // GERMANY
"6VZ7JY80Iy1wy7GF076AMo", // NORWAY
];
let spotify = auth_spotify("id", "secret");
for playlist in top_50 {
if let Ok(res) = get_genres_for_playlist(&spotify, playlist) {
let str: Vec<String> = res.iter().map(|p| format!("{}: {}", p.0, p.1)).collect();
println!("{} -> {:#?}", playlist, str);
} else {
eprintln!("error in analysing: {}", playlist);
}
}
}
Dependencies
~26–38MB
~613K SLoC