Add credentials cache and bump libraries
This commit is contained in:
parent
cad94d74e9
commit
4098752737
4 changed files with 593 additions and 381 deletions
949
Cargo.lock
generated
949
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -7,7 +7,7 @@ panic = "abort"
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "down_on_spot"
|
name = "down_on_spot"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
authors = ["exttex", "oSumAtrIX"]
|
authors = ["exttex", "oSumAtrIX"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
@ -19,7 +19,7 @@ winres = "0.1"
|
||||||
clap = "3.0"
|
clap = "3.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
protobuf = "2.25"
|
protobuf = "3.0"
|
||||||
id3 = "1.0"
|
id3 = "1.0"
|
||||||
dirs = "4.0"
|
dirs = "4.0"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
|
@ -34,7 +34,7 @@ async-std = { version = "1.10", features = ["attributes", "tokio1"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
async-stream = "0.3"
|
async-stream = "0.3"
|
||||||
oggvorbismeta = "0.1"
|
oggvorbismeta = "0.1"
|
||||||
sanitize-filename = "0.3"
|
sanitize-filename = "0.4"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tokio = { version = "1.12", features = ["fs"] }
|
tokio = { version = "1.12", features = ["fs"] }
|
||||||
|
|
||||||
|
|
@ -42,4 +42,4 @@ tokio = { version = "1.12", features = ["fs"] }
|
||||||
OriginalFilename = "DownOnSpot.exe"
|
OriginalFilename = "DownOnSpot.exe"
|
||||||
FileDescription = "Download songs from Spotify with Rust"
|
FileDescription = "Download songs from Spotify with Rust"
|
||||||
ProductName = "DownOnSpot"
|
ProductName = "DownOnSpot"
|
||||||
ProductVersion = "0.2.0"
|
ProductVersion = "0.2.1"
|
||||||
|
|
@ -504,7 +504,7 @@ impl DownloaderInternal {
|
||||||
'outer: loop {
|
'outer: loop {
|
||||||
for format in quality.get_file_formats() {
|
for format in quality.get_file_formats() {
|
||||||
if let Some(f) = track.files.get(&format) {
|
if let Some(f) = track.files.get(&format) {
|
||||||
info!("{} Using {:?} format.", id.to_base62(), format);
|
info!("{} Using {:?} format.", id.to_base62().unwrap(), format);
|
||||||
file_id = Some(f);
|
file_id = Some(f);
|
||||||
file_format = Some(format);
|
file_format = Some(format);
|
||||||
break 'outer;
|
break 'outer;
|
||||||
|
|
@ -515,7 +515,7 @@ impl DownloaderInternal {
|
||||||
Some(q) => quality = q,
|
Some(q) => quality = q,
|
||||||
None => break,
|
None => break,
|
||||||
}
|
}
|
||||||
warn!("{} Falling back to: {:?}", id.to_base62(), quality);
|
warn!("{} Falling back to: {:?}", id.to_base62().unwrap(), quality);
|
||||||
}
|
}
|
||||||
let file_id = file_id.ok_or(SpotifyError::Unavailable)?;
|
let file_id = file_id.ok_or(SpotifyError::Unavailable)?;
|
||||||
let file_format = file_format.unwrap();
|
let file_format = file_format.unwrap();
|
||||||
|
|
@ -573,7 +573,7 @@ impl DownloaderInternal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Done downloading: {}", track.id.to_base62());
|
info!("Done downloading: {}", track.id.to_base62().unwrap());
|
||||||
Ok((path, audio_format))
|
Ok((path, audio_format))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ use aspotify::{
|
||||||
TrackSimplified,
|
TrackSimplified,
|
||||||
};
|
};
|
||||||
use librespot::core::authentication::Credentials;
|
use librespot::core::authentication::Credentials;
|
||||||
|
use librespot::core::cache::Cache;
|
||||||
use librespot::core::config::SessionConfig;
|
use librespot::core::config::SessionConfig;
|
||||||
use librespot::core::session::Session;
|
use librespot::core::session::Session;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::path::Path;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::error::SpotifyError;
|
use crate::error::SpotifyError;
|
||||||
|
|
@ -26,7 +28,14 @@ impl Spotify {
|
||||||
) -> Result<Spotify, SpotifyError> {
|
) -> Result<Spotify, SpotifyError> {
|
||||||
// librespot
|
// librespot
|
||||||
let credentials = Credentials::with_password(username, password);
|
let credentials = Credentials::with_password(username, password);
|
||||||
let session = Session::connect(SessionConfig::default(), credentials, None).await?;
|
let (session, _) = Session::connect(
|
||||||
|
SessionConfig::default(),
|
||||||
|
credentials,
|
||||||
|
Some(Cache::new(Some(Path::new("credentials_cache")), None, None, None).unwrap()),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
//aspotify
|
//aspotify
|
||||||
let credentials = ClientCredentials {
|
let credentials = ClientCredentials {
|
||||||
id: client_id.to_string(),
|
id: client_id.to_string(),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue