mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +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 std::env;
|
||||||
|
|
||||||
use librespot::core::authentication::Credentials;
|
use librespot::core::{authentication::Credentials, config::SessionConfig, session::Session};
|
||||||
use librespot::core::config::SessionConfig;
|
|
||||||
use librespot::core::session::Session;
|
|
||||||
|
|
||||||
const SCOPES: &str =
|
const SCOPES: &str =
|
||||||
"streaming,user-read-playback-state,user-modify-playback-state,user-read-currently-playing";
|
"streaming,user-read-playback-state,user-modify-playback-state,user-read-currently-playing";
|
||||||
|
@ -17,14 +15,15 @@ async fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Connecting..");
|
println!("Connecting...");
|
||||||
let credentials = Credentials::with_password(&args[1], &args[2]);
|
let credentials = Credentials::with_password(&args[1], &args[2]);
|
||||||
let session = Session::connect(session_config, credentials, None)
|
let session = Session::new(session_config, None);
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
println!(
|
match session.connect(credentials).await {
|
||||||
"Token: {:#?}",
|
Ok(()) => println!(
|
||||||
session.token_provider().get_token(SCOPES).await.unwrap()
|
"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::{
|
||||||
use librespot::core::config::SessionConfig;
|
core::{
|
||||||
use librespot::core::session::Session;
|
authentication::Credentials, config::SessionConfig, session::Session, spotify_id::SpotifyId,
|
||||||
use librespot::core::spotify_id::SpotifyId;
|
},
|
||||||
use librespot::playback::audio_backend;
|
playback::{
|
||||||
use librespot::playback::config::{AudioFormat, PlayerConfig};
|
audio_backend,
|
||||||
use librespot::playback::player::Player;
|
config::{AudioFormat, PlayerConfig},
|
||||||
|
player::Player,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
@ -25,10 +28,12 @@ async fn main() {
|
||||||
|
|
||||||
let backend = audio_backend::find(None).unwrap();
|
let backend = audio_backend::find(None).unwrap();
|
||||||
|
|
||||||
println!("Connecting ..");
|
println!("Connecting...");
|
||||||
let session = Session::connect(session_config, credentials, None)
|
let session = Session::new(session_config, None);
|
||||||
.await
|
if let Err(e) = session.connect(credentials).await {
|
||||||
.unwrap();
|
println!("Error connecting: {}", e);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
let (mut player, _) = Player::new(player_config, session, None, move || {
|
let (mut player, _) = Player::new(player_config, session, None, move || {
|
||||||
backend(None, audio_format)
|
backend(None, audio_format)
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use std::env;
|
use std::{env, process::exit};
|
||||||
|
|
||||||
use librespot::core::authentication::Credentials;
|
use librespot::{
|
||||||
use librespot::core::config::SessionConfig;
|
core::{
|
||||||
use librespot::core::session::Session;
|
authentication::Credentials, config::SessionConfig, session::Session, spotify_id::SpotifyId,
|
||||||
use librespot::core::spotify_id::SpotifyId;
|
},
|
||||||
use librespot::metadata::{Metadata, Playlist, Track};
|
metadata::{Metadata, Playlist, Track},
|
||||||
|
};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
@ -24,9 +25,11 @@ async fn main() {
|
||||||
|
|
||||||
let plist_uri = SpotifyId::from_base62(uri_parts[2]).unwrap();
|
let plist_uri = SpotifyId::from_base62(uri_parts[2]).unwrap();
|
||||||
|
|
||||||
let session = Session::connect(session_config, credentials, None)
|
let session = Session::new(session_config, None);
|
||||||
.await
|
if let Err(e) = session.connect(credentials).await {
|
||||||
.unwrap();
|
println!("Error connecting: {}", e);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
let plist = Playlist::get(&session, plist_uri).await.unwrap();
|
let plist = Playlist::get(&session, plist_uri).await.unwrap();
|
||||||
println!("{:?}", plist);
|
println!("{:?}", plist);
|
||||||
|
|
Loading…
Reference in a new issue