Add more options

This commit is contained in:
Anas Elgarhy 2023-02-13 00:57:38 +02:00
parent 6910bc5ead
commit bd659cd2d9
No known key found for this signature in database
GPG key ID: 0501802A1D496528
2 changed files with 17 additions and 2 deletions

View file

@ -132,4 +132,19 @@ pub struct Arguments {
/// Link the program with cmus, if the cmus are not running, the program will exit.
#[arg(short = 'l', long)]
pub link: bool,
/// Force the program to use the external cover file, if available, and not even try to get the cover from the track's metadata.
/// this is useful if you have a cover file with a better quality than the cover in the track's metadata.
#[arg(short = 'u', long)]
pub force_use_external_cover: bool,
#[cfg(feature = "lyrics")]
/// Fotrce the program to use the external lyrics file, if available, and not even try to get the lyrics from the track's metadata.
#[arg(short = 'm', long)]
pub force_use_external_lyrics: bool,
/// No use the external cover file, even if it's available and the track's metadata doesn't have a cover.
#[arg(short = 'n', long)]
pub no_use_external_cover: bool,
#[cfg(feature = "lyrics")]
/// No use the external lyrics file, even if it's available and the track's metadata doesn't have a lyrics.
#[arg(short = 'o', long)]
pub no_use_external_lyrics: bool,
}

View file

@ -108,7 +108,7 @@ pub enum TrackCover {
/// If the track does not have an embedded cover, and `no_use_external_cover` is `false`, the function will search for an external cover.
/// If the track has an embedded cover, and `force_use_external_cover` is `true`, the function will search for an external cover.
#[inline]
pub fn track_cover(track_path: &str, force_use_external_cover: bool, no_use_external_cover: bool) -> TrackCover {
pub fn track_cover(track_path: &str, max_depth: u8, force_use_external_cover: bool, no_use_external_cover: bool) -> TrackCover {
if !force_use_external_cover {
if let Ok(Some(cover)) = get_embedded_art(track_path) {
return TrackCover::Embedded(cover);
@ -116,7 +116,7 @@ pub fn track_cover(track_path: &str, force_use_external_cover: bool, no_use_exte
}
if !no_use_external_cover {
if let Ok(Some(cover)) = search_for(track_path, 2,
if let Ok(Some(cover)) = search_for(track_path, max_depth,
&regex::Regex::new(r".*\.(jpg|jpeg|png|gif)$").unwrap()) {
return TrackCover::External(cover);
}