feat(config): Allow users to set AP port (#1420)
* added support for ap-port conf * chore: Reindent table * feat: Only set `ap_port` in session config if supplied by user * docs: Update CHANGELOG --------- Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
@@ -128,7 +128,7 @@ impl Spotify {
|
||||
}
|
||||
|
||||
/// Generate the librespot [SessionConfig] used when creating a [Session].
|
||||
pub fn session_config() -> SessionConfig {
|
||||
pub fn session_config(cfg: &config::Config) -> SessionConfig {
|
||||
let mut session_config = SessionConfig::default();
|
||||
match env::var("http_proxy") {
|
||||
Ok(proxy) => {
|
||||
@@ -137,12 +137,18 @@ impl Spotify {
|
||||
}
|
||||
Err(_) => debug!("No HTTP proxy set"),
|
||||
}
|
||||
if let Some(ap_port) = cfg.values().ap_port {
|
||||
session_config.ap_port = Some(ap_port)
|
||||
}
|
||||
session_config
|
||||
}
|
||||
|
||||
/// Test whether `credentials` are valid Spotify credentials.
|
||||
pub fn test_credentials(credentials: Credentials) -> Result<Session, SessionError> {
|
||||
let config = Self::session_config();
|
||||
pub fn test_credentials(
|
||||
cfg: &config::Config,
|
||||
credentials: Credentials,
|
||||
) -> Result<Session, SessionError> {
|
||||
let config = Self::session_config(cfg);
|
||||
ASYNC_RUNTIME
|
||||
.get()
|
||||
.unwrap()
|
||||
@@ -172,7 +178,7 @@ impl Spotify {
|
||||
)
|
||||
.expect("Could not create cache");
|
||||
debug!("opening spotify session");
|
||||
let session_config = Self::session_config();
|
||||
let session_config = Self::session_config(cfg);
|
||||
Session::connect(session_config, credentials, Some(cache), true)
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
|
||||
Reference in New Issue
Block a user