Add stopmixer task

This commit is contained in:
Craig Drummond 2022-03-02 13:11:23 +00:00
parent 58ede56b8e
commit 81df6c8732
3 changed files with 87 additions and 58 deletions

View File

@ -13,33 +13,36 @@ Quick guide
1. Install the `Bliss Mixer` LMS plugin.
2. Create `config.ini` in the current folder with (change as appropriate):
2. Install ffmpeg if using Linux or macOS.
3. Edit the supplied `config.ini` in the current folder to set appropiate values
for `music` and `lms` - e.g.:
```
[Bliss]
music=/home/user/Music
lms=127.0.0.1
```
3. Analyse your tracks:
4. Analyse your tracks:
```
./bliss-analyser analyse
```
4. Upload analysis database to LMS:
5. Upload analysis database to LMS:
```
./bliss-analyser upload
```
5. Set LMS to use `Bliss` in `Don't Stop the Music`
6. Set LMS to use `Bliss` in `Don't Stop the Music`
6. Play some music!
7. Play some music!
Installation
============
For Windows no extra installtion steps are required, as all dependencies are
For Windows no extra installation steps are required, as all dependencies are
bundled within its ZIP file. However, both the Linux and macOS versions require
that `ffmpeg` be installed.
@ -100,7 +103,7 @@ ignore=ignore.txt
The following items are supported:
* `music` specifies the location of your music collection - e.g. `c:\Users\user\Music`
for windows. This default to `Music` within the user's home folder.
* `db` specifies the name and location of the database file uses to store the
* `db` specifies the name and location of the database file used to store the
analysis results. This will default to `bliss.db` in the current folder.
* `lms` specifies the hostname, or IP address, of your LMS server. This is used
when uploading the database file to LMS. This defaults to `127.0.0.1`
@ -140,10 +143,11 @@ required task. This takes the following values:
* `analyse` Performs analysis of tracks.
* `upload` Uploads the database to LMS.
* `stopmixer` Asks LMS plugin to stop it instance of `bliss-mixer`
* `tags` Re-reads tags from your music collection, and updates the database for
any changes.
* `ignore` Reads the `ignore` file and updates the database to flag tracks as
being ignored for mixes.
to be ignored for mixes.
@ -166,10 +170,10 @@ accomplished as follows:
This will first iterate all sub-folders of your music collection to build a list
of filenames to analyse. New tracks that are not currently in the database are
the analysed, and a progress bar showing the current percentage and time used is
shown.
then analysed, and a progress bar showing the current percentage and time used
is shown.
As a rough guide, a 2015-era i7 8-core laptop with SSD analyses around 1400
As a rough guide, a 2015-era i7 8-core laptop with SSD analyses around 14000
tracks/hour.
@ -204,6 +208,22 @@ accomplished as follows:
.\bliss-analyser.exe upload
```
If your LMS is running on the same machine as `bliss-analyser` and you have set
the db path to be the location within your LMS's `Cache` folder which
`bliss-mixer` will use to access `bliss.db`, then there is no need to 'upload'
the database and all you need to do is stop any running `bliss-mixer`. This can
be accomplished manually, or via the following:
(Linux / macOS)
```
./bliss-analyser stopmixer
```
(Windows)
```
.\bliss-analyser.exe stopmixer
```
*NOTE* You must already have the `Bliss Mixer` LMS plugin installed, or you will
not be able to upload the database.
@ -234,7 +254,7 @@ Ignoring tracks in mixes
Its possible that you have some tracks that you never want added to mixes, but
as these are in your music collection they might be in your music queue and so
could possibly be chosen as `seed` tracks for mixes. Therefore you'd want there
could possibly be chosen as `seed` tracks for mixes. Therefore you'd want the
analysis in the database, so that you can find mixable tracks for them, but
would not want them be chosen as mixable tracks from other seeds. This is
accomplished be setting the `Ignore` column to `1` for such tracks. To make this

View File

@ -61,7 +61,7 @@ fn main() {
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.refer(&mut task).add_argument("task", Store, "Task to perform; analyse, tags, ignore, upload, stopmixer.");
arg_parse.parse_args_or_exit();
}
@ -78,7 +78,7 @@ fn main() {
process::exit(-1);
}
if !task.eq_ignore_ascii_case("analyse") && !task.eq_ignore_ascii_case("tags") && !task.eq_ignore_ascii_case("ignore") && !task.eq_ignore_ascii_case("upload") {
if !task.eq_ignore_ascii_case("analyse") && !task.eq_ignore_ascii_case("tags") && !task.eq_ignore_ascii_case("ignore") && !task.eq_ignore_ascii_case("upload") && !task.eq_ignore_ascii_case("stopmixer") {
log::error!("Invalid task ({}) supplied", task);
process::exit(-1);
}
@ -114,50 +114,54 @@ fn main() {
}
}
if db_path.len() < 3 {
log::error!("Invalid DB path ({}) supplied", db_path);
process::exit(-1);
}
let path = PathBuf::from(&db_path);
if path.exists() && !path.is_file() {
log::error!("DB path ({}) is not a file", db_path);
process::exit(-1);
}
if task.eq_ignore_ascii_case("upload") {
if path.exists() {
upload::upload_db(&db_path, &lms_host);
} else {
log::error!("DB ({}) does not exist", db_path);
process::exit(-1);
}
if task.eq_ignore_ascii_case("stopmixer") {
upload::stop_mixer(&lms_host);
} else {
let mpath = PathBuf::from(&music_path);
if !mpath.exists() {
log::error!("Music path ({}) does not exist", music_path);
process::exit(-1);
}
if !mpath.is_dir() {
log::error!("Music path ({}) is not a directory", music_path);
if db_path.len() < 3 {
log::error!("Invalid DB path ({}) supplied", db_path);
process::exit(-1);
}
if task.eq_ignore_ascii_case("tags") {
analyse::read_tags(&db_path, &mpath);
} else if task.eq_ignore_ascii_case("ignore") {
let ignore_path = PathBuf::from(&ignore_file);
if !ignore_path.exists() {
log::error!("Ignore file ({}) does not exist", ignore_file);
let path = PathBuf::from(&db_path);
if path.exists() && !path.is_file() {
log::error!("DB path ({}) is not a file", db_path);
process::exit(-1);
}
if task.eq_ignore_ascii_case("upload") {
if path.exists() {
upload::upload_db(&db_path, &lms_host);
} else {
log::error!("DB ({}) does not exist", db_path);
process::exit(-1);
}
if !ignore_path.is_file() {
log::error!("Ignore file ({}) is not a file", ignore_file);
process::exit(-1);
}
analyse::update_ignore(&db_path, &ignore_path);
} else {
analyse::analyse_files(&db_path, &mpath, dry_run, keep_old, max_num_tracks);
let mpath = PathBuf::from(&music_path);
if !mpath.exists() {
log::error!("Music path ({}) does not exist", music_path);
process::exit(-1);
}
if !mpath.is_dir() {
log::error!("Music path ({}) is not a directory", music_path);
process::exit(-1);
}
if task.eq_ignore_ascii_case("tags") {
analyse::read_tags(&db_path, &mpath);
} else if task.eq_ignore_ascii_case("ignore") {
let ignore_path = PathBuf::from(&ignore_file);
if !ignore_path.exists() {
log::error!("Ignore file ({}) does not exist", ignore_file);
process::exit(-1);
}
if !ignore_path.is_file() {
log::error!("Ignore file ({}) is not a file", ignore_file);
process::exit(-1);
}
analyse::update_ignore(&db_path, &ignore_path);
} else {
analyse::analyse_files(&db_path, &mpath, dry_run, keep_old, max_num_tracks);
}
}
}
}

View File

@ -18,10 +18,19 @@ fn fail(msg:&str) {
process::exit(-1);
}
pub fn stop_mixer(lms:&String) {
let stop_req = "{\"id\":1, \"method\":\"slim.request\",\"params\":[\"\",[\"blissmixer\",\"stop\"]]}";
log::info!("Asking plugin to stop mixer");
match ureq::post(&format!("http://{}:9000/jsonrpc.js", lms)).send_string(&stop_req) {
Ok(_) => { },
Err(e) => { log::error!("Failed to ask plugin to stop mixer. {}", e); }
}
}
pub fn upload_db(db_path:&String, lms:&String) {
// First tell LMS to restart the mixer in upload mode
let start_req = "{\"id\":1, \"method\":\"slim.request\",\"params\":[\"\",[\"blissmixer\",\"start-upload\"]]}";
let stop_req = "{\"id\":1, \"method\":\"slim.request\",\"params\":[\"\",[\"blissmixer\",\"stop\"]]}";
let mut port:u16 = 0;
log::info!("Requesting LMS plugin to allow uploads");
@ -76,11 +85,7 @@ pub fn upload_db(db_path:&String, lms:&String) {
.send(buffered_reader) {
Ok(_) => {
log::info!("Database uploaded");
log::info!("Asking plugin to stop mixer");
match ureq::post(&format!("http://{}:9000/jsonrpc.js", lms)).send_string(&stop_req) {
Ok(_) => { },
Err(_) => { }
}
stop_mixer(lms);
},
Err(e) => {
fail(&format!("Failed to upload database. {}", e));
@ -96,4 +101,4 @@ pub fn upload_db(db_path:&String, lms:&String) {
fail(&format!("Failed to open database. {}", e));
}
}
}
}