mirror of
https://github.com/CDrummond/bliss-analyser.git
synced 2026-10-22 22:32:08 +03:00
Merge branch 'master' into multi-folder
This commit is contained in:
commit
4f7850bc40
6 files changed
+80
-32
No files matched your search
@@ -33,6 +33,7 @@ jobs:
|
|||||||
name: bliss-analyser-linux
|
name: bliss-analyser-linux
|
||||||
path: releases/
|
path: releases/
|
||||||
|
|
||||||
|
|
||||||
macOS:
|
macOS:
|
||||||
runs-on: macos-11.0
|
runs-on: macos-11.0
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: |
|
run: |
|
||||||
brew install ffmpeg@5
|
brew install ffmpeg@5
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
@@ -65,6 +66,7 @@ jobs:
|
|||||||
name: bliss-analyser-mac
|
name: bliss-analyser-mac
|
||||||
path: releases/
|
path: releases/
|
||||||
|
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
|
||||||
|
|||||||
Generated
+1
-2
@@ -732,8 +732,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "lofty"
|
name = "lofty"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/Serial-ATA/lofty-rs?rev=45182b6#45182b6e3d71f9b9cc022aca9e3e192abb82ad10"
|
||||||
checksum = "dfc751ba10f732cf5c522b9bc887027c9eee277512a38a3a0c4f1806bdcd730d"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ rusqlite = { version = "0.25.0", features = ["bundled"] }
|
|||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
env_logger = "0.8.4"
|
env_logger = "0.8.4"
|
||||||
indicatif = "0.16.2"
|
indicatif = "0.16.2"
|
||||||
lofty = "0.5.3"
|
lofty = { git = "https://github.com/Serial-ATA/lofty-rs", rev = "45182b6" }
|
||||||
dirs = "1"
|
dirs = "1"
|
||||||
chrono = "0.4.19"
|
chrono = "0.4.19"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
0.1.0
|
0.1.0
|
||||||
-----
|
-----
|
||||||
1. Add support for analysing CUE files.
|
1. Add support for analysing CUE files.
|
||||||
2. Support up to 5 music folders (music, music_1, music_2, music_3, and
|
2. Output list of (up to 100) tracks that failed to analyse.
|
||||||
|
3. When performing a dry-run analysis (--dry-run) print paths of all tracks to
|
||||||
|
be analysed and to be removed.
|
||||||
|
4. Use git version of tag reader library.
|
||||||
|
5. Support up to 5 music folders (music, music_1, music_2, music_3, and
|
||||||
music_4).
|
music_4).
|
||||||
|
|
||||||
0.0.2
|
0.0.2
|
||||||
|
|||||||
+52
-16
@@ -27,7 +27,8 @@ use crate::db;
|
|||||||
use crate::tags;
|
use crate::tags;
|
||||||
|
|
||||||
const DONT_ANALYSE:&str = ".notmusic";
|
const DONT_ANALYSE:&str = ".notmusic";
|
||||||
const MAX_TAG_ERRORS_TO_SHOW:usize = 25;
|
const MAX_ERRORS_TO_SHOW:usize = 100;
|
||||||
|
const MAX_TAG_ERRORS_TO_SHOW:usize = 50;
|
||||||
|
|
||||||
fn get_file_list(db:&mut db::Db, mpath:&PathBuf, path:&PathBuf, track_paths:&mut Vec<String>, cue_tracks:&mut Vec<cue::CueTrack>) {
|
fn get_file_list(db:&mut db::Db, mpath:&PathBuf, path:&PathBuf, track_paths:&mut Vec<String>, cue_tracks:&mut Vec<cue::CueTrack>) {
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
@@ -112,7 +113,7 @@ pub fn analyse_new_files(db:&db::Db, mpath: &PathBuf, track_paths:Vec<String>) -
|
|||||||
|
|
||||||
let results = analyze_paths_streaming(track_paths)?;
|
let results = analyze_paths_streaming(track_paths)?;
|
||||||
let mut analysed = 0;
|
let mut analysed = 0;
|
||||||
let mut failed = 0;
|
let mut failed:Vec<String> = Vec::new();
|
||||||
let mut tag_error:Vec<String> = Vec::new();
|
let mut tag_error:Vec<String> = Vec::new();
|
||||||
|
|
||||||
log::info!("Analysing new tracks");
|
log::info!("Analysing new tracks");
|
||||||
@@ -133,13 +134,25 @@ pub fn analyse_new_files(db:&db::Db, mpath: &PathBuf, track_paths:Vec<String>) -
|
|||||||
db.add_track(&sname, &meta, &track.analysis);
|
db.add_track(&sname, &meta, &track.analysis);
|
||||||
analysed += 1;
|
analysed += 1;
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(e) => {
|
||||||
failed += 1;
|
failed.push(format!("{} - {}", sname, e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
pb.inc(1);
|
pb.inc(1);
|
||||||
}
|
}
|
||||||
pb.finish_with_message(format!("{} Analysed. {} Failure(s).", analysed, failed));
|
pb.finish_with_message(format!("{} Analysed. {} Failure(s).", analysed, failed.len()));
|
||||||
|
if !failed.is_empty() {
|
||||||
|
let total = failed.len();
|
||||||
|
failed.truncate(MAX_ERRORS_TO_SHOW);
|
||||||
|
|
||||||
|
log::error!("Failed to analyse the folling track(s):");
|
||||||
|
for err in failed {
|
||||||
|
log::error!(" {}", err);
|
||||||
|
}
|
||||||
|
if total>MAX_ERRORS_TO_SHOW {
|
||||||
|
log::error!(" + {} other(s)", total - MAX_ERRORS_TO_SHOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
if !tag_error.is_empty() {
|
if !tag_error.is_empty() {
|
||||||
let total = tag_error.len();
|
let total = tag_error.len();
|
||||||
tag_error.truncate(MAX_TAG_ERRORS_TO_SHOW);
|
tag_error.truncate(MAX_TAG_ERRORS_TO_SHOW);
|
||||||
@@ -255,7 +268,7 @@ pub fn analyse_new_cue_tracks(db:&db::Db, mpath: &PathBuf, cue_tracks:Vec<cue::C
|
|||||||
|
|
||||||
let results = analyze_cue_streaming(cue_tracks)?;
|
let results = analyze_cue_streaming(cue_tracks)?;
|
||||||
let mut analysed = 0;
|
let mut analysed = 0;
|
||||||
let mut failed = 0;
|
let mut failed:Vec<String> = Vec::new();
|
||||||
|
|
||||||
log::info!("Analysing new cue tracks");
|
log::info!("Analysing new cue tracks");
|
||||||
for (track, result) in results {
|
for (track, result) in results {
|
||||||
@@ -277,13 +290,25 @@ pub fn analyse_new_cue_tracks(db:&db::Db, mpath: &PathBuf, cue_tracks:Vec<cue::C
|
|||||||
db.add_track(&sname, &meta, &song.analysis);
|
db.add_track(&sname, &meta, &song.analysis);
|
||||||
analysed += 1;
|
analysed += 1;
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(e) => {
|
||||||
failed += 1;
|
failed.push(format!("{} - {}", sname, e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
pb.inc(1);
|
pb.inc(1);
|
||||||
}
|
}
|
||||||
pb.finish_with_message(format!("{} Analysed. {} Failure(s).", analysed, failed));
|
pb.finish_with_message(format!("{} Analysed. {} Failure(s).", analysed, failed.len()));
|
||||||
|
if !failed.is_empty() {
|
||||||
|
let total = failed.len();
|
||||||
|
failed.truncate(MAX_ERRORS_TO_SHOW);
|
||||||
|
|
||||||
|
log::error!("Failed to analyse the folling track(s):");
|
||||||
|
for err in failed {
|
||||||
|
log::error!(" {}", err);
|
||||||
|
}
|
||||||
|
if total>MAX_ERRORS_TO_SHOW {
|
||||||
|
log::error!(" + {} other(s)", total - MAX_ERRORS_TO_SHOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,6 +317,10 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec<PathBuf>, dry_run:bool, keep_ol
|
|||||||
|
|
||||||
db.init();
|
db.init();
|
||||||
|
|
||||||
|
if !keep_old {
|
||||||
|
db.remove_old(mpaths, dry_run);
|
||||||
|
}
|
||||||
|
|
||||||
for path in mpaths {
|
for path in mpaths {
|
||||||
let mpath = path.clone();
|
let mpath = path.clone();
|
||||||
let cur = path.clone();
|
let cur = path.clone();
|
||||||
@@ -300,6 +329,7 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec<PathBuf>, dry_run:bool, keep_ol
|
|||||||
|
|
||||||
log::info!("Looking for new tracks in {}", mpath.to_string_lossy());
|
log::info!("Looking for new tracks in {}", mpath.to_string_lossy());
|
||||||
get_file_list(&mut db, &mpath, &cur, &mut track_paths, &mut cue_tracks);
|
get_file_list(&mut db, &mpath, &cur, &mut track_paths, &mut cue_tracks);
|
||||||
|
track_paths.sort();
|
||||||
log::info!("Num new tracks: {}", track_paths.len());
|
log::info!("Num new tracks: {}", track_paths.len());
|
||||||
if !cue_tracks.is_empty() {
|
if !cue_tracks.is_empty() {
|
||||||
log::info!("Num new cue tracks: {}", cue_tracks.len());
|
log::info!("Num new cue tracks: {}", cue_tracks.len());
|
||||||
@@ -312,9 +342,18 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec<PathBuf>, dry_run:bool, keep_ol
|
|||||||
log::info!("Only analysing {} cue tracks", max_num_tracks);
|
log::info!("Only analysing {} cue tracks", max_num_tracks);
|
||||||
cue_tracks.truncate(max_num_tracks);
|
cue_tracks.truncate(max_num_tracks);
|
||||||
}
|
}
|
||||||
|
if dry_run {
|
||||||
if !dry_run {
|
if !track_paths.is_empty() || !cue_tracks.is_empty() {
|
||||||
if track_paths.len()>0 {
|
log::info!("The following need to be analysed:");
|
||||||
|
for track in track_paths {
|
||||||
|
log::info!(" {}", track);
|
||||||
|
}
|
||||||
|
for track in cue_tracks {
|
||||||
|
log::info!(" {}", track.track_path.to_string_lossy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if !track_paths.is_empty() {
|
||||||
match analyse_new_files(&db, &mpath, track_paths) {
|
match analyse_new_files(&db, &mpath, track_paths) {
|
||||||
Ok(_) => { },
|
Ok(_) => { },
|
||||||
Err(e) => { log::error!("Analysis returned error: {}", e); }
|
Err(e) => { log::error!("Analysis returned error: {}", e); }
|
||||||
@@ -322,6 +361,7 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec<PathBuf>, dry_run:bool, keep_ol
|
|||||||
} else {
|
} else {
|
||||||
log::info!("No new tracks to analyse");
|
log::info!("No new tracks to analyse");
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cue_tracks.is_empty() {
|
if !cue_tracks.is_empty() {
|
||||||
match analyse_new_cue_tracks(&db, &mpath, cue_tracks) {
|
match analyse_new_cue_tracks(&db, &mpath, cue_tracks) {
|
||||||
Ok(_) => { },
|
Ok(_) => { },
|
||||||
@@ -331,10 +371,6 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec<PathBuf>, dry_run:bool, keep_ol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !keep_old {
|
|
||||||
db.remove_old(mpaths, dry_run);
|
|
||||||
}
|
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,18 +188,25 @@ impl Db {
|
|||||||
|
|
||||||
let num_to_remove = to_remove.len();
|
let num_to_remove = to_remove.len();
|
||||||
log::info!("Num non-existant tracks: {}", num_to_remove);
|
log::info!("Num non-existant tracks: {}", num_to_remove);
|
||||||
if !dry_run && num_to_remove>0 {
|
if num_to_remove>0 {
|
||||||
let count_before = self.get_track_count();
|
if dry_run {
|
||||||
for t in to_remove {
|
log::info!("The following need to be removed from database:");
|
||||||
//log::debug!("Remove '{}'", t);
|
for t in to_remove {
|
||||||
match self.conn.execute("DELETE FROM Tracks WHERE File = ?;", params![t]) {
|
log::info!(" {}", t);
|
||||||
Ok(_) => { },
|
}
|
||||||
Err(e) => { log::error!("Failed to remove '{}' - {}", t, e) }
|
} else {
|
||||||
|
let count_before = self.get_track_count();
|
||||||
|
for t in to_remove {
|
||||||
|
//log::debug!("Remove '{}'", t);
|
||||||
|
match self.conn.execute("DELETE FROM Tracks WHERE File = ?;", params![t]) {
|
||||||
|
Ok(_) => { },
|
||||||
|
Err(e) => { log::error!("Failed to remove '{}' - {}", t, e) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let count_now = self.get_track_count();
|
||||||
|
if (count_now + num_to_remove) != count_before {
|
||||||
|
log::error!("Failed to remove all tracks. Count before: {}, wanted to remove: {}, count now: {}", count_before, num_to_remove, count_now);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let count_now = self.get_track_count();
|
|
||||||
if (count_now + num_to_remove) != count_before {
|
|
||||||
log::error!("Failed to remove all tracks. Count before: {}, wanted to remove: {}, count now: {}", count_before, num_to_remove, count_now);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user