mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Fix examples
This commit is contained in:
parent
abbc3bade8
commit
2065ded7b6
3 changed files with 39 additions and 32 deletions
|
@ -1,8 +1,6 @@
|
|||
use std::env;
|
||||
|
||||
use librespot::core::authentication::Credentials;
|
||||
use librespot::core::config::SessionConfig;
|
||||
use librespot::core::session::Session;
|
||||
use librespot::core::{authentication::Credentials, config::SessionConfig, session::Session};
|
||||
|
||||
const SCOPES: &str =
|
||||
"streaming,user-read-playback-state,user-modify-playback-state,user-read-currently-playing";
|
||||
|
@ -17,14 +15,15 @@ async fn main() {
|
|||
return;
|
||||
}
|
||||
|
||||
println!("Connecting..");
|
||||
println!("Connecting...");
|
||||
let credentials = Credentials::with_password(&args[1], &args[2]);
|
||||
let session = Session::connect(session_config, credentials, None)
|
||||
.await
|
||||
.unwrap();
|
||||
let session = Session::new(session_config, None);
|
||||
|
||||
println!(
|
||||
"Token: {:#?}",
|
||||
session.token_provider().get_token(SCOPES).await.unwrap()
|
||||
);
|
||||
match session.connect(credentials).await {
|
||||
Ok(()) => println!(
|
||||
"Token: {:#?}",
|
||||
session.token_provider().get_token(SCOPES).await.unwrap()
|
||||
),
|
||||
Err(e) => println!("Error connecting: {}", e),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
use std::env;
|
||||
use std::{env, process::exit};
|
||||
|
||||
use librespot::core::authentication::Credentials;
|
||||
use librespot::core::config::SessionConfig;
|
||||
use librespot::core::session::Session;
|
||||
use librespot::core::spotify_id::SpotifyId;
|
||||
use librespot::playback::audio_backend;
|
||||
use librespot::playback::config::{AudioFormat, PlayerConfig};
|
||||
use librespot::playback::player::Player;
|
||||
use librespot::{
|
||||
core::{
|
||||
authentication::Credentials, config::SessionConfig, session::Session, spotify_id::SpotifyId,
|
||||
},
|
||||
playback::{
|
||||
audio_backend,
|
||||
config::{AudioFormat, PlayerConfig},
|
||||
player::Player,
|
||||
},
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
@ -25,10 +28,12 @@ async fn main() {
|
|||
|
||||
let backend = audio_backend::find(None).unwrap();
|
||||
|
||||
println!("Connecting ..");
|
||||
let session = Session::connect(session_config, credentials, None)
|
||||
.await
|
||||
.unwrap();
|
||||
println!("Connecting...");
|
||||
let session = Session::new(session_config, None);
|
||||
if let Err(e) = session.connect(credentials).await {
|
||||
println!("Error connecting: {}", e);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let (mut player, _) = Player::new(player_config, session, None, move || {
|
||||
backend(None, audio_format)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use std::env;
|
||||
use std::{env, process::exit};
|
||||
|
||||
use librespot::core::authentication::Credentials;
|
||||
use librespot::core::config::SessionConfig;
|
||||
use librespot::core::session::Session;
|
||||
use librespot::core::spotify_id::SpotifyId;
|
||||
use librespot::metadata::{Metadata, Playlist, Track};
|
||||
use librespot::{
|
||||
core::{
|
||||
authentication::Credentials, config::SessionConfig, session::Session, spotify_id::SpotifyId,
|
||||
},
|
||||
metadata::{Metadata, Playlist, Track},
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
@ -24,9 +25,11 @@ async fn main() {
|
|||
|
||||
let plist_uri = SpotifyId::from_base62(uri_parts[2]).unwrap();
|
||||
|
||||
let session = Session::connect(session_config, credentials, None)
|
||||
.await
|
||||
.unwrap();
|
||||
let session = Session::new(session_config, None);
|
||||
if let Err(e) = session.connect(credentials).await {
|
||||
println!("Error connecting: {}", e);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let plist = Playlist::get(&session, plist_uri).await.unwrap();
|
||||
println!("{:?}", plist);
|
||||
|
|
Loading…
Reference in a new issue