use aspotify::{Client, ClientCredentials};
#[tokio::main]
async fn main() {
dotenv::dotenv().unwrap();
let client = Client::with_refresh(
ClientCredentials::from_env().unwrap(),
std::fs::read_to_string(".refresh_token").unwrap(),
);
let recent = client
.player()
.get_recently_played(50, None, None)
.await
.unwrap()
.data;
match recent {
Some(aspotify::TwoWayCursorPage { items, .. }) => {
println!("Play history:");
for item in items {
println!(
"{}: '{}' by {}",
item.played_at,
item.track.name,
item.track
.artists
.into_iter()
.map(|artist| artist.name)
.collect::<Vec<_>>()
.join(", ")
);
}
}
None => {
println!("Nothing in play history.");
}
}
}