Skip to content

Hackerspace Music Server Guide

robotanarchy edited this page Sep 28, 2014 · 7 revisions

This is a rough guide to setting up a music server with mpd, beets and beetwerk from scratch. If you only need the beetwerk part, skip the rest.

toc

unix

So far, beetwerk has been tested on Arch Linux and Debian. It should work on any POSIX OS, that runs nodejs and python2. You probably have a very strong opinion on what is the right system anyway, so choose what you like.

beets

install

Add a new user called beets (or whatever the heck you like), read man 8 useradd if you need to.

It is important, that you always install the latest greatest version of beets, because otherwise you will have broken API calls in the discogs plugin for example, and also miss some of the awesome features that are only in the new versions. So in case you run a bleeding edge distribution, simply install it with your package manager.

In case it is not packaged or you run something solid as a mountain (read: outdated), then you are better off using the python package manager pip:

# su beets
% pip install --user beets discogs-client

The discogs-client package allows beets to use the Discogs database side by side with the one from MusicBrainz, when properly configured (see below).

config

Fire up your favorite editor and start hacking on your very own beets config file:

% EDITOR=nano beet config -e

That is not a typo there, the beets main executable is called beet. Its developers also do a very good job in writing a documentation, so open it in a new tab, and read on below for a beetwerk specific example config:

directory: "~/music_sorted"
threaded: yes
art_filename: cover

import:
    write: yes
    copy: no
    move: yes
    delete: no
    resume: ask
    incremental: no
    quiet_fallback: skip
    none_rec_action: ask
    timid: no
    autotag: yes
    quiet: no
    default_action: apply
    languages: [ "de",  "en" ]
    flat: no
    group_albums: no

paths:
    default: $genre/$albumartist/$album%aunique{}/$track $title
    singleton: $genre/$artist/$title
    comp: Compilations/$album%aunique{}/$track $title

# Notes about specific plugins:
# lastgenre:
#     You probably have lots of people with a different taste of music genre. To make it easier
#     to find the music, use the lastgenre plugin to fetch the genre associated by most users
#     and also streamline more obscure genres into coarser-grained ones.
#     See also: paths, lastgenre
# importfeeds:
#    Show the location of imported music and also create the /home/beets/imported.m3u file, which
#    is a log that contains the new files at the bottom.
#    See also: importfeeds
# mpdupdate:
#    Automagically updates your MPD database, so you can drag the songs in the playlist right away!
#
plugins: fromfilename lyrics lastgenre fetchart embedart replaygain duplicates importfeeds mpdupdate discogs

lastgenre:
    source: artist
    canonical: true

replaygain:
    backend: gstreamer

importfeeds:
    formats: m3u echo
    dir: ~/
    relative_to: /home/beets/music_sorted/

Make sure, that your beets user has the required permissions for the music collection directory. When you're done, import an album to check if everything works fine. We'll grab the CC-BY-NC-SA licensed pornophonique album 8-bit lagerfeuer in this example. Don't be offended by the name, it is really nice music from hackers with a gameboy and everything.

% mkdir Downloads
% cd Downloads
% wget "https://storage-new.newjamendo.com/albums/pornophonique - 8-bit lagerfeuer - a7505 --- Jamendo - MP3.zip"
% unzip porn*.zip
% beet import .

mpd

While this is not a hard dependency, it makes a lot of sense to choose mpd as your music server.

reasons

  • built from the ground up as a server
  • everyone in the LAN can access/modify the playlist
  • lots of clients for terminals, browsers, X11/Wayland and about every smartphone

config

Read man 5 mpd.conf, set up typical stuff like the music library path (it must be the same as, or include the beets directory!) and make sure that you enable replaygain (set it to track). When you wish to play full albums, you may set it temporarily to album in your client.

client

If you don't know which client you should use, check out:

testing

Start your mpd server and launch a client, use it to play the album that you have downloaded earlier. When everything works, read on!

beetwerk

At this point, you should have set up a music player and beets, both with working and tested configurations. Install nodejs on your operating system and use npm, the node package manager, to install beetwerk. You should run this command as the user who should normally run beets, because npm installs its packages locally by default (which is what we want exactly).

% cd ~
% npm install beetwerk

To be able to start beetwerk by typing its name, add the new nodejs folder to your PATH variable in your beets user's shells configuration file (eg. ~/.bash_profile) and perform a new login before starting beetwerk for the first time:

% echo "PATH=\$PATH:~/node_modules/.bin" >> ~/.bash_profile
% exit
# su beets
% beetwerk

Start beetwerk once, to let it generate the default config (it will give you the path) and modify the file manually. After that, start beetwerk again and it will be ready to be accessed via the webinterface. Grab any laptop or phone in your reach, point its browser to http://yourmusicserver:1234/ and upload as many albums, as you like, one at a time!

display

Now that you have your all-new sorted library with shiny tags, it's time to set up some fancy display device. Basically anything will do, but make sure it is huge and easy to read. In our hackerspace, we have reverse engineered a nice Lumino display for that purpose (more information, in german).

Clone this wiki locally