Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix inital_volume being a string #778

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use librespot::{
core::{cache::Cache, config::DeviceType as LSDeviceType, config::SessionConfig, version},
playback::config::{Bitrate as LSBitrate, PlayerConfig},
};
use log::{error, info, warn};
use log::{error, info};
use serde::{de::Error, de::Unexpected, Deserialize, Deserializer};
use sha1::{Digest, Sha1};
use std::{fmt, fs, path::PathBuf, str::FromStr, string::ToString};
Expand Down Expand Up @@ -337,7 +337,7 @@ pub struct SharedConfigValues {

/// Initial volume between 0 and 100
#[structopt(long, value_name = "initial_volume")]
initial_volume: Option<String>,
initial_volume: Option<u16>,

/// Enable to normalize the volume during playback
#[structopt(long)]
Expand Down Expand Up @@ -595,14 +595,6 @@ pub(crate) fn get_internal_config(config: CliConfig) -> SpotifydConfig {
let initial_volume: Option<u16> = config
.shared_config
.initial_volume
.map(|input| match input.parse::<i16>() {
Ok(v) if (0..=100).contains(&v) => Some(v),
_ => {
warn!("Could not parse initial_volume (must be in the range 0-100)");
None
}
})
.flatten()
.map(|volume| (volume as i32 * 0xFFFF / 100) as u16);

let device_name = config
Expand Down