2020-08-25 21:13:46 +00:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
use librespot::core::authentication::Credentials;
|
|
|
|
use librespot::core::config::SessionConfig;
|
|
|
|
use librespot::core::keymaster;
|
|
|
|
use librespot::core::session::Session;
|
|
|
|
|
|
|
|
const SCOPES: &str =
|
|
|
|
"streaming,user-read-playback-state,user-modify-playback-state,user-read-currently-playing";
|
|
|
|
|
2021-03-06 00:29:08 +00:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
2020-08-25 21:13:46 +00:00
|
|
|
let session_config = SessionConfig::default();
|
|
|
|
|
|
|
|
let args: Vec<_> = env::args().collect();
|
|
|
|
if args.len() != 4 {
|
2021-03-06 00:29:08 +00:00
|
|
|
eprintln!("Usage: {} USERNAME PASSWORD CLIENT_ID", args[0]);
|
|
|
|
return;
|
2020-08-25 21:13:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
println!("Connecting..");
|
2021-03-06 00:29:08 +00:00
|
|
|
let credentials = Credentials::with_password(&args[1], &args[2]);
|
2022-05-20 10:53:44 +00:00
|
|
|
let (session, _) = Session::connect(session_config, credentials, None, false)
|
2021-04-01 16:10:42 +00:00
|
|
|
.await
|
|
|
|
.unwrap();
|
2020-08-25 21:13:46 +00:00
|
|
|
|
|
|
|
println!(
|
|
|
|
"Token: {:#?}",
|
2021-03-06 00:29:08 +00:00
|
|
|
keymaster::get_token(&session, &args[3], SCOPES)
|
|
|
|
.await
|
2020-08-25 21:13:46 +00:00
|
|
|
.unwrap()
|
|
|
|
);
|
|
|
|
}
|