format code
Signed-off-by: Felix Breuer <fbreuer@pm.me>
This commit is contained in:
parent
ea877ebde6
commit
befad26e33
6 changed files with 70 additions and 67 deletions
1
rustfmt.toml
Normal file
1
rustfmt.toml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
hard_tabs = true
|
||||||
|
|
@ -3,7 +3,7 @@ use std::io::{Error, ErrorKind, Read, Seek};
|
||||||
|
|
||||||
use crate::downloader::{AudioFormat, Quality};
|
use crate::downloader::{AudioFormat, Quality};
|
||||||
use crate::error::SpotifyError;
|
use crate::error::SpotifyError;
|
||||||
use crate::error::SpotifyError::{LameConverterError, InvalidFormat};
|
use crate::error::SpotifyError::{InvalidFormat, LameConverterError};
|
||||||
|
|
||||||
/// Converts audio to MP3
|
/// Converts audio to MP3
|
||||||
pub enum AudioConverter {
|
pub enum AudioConverter {
|
||||||
|
|
@ -35,16 +35,16 @@ impl AudioConverter {
|
||||||
|
|
||||||
match lame.set_channels(2) {
|
match lame.set_channels(2) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => return Err(LameConverterError("Channels".to_string()))
|
Err(_) => return Err(LameConverterError("Channels".to_string())),
|
||||||
};
|
};
|
||||||
|
|
||||||
match lame.set_quality(0) {
|
match lame.set_quality(0) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => return Err(LameConverterError("Quality".to_string()))
|
Err(_) => return Err(LameConverterError("Quality".to_string())),
|
||||||
};
|
};
|
||||||
match lame.set_kilobitrate(bitrate) {
|
match lame.set_kilobitrate(bitrate) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => return Err(LameConverterError("Bitrate".to_string()))
|
Err(_) => return Err(LameConverterError("Bitrate".to_string())),
|
||||||
};
|
};
|
||||||
|
|
||||||
match format {
|
match format {
|
||||||
|
|
@ -57,11 +57,11 @@ impl AudioConverter {
|
||||||
// Init lame
|
// Init lame
|
||||||
match lame.set_sample_rate(sample_rate) {
|
match lame.set_sample_rate(sample_rate) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => return Err(LameConverterError("Sample rate".to_string()))
|
Err(_) => return Err(LameConverterError("Sample rate".to_string())),
|
||||||
};
|
};
|
||||||
match lame.init_params() {
|
match lame.init_params() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => return Err(LameConverterError("Init".to_string()))
|
Err(_) => return Err(LameConverterError("Init".to_string())),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(AudioConverter::Ogg {
|
Ok(AudioConverter::Ogg {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ impl Settings {
|
||||||
client_id: client_id.to_string(),
|
client_id: client_id.to_string(),
|
||||||
client_secret: client_secret.to_string(),
|
client_secret: client_secret.to_string(),
|
||||||
refresh_ui_seconds: 1,
|
refresh_ui_seconds: 1,
|
||||||
downloader: DownloaderConfig::new()
|
downloader: DownloaderConfig::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
use aspotify::{Album, Artist, Client, ClientCredentials, ItemType, Playlist, PlaylistItemType, Track, TrackSimplified};
|
use aspotify::{
|
||||||
|
Album, Artist, Client, ClientCredentials, ItemType, Playlist, PlaylistItemType, Track,
|
||||||
|
TrackSimplified,
|
||||||
|
};
|
||||||
use librespot::core::authentication::Credentials;
|
use librespot::core::authentication::Credentials;
|
||||||
use librespot::core::config::SessionConfig;
|
use librespot::core::config::SessionConfig;
|
||||||
use librespot::core::session::Session;
|
use librespot::core::session::Session;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ pub enum TagWrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TagWrap {
|
impl TagWrap {
|
||||||
|
|
||||||
/// Load from file
|
/// Load from file
|
||||||
pub fn new(path: impl AsRef<Path>, format: AudioFormat) -> Result<TagWrap, SpotifyError> {
|
pub fn new(path: impl AsRef<Path>, format: AudioFormat) -> Result<TagWrap, SpotifyError> {
|
||||||
match format {
|
match format {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue