GioF71 / mpd-subsonic-scrobbler

A Subsonic Scrobbler for Music Player Daemon, written in Python
MIT License
6 stars 0 forks source link
docker gonic lightweight-media-server mpd navidrome python python-mpd2 scrobbler subsonic subsonic-client upmpdcli

mpd-subsonic-scrobbler

This is a very simple Subsonic scrobbler for MPD.
It is not a LAST.FM or libre.fm scrobbler.
This scrobbler allows mpd to notify a subsonic server when it has played a song which has been server from that subsonic server. The subsonic server might, if configured, scrobble the song to LAST.FM, libre.fm, etc.
It might be useful when using the Subsonic plugin for Upmpdcli. See the discussion here.

Support

ko-fi
Please see the Goal.
Please note that support goal is limited to cover running costs for subscriptions to music services.

Important notice

Initially I used this docker repo. I then noticed that it was named differently from the github repo.
So I created a new docker hub repo here and updated the documentation.
The old docker hub repo will not receive updates of course. Please correct your docker compose/run so that they reference the correct image name.
Sorry for the inconvenience

Links

Related projects

PROJECT Git Repo(s)
Music Player Daemon On GitHub
Upmpdcli Framagit (Mirror). My Fork (Mirror)
mpd-alsa-docker GitHub
upmpdcli-docker GitHub
subsonic-connector GitHub
python-mpd2 GitHub

Among those, mpd-alsa-docker and upmpdcli-docker provide a method for deploying mpd and upmpdcli using docker.

Repositories for this project

Repo URL
Source code GitHub
Docker images Docker Hub

Available Archs on Docker Hub

Usage

Volumes

VOLUME DESCRIPTION
/config Suggested location for additional configuration files

Enviroment Variables

VARIABLE DESCRIPTION DEFAULT
MPD_FRIENDLY_NAME Friendly name of the mpd instance
MPD_HOST MPD hostname localhost
MPD_PORT MPD port 6600
SUBSONIC_FRIENDLY_NAME Friendly name of the subsonic server
SUBSONIC_PARAMETERS_FILE Separate config file for subsonic parameters
SUBSONIC_BASE_URL Subsonic Server URL, including http or https
SUBSONIC_PORT Subsonic Server Port
SUBSONIC_USER Subsonic Username
SUBSONIC_PASSWORD Subsonic password
SUBSONIC_LEGACYAUTH Legacy authentication, required to true for lms, defaults to false
SUBSONIC_CREDENTIALS Reference to a file with credentials, alternative to specifying SUBSONIC_USER and SUBSONIC_PASSWORD
SUBSONIC_UPMPDCLI_BASE_URL If set, only this upmpdcli server will be allowed (base url)
SUBSONIC_UPMPDCLI_PORT If set, only this upmpdcli server will be allowed (port)
MIN_COVERAGE Percent of the song that needs to be played 50
ENOUGH_PLAYBACK_SEC Minimum playback time needed for a scrobble, regardless of coverage, defaults to 240
SLEEP_TIME Interval between a coverage check and the next, in millisec 1000
REDACT_CREDENTIALS If set to 1, credentials are not displayed on startup
MAX_SUBSONIC_SERVERS Max number of SubSonic servers, defaults to 10
MAX_MPD_INSTANCES Max number of MPD instances, defaults to 10
MPD_CLIENT_TIMEOUT_SEC Mpd client timeout, defaults to 0.05 (one value across all mpd instance)
ITERATION_DURATION_THRESHOLD_PERCENT If total handle_playback elapsed time is greater than this percentage of SLEEP_TIME, a warning is displayed on the standard output. In this case, you should increase SLEEP_TIME, reduce MPD_CLIENT_TIMEOUT_SEC, or increase this threshold
MPD_IMPOSED_SLEEP_ITERATION_COUNT Number of iteration an instance of mpd must sleep when it appears to not be accessible, defaults to 30
VERBOSE Verbose output, valid values are 1 and 0 0

The subsonic configuration parameters are required: either specificy the individual variables, or specify a SUBSONICPARAMETERS to indicate the file which will contain the parameters. The file must be accessible to the container. You can use the /config volume and put a file named, e.g. ".subsonic.env" there.
All the `MPD
(unless specified) andSUBSONIC_variables can be suffixed with_1,_2,_3` etc in order to configure multiple mpd instances and multiple SubSonic servers.
Inside a single config file, even if it refer to an index > 0, the variable names must be specified without the index.

Example configurations

The following compose file creates a subsonic scrobbler for mpd-d10 (as it operates on a Topping D10 DAC) and mpd-d200 (as it operates on a Yulong D200 DAC), which are instances of mpd-alsa-docker running on the same host and specifically on the network mpd.
Subsonic config is read from a separate file.

---
version: "3"

networks:
  mpd:
    external: true

services:
  scrobbler:
    image: giof71/mpd-subsonic-scrobbler:latest
    container_name: subsonic-scrobbler-d10
    networks:
      - mpd
    environment:
      - MPD_HOST=mpd-d10
      - MPD_PORT=6600
      - MPD_HOST_1=mpd-d200
      - MPD_PORT_1=6600
      - SUBSONIC_PARAMETERS_FILE=/config/my-navidrome.env
      - SUBSONIC_PARAMETERS_FILE_1=/config/navidrome-demo.env
      - VERBOSE=0
    volumes:
      - ./my-navidrome.env:/config/my-navidrome.env:ro
      - ./navidrome-demo.env:/config/navidrome-demo.env:ro
    restart: unless-stopped

Same situation, without the separate file:

---
version: "3"

networks:
  mpd:
    external: true

services:
  scrobbler:
    image: giof71/mpd-subsonic-scrobbler:latest
    container_name: subsonic-scrobbler-d10
    networks:
      - mpd
    environment:
      - MPD_HOST=mpd-d10
      - MPD_PORT=6600
      - MPD_HOST_1=mpd-d200
      - MPD_PORT_1=6600
      - SUBSONIC_BASE_URL=${MY_NAVIDROME_BASE_URL}
      - SUBSONIC_PORT=${MY_NAVIDROME_PORT}
      - SUBSONIC_USER=${MY_NAVIDROME_USER}
      - SUBSONIC_PASSWORD=${MY_NAVIDROME_PASSWORD}
      - SUBSONIC_BASE_URL_1=${NAVIDROME_DEMO_BASE_URL}
      - SUBSONIC_PORT_1=${NAVIDROME_DEMO_PORT}
      - SUBSONIC_USER_1=${NAVIDROME_DEMO_USER}
      - SUBSONIC_PASSWORD_1=${NAVIDROME_DEMO_PASSWORD}
      - VERBOSE=0
    restart: unless-stopped

In this case, the configuration parameters are read from the .env file.
In order to avoid issues with password, which might contain special characters, it is better to not place such password on the compose file, and leverage the .env file instead.

Releases

Release 0.5.3

Release 0.5.2

Release 0.5.1

Release 0.5.0 (2024-04-19)

Release 0.4.0 (2023-11-13)

Release 0.3.6 (2023-11-11)

Release 0.3.5 (2023-11-11)

Release 0.3.4 (2023-11-11)

Release 0.3.3 (2023-11-11)

Release 0.3.2 (2023-11-06)

Release 0.3.1 (2023-11-04)

Release 0.3.0 (2023-11-04)

Release 0.2.2 (2023-10-28)

Release 0.2.1 (2023-10-28)

Release 0.2.0 (2023-05-25)

Release 0.1.2 (2023-05-18)

Release 0.1.1 (2023-05-13)

Release 0.1.0 (Initial Release, 2023-05-12)