mirror of
https://github.com/Dangoware/dmp-core.git
synced 2025-04-19 17:42:56 -05:00
Fixed duplicate entries
This commit is contained in:
parent
60add901bd
commit
c5a631e30f
1 changed files with 28 additions and 20 deletions
|
@ -161,7 +161,7 @@ impl URI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_string(&self) -> String {
|
pub fn path_string(&self) -> String {
|
||||||
let path_str = match self {
|
let path_str = match self {
|
||||||
URI::Local(location) => location.as_path().to_string_lossy(),
|
URI::Local(location) => location.as_path().to_string_lossy(),
|
||||||
URI::Cue {
|
URI::Cue {
|
||||||
|
@ -359,7 +359,10 @@ impl MusicLibrary {
|
||||||
&& extension.to_ascii_lowercase() != "vob"
|
&& extension.to_ascii_lowercase() != "vob"
|
||||||
{
|
{
|
||||||
match self.add_file(&target_file.path()) {
|
match self.add_file(&target_file.path()) {
|
||||||
Ok(_) => total += 1,
|
Ok(_) => {
|
||||||
|
//println!("{:?}", target_file.path());
|
||||||
|
total += 1
|
||||||
|
},
|
||||||
Err(_error) => {
|
Err(_error) => {
|
||||||
//println!("{}, {:?}: {}", format, target_file.file_name(), _error)
|
//println!("{}, {:?}: {}", format, target_file.file_name(), _error)
|
||||||
} // TODO: Handle more of these errors
|
} // TODO: Handle more of these errors
|
||||||
|
@ -482,7 +485,7 @@ impl MusicLibrary {
|
||||||
let album_artist = &cue_data.get_cdtext().read(cue::cd_text::PTI::Performer).unwrap_or(String::new());
|
let album_artist = &cue_data.get_cdtext().read(cue::cd_text::PTI::Performer).unwrap_or(String::new());
|
||||||
|
|
||||||
let parent_dir = cuesheet.parent().expect("The file has no parent path??");
|
let parent_dir = cuesheet.parent().expect("The file has no parent path??");
|
||||||
for track in cue_data.tracks() {
|
for (i, track) in cue_data.tracks().iter().enumerate() {
|
||||||
let audio_location = parent_dir.join(track.get_filename());
|
let audio_location = parent_dir.join(track.get_filename());
|
||||||
|
|
||||||
if !audio_location.exists() {
|
if !audio_location.exists() {
|
||||||
|
@ -528,12 +531,21 @@ impl MusicLibrary {
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get some useful tags
|
||||||
let mut tags: Vec<(Tag, String)> = Vec::new();
|
let mut tags: Vec<(Tag, String)> = Vec::new();
|
||||||
tags.push((Tag::Album, album_title.clone()));
|
tags.push((Tag::Album, album_title.clone()));
|
||||||
tags.push((Tag::Key("AlbumArtist".to_string()), album_artist.clone()));
|
tags.push((Tag::Key("AlbumArtist".to_string()), album_artist.clone()));
|
||||||
match track.get_cdtext().read(cue::cd_text::PTI::Title) {
|
match track.get_cdtext().read(cue::cd_text::PTI::Title) {
|
||||||
Some(title) => tags.push((Tag::Title, title)),
|
Some(title) => tags.push((Tag::Title, title)),
|
||||||
None => ()
|
None => {
|
||||||
|
match track.get_cdtext().read(cue::cd_text::PTI::UPC_ISRC) {
|
||||||
|
Some(title) => tags.push((Tag::Title, title)),
|
||||||
|
None => {
|
||||||
|
let namestr = format!("{} - {}", i, track.get_filename());
|
||||||
|
tags.push((Tag::Title, namestr))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
match track.get_cdtext().read(cue::cd_text::PTI::Performer) {
|
match track.get_cdtext().read(cue::cd_text::PTI::Performer) {
|
||||||
Some(artist) => tags.push((Tag::Artist, artist)),
|
Some(artist) => tags.push((Tag::Artist, artist)),
|
||||||
|
@ -573,7 +585,7 @@ impl MusicLibrary {
|
||||||
match self.add_song(new_song) {
|
match self.add_song(new_song) {
|
||||||
Ok(_) => tracks_added += 1,
|
Ok(_) => tracks_added += 1,
|
||||||
Err(_error) => {
|
Err(_error) => {
|
||||||
println!("{}", _error);
|
//println!("{}", _error);
|
||||||
continue
|
continue
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -589,16 +601,11 @@ impl MusicLibrary {
|
||||||
}
|
}
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
match self.query_path(&new_song.location.path()) {
|
match new_song.location {
|
||||||
Some(songs) => {
|
URI::Local(_) if self.query_path(&new_song.location.path()).is_some() => {
|
||||||
for song in songs {
|
return Err(format!("Location exists for {:?}", new_song.location).into())
|
||||||
match &song.location {
|
},
|
||||||
URI::Local(location) => return Err(format!("Cuesheet exists: {:?}", new_song.location).into()),
|
_ => ()
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.library.push(new_song);
|
self.library.push(new_song);
|
||||||
|
@ -642,12 +649,13 @@ impl MusicLibrary {
|
||||||
let songs = Arc::new(Mutex::new(Vec::new()));
|
let songs = Arc::new(Mutex::new(Vec::new()));
|
||||||
|
|
||||||
self.library.par_iter().for_each(|track| {
|
self.library.par_iter().for_each(|track| {
|
||||||
for tag in &track.tags {
|
for tag in target_tags {
|
||||||
if !target_tags.contains(&tag.0) {
|
let track_result = match track.get_tag(&tag) {
|
||||||
continue;
|
Some(value) => value,
|
||||||
}
|
None => continue
|
||||||
|
};
|
||||||
|
|
||||||
if normalize(&tag.1).contains(&normalize(&query_string)) {
|
if normalize(track_result).contains(&normalize(&query_string)) {
|
||||||
songs.lock().unwrap().push(track);
|
songs.lock().unwrap().push(track);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue