Skip to content

Commit

Permalink
Merge pull request #35 from msandoval/main
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorSatori authored Dec 22, 2024
2 parents 49b41bc + 60c9431 commit 4fdeefe
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/helpers/gen_funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use glob::glob;
use lofty::{Accessor, Probe, TaggedFileExt};
use lofty::{Accessor, AudioFile, Probe, TaggedFileExt};

// converts queue items to what's displayed for user
pub fn audio_display(path: &PathBuf) -> String {
Expand All @@ -16,16 +16,21 @@ pub fn audio_display(path: &PathBuf) -> String {
.read()
.expect("ERROR: Failed to read file!");

let ptag = tagged_file.primary_tag().unwrap();
let artist = ptag.artist();
// If the file contains a tag
if tagged_file.contains_tag() {
let ptag = tagged_file.primary_tag().unwrap();
let artist = ptag.artist();

// if filename
if let Some(i) = tagged_file.primary_tag().unwrap().title() {
// if artist data
if let Some(j) = artist {
format!("{artist} - {title}", artist = j, title = i)
// if filename
if let Some(i) = tagged_file.primary_tag().unwrap().title() {
// if artist data
if let Some(j) = artist {
format!("{artist} - {title}", artist = j, title = i)
} else {
i.into()
}
} else {
i.into()
path.file_name().unwrap().to_str().unwrap().to_string()
}
} else {
path.file_name().unwrap().to_str().unwrap().to_string()
Expand Down

0 comments on commit 4fdeefe

Please sign in to comment.