Skip to content

Commit

Permalink
renamed package to mscout
Browse files Browse the repository at this point in the history
  • Loading branch information
hardfau1t committed Jul 8, 2023
1 parent 396f705 commit 659a615
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
edition = "2021"
name = "mpr"
name = "mscout"
version = "0.2.0"
authors = ["hardfault [email protected]"]
description = "rates song with skip/rate count for mpd"
description = "scout for mpd, listens for events, tracks the statistics, stores them either in mpd stickers or writes them directly to the metadata for permanent storage"

[dependencies]
env_logger = "0.9"
Expand Down
26 changes: 13 additions & 13 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mpr
# mscout
Its a plugin for mpd, which handles rating for each song based on play count and skip counts.

NOTE: This doesn't work if consume is enabled
Expand All @@ -12,14 +12,14 @@ NOTE: This doesn't work if consume is enabled

## Installation
building from source
* `Git clone https://github.com/hardfau18/mp_rater.git`
* `cd mp_rater`
* `Git clone https://github.com/hardfau18/mscout.git`
* `cd mscout`
* `cargo build --release`
* `cp target/release/mpr ~/.local/bin`
* `cp target/release/mscout ~/.local/bin`
* if `~/.local/bin/` path is not set then `export PATH=~/.local/bin:$PATH`. To make it permanent add it in `~/.bashrc` file.

## Running
To run `mpr`, `mpd` should be running in background and should be listening on the local network socket or unix socket file.
To run `mscout`, `mpd` should be running in background and should be listening on the local network socket or unix socket file.
To configure mpd to listening on network socket add these two lines to mpd.conf file.
```
bind_to_address "any"
Expand All @@ -36,37 +36,37 @@ There are 2 ways to store stats of songs.
By default mpd database is used to store ratings. But this is not persistent. If you move any files to a separate directories then all of the ratings of those files will reset.
id3 tags store the rating even if you move the songs. ratings will be saved in comment section of id3 tag of respective song. If you want to use id3 tags use `--socket-path <path to socket file>` option or `--root-dir <path to mpd music directory>` and with that `--use-tags` option.

If you don't want give `--use-tags` each time you can `export MPR_USE_TAGS=1` variable.
If you don't want give `--use-tags` each time you can `export MSCOUT_USE_TAGS=1` variable.


#### examples:
For listening on network socket with mpd sticker database

`mpr -a 127.0.0.1:6600 -L`
`mscout -a 127.0.0.1:6600 -L`

For listening on network socket with id3 tags

`mpr -a 127.0.0.1:6600 --use-tags -r <mpd music directory > -L`
`mscout -a 127.0.0.1:6600 --use-tags -r <mpd music directory > -L`

For listening on socket file with id3 tags

`mpr -p ~/.local/run/mpd/socket --use-tags -L`
`mscout -p ~/.local/run/mpd/socket --use-tags -L`

### retrieving ratings.
To get rating for a particular song use get-stats option. For example to get stats for current song

`mpr -a 127.0.0.1:6600 -G --current`
`mscout -a 127.0.0.1:6600 -G --current`

Or to get stats for any other song, give a path relative to mpd music directory

`mpr -a 127.0.0.1:6600 -G <relative path to song>`
`mscout -a 127.0.0.1:6600 -G <relative path to song>`

To get stats from whole playlist.

`mpr -G --playlist <playlist> ...`
`mscout -G --playlist <playlist> ...`

To get stats from currrent queue.

`mpr -G -Q `
`mscout -G -Q `

use -s flags to get exact play and skip count
14 changes: 7 additions & 7 deletions src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ impl ListenerState {
}
}

/// creates a lock file indicating that mpr is running
/// if mpr crashes and this file is not cleaned up, removie it manually
const LOCK_NAME: &str = "mpr.lck";
/// creates a lock file indicating that mscout is running
/// if mscout crashes and this file is not cleaned up, removie it manually
const LOCK_NAME: &str = "mscout.lck";

/// checks if any other instance of listener is running, if not then create flag file indicating that a listener is running
fn init_listener(notif: &mut notify_rust::Notification) {
Expand Down Expand Up @@ -282,13 +282,13 @@ fn init_listener(notif: &mut notify_rust::Notification) {
println!(
"Already another instance is running!!!\n\
kill that instance to start another.\n\
if not running then remove /tmp/mpr.lck file"
if not running then remove /tmp/mscout.lck file"
);
}
_ => error!("failed to check for instance {:?}", err),
}
notif
.body("Failed to start mpr may be already started")
.body("Failed to start mscout may be already started")
.show()
.ok();
exit(1);
Expand All @@ -298,7 +298,7 @@ fn init_listener(notif: &mut notify_rust::Notification) {
std::thread::spawn(move || {
for sig in signals.forever() {
Notification::new()
.summary("mpr")
.summary("mscout")
.timeout(10000)
.urgency(Urgency::Low)
.icon("/usr/share/icons/Adwaita/scalable/devices/media-optical-dvd-symbolic.svg")
Expand All @@ -317,7 +317,7 @@ fn init_listener(notif: &mut notify_rust::Notification) {
pub fn listen(client: &mut mpd::Client<ConnType>, use_tags: bool) -> ! {
let mut notif = Notification::new();
notif
.summary("mpr")
.summary("mscout")
.timeout(10000)
.urgency(Urgency::Low)
.icon("/usr/share/icons/Adwaita/scalable/devices/media-optical-dvd-symbolic.svg");
Expand Down
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::io::{Read, Write};
use std::path::PathBuf;

/// header name which will be used on either mpd's sticker database or tags for identifications
pub const MP_DESC: &str = "mpr";
pub const MP_DESC: &str = "msout";

/// defines connection type for the mpd.
#[derive(Debug)]
Expand Down Expand Up @@ -93,7 +93,7 @@ enum Commands {
Clear,
}

/// Arguments for mpr
/// Arguments for mscout
#[derive(Parser, Debug)]
#[command(author, version, about)]
struct Config {
Expand All @@ -104,7 +104,7 @@ struct Config {
#[arg(short, long, action=clap::ArgAction::Count)]
verbose: u8,
/// use eyed3 tags to store ratings. If not specified by default mpd stickers are used. tags are persistante across file moves, where as incase of mpd sticker these will be erased if you move the files.
#[arg(short = 't', long, env = "MPR_USE_TAGS")]
#[arg(short = 't', long, env = "MSCOUT_USE_TAGS")]
use_tags: bool,
/// path to mpd socket.
/// if both path and socket address are specified, then path has higher priority.
Expand All @@ -117,7 +117,7 @@ struct Config {
/// mpd socket address. <host>:<port> ex. -a 127.0.0.1:6600
#[arg(short = 'a', long, default_value = "127.0.0.1:6600")]
socket_address: String,
/// subcommands for mpr
/// subcommands for mscout
#[command(subcommand)]
command: Commands,
}
Expand All @@ -128,11 +128,11 @@ fn main() {

// set the verbosity
match arguments.verbose {
0 => builder.filter_module("mpr", log::LevelFilter::Error).init(),
1 => builder.filter_module("mpr", log::LevelFilter::Warn).init(),
2 => builder.filter_module("mpr", log::LevelFilter::Info).init(),
3 => builder.filter_module("mpr", log::LevelFilter::Debug).init(),
4 => builder.filter_module("mpr", log::LevelFilter::Trace).init(),
0 => builder.filter_module("mscout", log::LevelFilter::Error).init(),
1 => builder.filter_module("mscout", log::LevelFilter::Warn).init(),
2 => builder.filter_module("mscout", log::LevelFilter::Info).init(),
3 => builder.filter_module("mscout", log::LevelFilter::Debug).init(),
4 => builder.filter_module("mscout", log::LevelFilter::Trace).init(),
_ => {
builder.filter_level(log::LevelFilter::Trace).init();
trace!("wait one of the rust expert is coming to debug");
Expand Down

0 comments on commit 659a615

Please sign in to comment.