mirror of
https://github.com/CDrummond/bliss-analyser.git
synced 2025-04-08 05:00:02 +03:00
Add option to limit number of tracks to analyse
This commit is contained in:
parent
01622016dc
commit
087a169971
@ -130,6 +130,7 @@ analysis will be performed, instead the logging will inform you how many new
|
||||
tracks are to be analysed and how many old tracks are left in the database.
|
||||
* `-i` / `--ignore` Name and location of the file containing items to ignore.
|
||||
* `-L` / `--lms` Hostname, or IP address, of your LMS server.
|
||||
* `-n` / `--numtracks` Specify maximum number of tracks to analyse.
|
||||
|
||||
If any of these are used, then they will override their equivalent from the INI
|
||||
config file.
|
||||
|
@ -127,7 +127,7 @@ pub fn analyse_new_files(db:&db::Db, mpath: &PathBuf, track_paths:Vec<String>) -
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn analyse_files(db_path: &str, mpath: &PathBuf, dry_run:bool, keep_old:bool) {
|
||||
pub fn analyse_files(db_path: &str, mpath: &PathBuf, dry_run:bool, keep_old:bool, max_num_tracks:usize) {
|
||||
let mut track_paths:Vec<String> = Vec::new();
|
||||
let mut db = db::Db::new(&String::from(db_path));
|
||||
let cur = PathBuf::from(mpath);
|
||||
@ -136,6 +136,10 @@ pub fn analyse_files(db_path: &str, mpath: &PathBuf, dry_run:bool, keep_old:bool
|
||||
log::info!("Looking for new tracks");
|
||||
get_file_list(&mut db, mpath, &cur, &mut track_paths);
|
||||
log::info!("Num new tracks: {}", track_paths.len());
|
||||
if !dry_run && max_num_tracks>0 && track_paths.len()>max_num_tracks {
|
||||
log::info!("Only analysing {} tracks", max_num_tracks);
|
||||
track_paths.truncate(max_num_tracks);
|
||||
}
|
||||
if !keep_old {
|
||||
db.remove_old(mpath, dry_run);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ fn main() {
|
||||
let mut dry_run:bool = false;
|
||||
let mut task = "".to_string();
|
||||
let mut lms_host = "127.0.0.1".to_string();
|
||||
let mut max_num_tracks:usize = 0;
|
||||
|
||||
match dirs::home_dir() {
|
||||
Some(path) => { music_path = String::from(path.join("Music").to_string_lossy()); }
|
||||
@ -59,6 +60,7 @@ fn main() {
|
||||
arg_parse.refer(&mut dry_run).add_option(&["-r", "--dry-run"], StoreTrue, "Dry run, only show what needs to be done (used with analyse task)");
|
||||
arg_parse.refer(&mut ignore_file).add_option(&["-i", "--ignore"], Store, &ignore_file_help);
|
||||
arg_parse.refer(&mut lms_host).add_option(&["-L", "--lms"], Store, &lms_host_help);
|
||||
arg_parse.refer(&mut max_num_tracks).add_option(&["-n", "--numtracks"], Store, "Maximum number of tracks to analyse");
|
||||
arg_parse.refer(&mut task).add_argument("task", Store, "Task to perform; analyse, tags, ignore, upload.");
|
||||
arg_parse.parse_args_or_exit();
|
||||
}
|
||||
@ -155,7 +157,7 @@ fn main() {
|
||||
}
|
||||
analyse::update_ignore(&db_path, &ignore_path);
|
||||
} else {
|
||||
analyse::analyse_files(&db_path, &mpath, dry_run, keep_old);
|
||||
analyse::analyse_files(&db_path, &mpath, dry_run, keep_old, max_num_tracks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user