alphapapa / mpdsync

Python program to synchronize multiple MPD servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mpdsync

mpdsync is a simple way to synchronize multiple MPD servers so that they’re all playing the same thing, at the same time, with the same playlist.

Requirements

  • Two or more MPD servers (duh!) which have identical music databases, like a network share
  • Python 2.6+
  • python-mpd2 (This is a new fork of python-mpd, and it may not be in your distro’s repo yet. You can install it with pip. Use the --user switch if you want to install it as a user instead of as root).

Setup

One MPD server will be considered the master and all the others will be slaves. Once that’s taken care of, all you have to is run the mpdsync.py file!

Upon startup, mpdsync will propagate the playlist and player state from the master to all of the slaves. Then mpdsync waits for the master server to do something, such as modify the playlist, and then makes the same changes to the slaves.

Examples

Usage is very simple:

usage: mpdsync.py [-h] [-m MASTER] [-s [SLAVES [SLAVES ...]]] [-p PASSWORD]
                  [-l] [-v]

Syncs multiple mpd servers.

optional arguments:
  -h, --help            show this help message and exit
  -m MASTER, --master MASTER
                        Name or address of master server, optionally with port
                        in HOST:PORT format
  -s [SLAVES [SLAVES ...]], --slaves [SLAVES [SLAVES ...]]
                        Name or address of slave servers, optionally with port
                        in HOST:PORT/LATENCY format
  -p PASSWORD, --password PASSWORD
                        Password to connect to servers with
  -l, --latency-adjust  Monitor latency between master and slaves and try to
                        keep slaves' playing position in sync with the
                        master's
  -v, --verbose         Be verbose, up to -vv

So if your master server were on the local machine, and you wanted to also play music on a machine in the kitchen and a machine in the basement, you would simply run:

mpdsync.py -m localhost -s kitchen basement

Or if your master server were in the living room, and occasionally you wanted to sync your bedroom’s MPD instance with it, you could run this from the bedroom machine:

mpdsync.py -m livingroom -s localhost

Development

Contributions are welcome!

TODOs

  • Sync player settings (e.g. shuffle, repeat). Simple, just haven’t bothered yet. Although some of these should probably not be synced, because the master should control which tracks play, etc.
  • Due to network latency and and MPD’s idle command, playback can’t be perfectly synced. We try to workaround this by adjusting for latency (the -l option), but it’s not perfect. It probably cannot be completely fixed without implementing it in MPD itself. For some interesting reading, see:
  • It might be handy for adjusting the volume on the master to (optionally) proportionally adjust the volume on all of the slaves.

Credits

mpdsync was originally written by Nick Pegg (https://github.com/nickpegg/mpdsync). Nick doesn’t use it much anymore, so he transferred the project to me.

License

GPLv3

About

Python program to synchronize multiple MPD servers

License:GNU General Public License v3.0


Languages

Language:Python 100.0%