Number cue tracks from 1, should match LMS track number

This commit is contained in:
Craig Drummond committed 2022-03-13 06:54:09 +00:00
1 parent 5fef00c24a
commit 25c01f4434
2 files changed
+4 -13

No files matched your search

+2 -9
View File
@@ -57,8 +57,7 @@ fn get_file_list(db:&mut db::Db, mpath:&PathBuf, path:&PathBuf, track_paths:&mut
if cue_file.exists() { if cue_file.exists() {
// Found a CUE file, try to parse and then check if tracks exists in DB // Found a CUE file, try to parse and then check if tracks exists in DB
let this_cue_tracks = cue::parse(&pb, &cue_file); let this_cue_tracks = cue::parse(&pb, &cue_file);
let mut analyse = false; for track in this_cue_tracks {
for track in this_cue_tracks.iter() {
match track.track_path.strip_prefix(mpath) { match track.track_path.strip_prefix(mpath) {
Ok(tstripped) => { Ok(tstripped) => {
let spb = tstripped.to_path_buf(); let spb = tstripped.to_path_buf();
@@ -66,7 +65,7 @@ fn get_file_list(db:&mut db::Db, mpath:&PathBuf, path:&PathBuf, track_paths:&mut
match db.get_rowid(&sname) { match db.get_rowid(&sname) {
Ok(id) => { Ok(id) => {
if id<=0 { if id<=0 {
analyse = true; cue_tracks.push(track.clone());
} }
}, },
Err(_) => { } Err(_) => { }
@@ -75,12 +74,6 @@ fn get_file_list(db:&mut db::Db, mpath:&PathBuf, path:&PathBuf, track_paths:&mut
Err(_) => { } Err(_) => { }
} }
} }
if analyse {
for track in this_cue_tracks {
cue_tracks.push(track);
}
}
} else { } else {
let spb = stripped.to_path_buf(); let spb = stripped.to_path_buf();
let sname = String::from(spb.to_string_lossy()); let sname = String::from(spb.to_string_lossy());
+2 -4
View File
@@ -26,8 +26,7 @@ pub struct CueTrack {
pub album_artist:String, pub album_artist:String,
pub genre:String, pub genre:String,
pub start:Duration, pub start:Duration,
pub duration:Duration, pub duration:Duration
pub analyse:bool
} }
pub fn parse(audio_path:&PathBuf, cue_path:&PathBuf) -> Vec<CueTrack> { pub fn parse(audio_path:&PathBuf, cue_path:&PathBuf) -> Vec<CueTrack> {
@@ -50,7 +49,7 @@ pub fn parse(audio_path:&PathBuf, cue_path:&PathBuf) -> Vec<CueTrack> {
Some((_, start)) => { Some((_, start)) => {
let mut track_path = audio_path.clone(); let mut track_path = audio_path.clone();
let ext = audio_path.extension().unwrap().to_string_lossy(); let ext = audio_path.extension().unwrap().to_string_lossy();
track_path.set_extension(format!("{}{}{}.mp3", ext, MARKER, resp.len())); track_path.set_extension(format!("{}{}{}.mp3", ext, MARKER, resp.len()+1));
let ctrack = CueTrack { let ctrack = CueTrack {
audio_path: audio_path.clone(), audio_path: audio_path.clone(),
track_path: track_path, track_path: track_path,
@@ -61,7 +60,6 @@ pub fn parse(audio_path:&PathBuf, cue_path:&PathBuf) -> Vec<CueTrack> {
genre: genre.clone(), genre: genre.clone(),
start: start.clone(), start: start.clone(),
duration: Duration::new(LAST_TRACK_DURATION, 0), duration: Duration::new(LAST_TRACK_DURATION, 0),
analyse: false
}; };
resp.push(ctrack); resp.push(ctrack);
}, },