Home

Awesome

YAMS

Yet Another MPD Scrobbler (For Last.FM)

Code style: black

YAMS is exactly what its name says it is.

Features

YAMS is just your run of the mill Last.FM scrobbler. But, if you really need to know, it can do the following:

Requirements

PyYAML, psutil and python-mpd2 are required. YAMS is written for python3 only.

Installation

Via Pip

Run pip3 install YAMScrobbler (or maybe just pip, depending on your system)

Via the AUR

If you're an Arch Linux user you may use the python-yams package in the AUR to install YAMS locally. Please see here for instructions if you're new to AUR packages.

Note: For those who want to install the -git variant of the AUR package, checkout this repo and use the provided PKGBUILD at the repository's root folder. That is: check out the repo, cd in, and run makepkg -s to generate an installable package. The PKGBUILD can be re-used to apply updates.

From Source

Clone this repo and run pip3 install --user -e <path_to_repo> (omit the -e flag if you don't want changes in the repo to be reflected in your local installation; likewise one can omit the --user flag for a system-wide installation, though it's really not recommended).

Unofficial Sources

Please note that these are not official builds, and are not vouched for by YAMS' maintainer. It's up to you to do your due diligence and ensure you're not installing anything nasty. If you aren't comfortable with that, please consider using one of the official methods, listed above.

Running

The script includes a yams script that will be installed by pip.

yams runs as a daemon by default (yams -N will run it in the foreground).

yams -k will kill the current running instance.

yams -a will attach to the current running instance's log file, allowing you to watch the daemon's output.

yams -h will print all the options (also available below).

NB: (If you can't access the yams script, maybe because pip's script install directory isn't in your $PATH or something, python3 -m yams will also do the trick.)

Via Systemd

A Systemd user service unit file is included in the root of this repository (named yams.service). This can be used to automate starting/stopping YAMS on startup, for a specific user. (Note for users who installed from the AUR: The service file is automatically installed with the PKGBUILD, you just need to start it with systemctl)

To install, copy it to ~/.config/systemd/user/ and run systemctl --user enable --now yams to enable/start it. Note that you should also start mpd as a Systemd service to ensure YAMS actually loads up at the right time. You might also need to edit the path to the python binary in the unit file if your system python version is installed anywhere other than /usr/bin/python3.

Note: If you can't start MPD as a service before yams, make sure to use the --keep-alive argument to prevent YAMS from shutting down after failing to connect to MPD.

Via Launchd (OS X)

OS X users can use the yams.plist file at the root of this repository to automate starting/stopping YAMS via OS X's built-in launchd. Note that this file must be installed manually.

To load the program, copy yams.plist to: $HOME/Library/LaunchAgents/

To start YAMS, either re-login, or run launchctl load -w ~/Library/LaunchAgents/yams.plist

Once loaded, check that everything is running fine with yams -a

Note: The plist expects a Homebrew installation of Python to be available at /usr/local/bin/python3 to work. For systems not using Homebrew's python, edit yams.plist and change the first string in the ProgramArguments array to point to your Python binary (or just call YAMS directly). I've left some comments in there to help you out.

Setup

YAMS will use the usual $MPD_HOST and $MPD_PORT environment variables to connect to mpd, if they exist.

Run yams and follow the printed instructions to authenticate with Last.FM

Configuration Files

If it can't find a config file by default, YAMS will create a default config file, log, cache, and session file.

The locations of these folders are different for every platform, consult platformdirs for more info.

Help

Here's the output for --help:

usage: YAMS [-h] [-m 127.0.0.1] [-p 6600] [-s ./.lastfm_session]
            [--api-key API_KEY] [--api-secret API_SECRET] [-t 50] [-r] [-d]
            [-g] [-l /path/to/log] [-c /path/to/cache] [-C ~/my_config] [-N]
            [-D] [-k] [--disable-log] [--keep-alive] [-a]

Yet Another Mpd Scrobbler, v0.7.3. Configuration directories are either
~/.config/yams, ~/.yams, or your current working directory. Create one of
these paths if need be.

options:
  -h, --help            show this help message and exit
  -m 127.0.0.1, --mpd-host 127.0.0.1
                        Your MPD instance's host
  -p 6600, --mpd-port 6600
                        Your MPD instance's port
  -s ./.lastfm_session, --session-file-path ./.lastfm_session
                        Where to read in/save your session file to. Defaults
                        to inside your $XDG_STATE_HOME directory. (Default:
                        '$HOME"/.local/state/yams')
  --api-key API_KEY     Your last.fm api key
  --api-secret API_SECRET
                        Your last.fm api secret
  -t 50, --scrobble-threshold 50
                        The minimum point at which to scrobble, defaults to 50
                        percent
  -r, --real-time       Use real times when calculating scrobble times? (e.g.
                        how long you've been running the app, not the track
                        time reported by mpd). Default: True
  -d, --allow-duplicate-scrobbles
                        Allow the program to scrobble the same track multiple
                        times in a row? Default: False
  -g, --generate-config
                        Save the entirety of the running configuration to the
                        config file, including command line arguments. Use
                        this if you always run yams a certain fashion and want
                        that to be the default. Default: False
  -l /path/to/log, --log-file /path/to/log
                        Full path to a log file. If not set, a log file called
                        "yams.log" will be placed in $XDG_STATE_HOME.
                        (Default:"$HOME"/.local/state")
  -c /path/to/cache, --cache-file /path/to/cache
                        Full path to the scrobbles cache file. This stores
                        failed scrobbles for upload at a later date. If not
                        set, a log file called "scrobbles.cache" will be
                        placed in the $XDG_CACHE_HOME.
                        (Default:"$HOME"/.cache")
  -C ~/my_config, --config ~/my_config
                        Your config to read
  -N, --no-daemon       If set to true, program will not be run as a daemon
                        (e.g. it will run in the foreground) Default: False
  -D, --debug           Run in Debug mode. Default: False
  -k, --kill-daemon     Will kill the daemon if running - will fail otherwise.
                        Default: False
  --disable-log         Disable the log? Default: False
  --keep-alive          If set to True will not exit on initial MPD connection
                        failure. (E.g. always reconnect) Default: False
  -a, --attach          Runs "tail -F" on a running instance of yams' log
                        file. "Attaches" to it, for all intents and purposes.
                        NB: You will still need to kill it by hand. Default:
                        False

Contributing

Other Information