Serveur de musique Mopidy - Configuration

mopidy est un serveur audio léger et modulaire. Ce document décrit la configuration

Références

Sommaire


1 - Configuration

1.1 - Configuration en mode application utilisateur

$ mopidy config
......
$ cat .config/mopidy/mopidy.conf 
# For further information about options in this file see:
# https://docs.mopidy.com/
#
.....
.....

1.2 - Configuration en mode service

$ sudo cat /etc/mopidy/mopidy.conf

[http]
hostname = 192.168.0.20

[file]
media_dirs = /var/lib/mopidy/Music

[local] media_dir = /var/lib/mopidy/Music
$ sudo mkdir /var/lib/mopidy/Music
$ sudo chown -R mopidy:audio /var/lib/mopidy/Music
$ sudo mkdir /var/lib/mopidy/m3u
$ sudo chown -R mopidy:audio /var/lib/mopidy/m3u

par exemple

$ ls -l /var/lib/mopidy/m3u/
total 16
-rw------- 1 mopidy audio 614 nov. 28 15:16 '[Radio Streams].m3u8'
$ sudo mopidyctl config

1.3 - Exemple de fichier de configuration

$ cat .config/mopidy/mopidy.conf
[http]
hostname = 192.168.0.20

[file]
media_dirs = ~/Music

[local] media_dir = ~/Music

2 - Extensions intégrées à Mopidy

2.1 - Serveur web - Mopidy-http

$ links2 http://localhost:6680
# équivalent à
$ links2 http://127.0.0.1:6680
[http]
....
#hostname = 127.0.0.1

par l'adresse du raspberry sur le réseau local, dans notre exemple192.168.0.20

[http]
....
hostname = 192.168.0.20
$ links2 http://192.168.0.20:6680
(PC_client) $ firefox http://192.168.0.20:6680

2.2 - Explorateur de fichier audio - Mopidy-file

[file]
....
# $XDG_MUSIC_DIR|Music
# ~/|Home
[file]
...
media_dirs = ~/Music

2.3 - Playlists m3u - Mopidy-m3u

 .local/share/mopidy/m3u
$ cat .local/share/mopidy/m3u/mes_stations.m3u8 
#EXTM3U

#EXTINF:-1,ANTENNE BAYERN Schlagersahne
http://stream.antenne.de/das-schlager-karussell

.....

-1 indique qu'il s'agit d'un flux sans durée limite

2.4 - Flux audios - Mopidy-stream

[stream]
#enabled = true
#protocols =
# http
# https
# mms
# rtmp
# rtmps
# rtsp

3 - Installation d'extensions via les dépôts mopidy

3.1 - Principe

$ aptitude search mopidy
i mopidy - extensible music server
p mopidy-alsamixer - Mopidy extension for volume control via ALSA
p mopidy-beets - Mopidy extension for playing music from Beets' web plugin
p mopidy-dleyna - Mopidy extension for playing music from Digital Media Servers
p mopidy-doc - extensible music server - documentation
p mopidy-gmusic - Mopidy extension for playing music from Google Play Music
p mopidy-internetarchive - Mopidy extension for playing music from the Internet Archive
p mopidy-local - Mopidy extension for playing music from your local music archive
p mopidy-mpd - Mopidy extension for controlling Mopidy from MPD clients
p mopidy-mpris - Mopidy extension for controlling playback through MPRIS
p mopidy-podcast - Mopidy extension for searching and browsing podcasts
p mopidy-podcast-itunes - Mopidy extension for searching and browsing iTunes podcasts
p mopidy-scrobbler - Mopidy extension for scrobbling music to Last.fm
p mopidy-somafm - Mopidy extension for playing music from SomaFM
p mopidy-soundcloud - Mopidy extension for playing music from SoundCloud
p mopidy-spotify - Mopidy extension for playing music from Spotify
p mopidy-tunein - Mopidy extension for playing music from TuneIn
$ sudo aptitude install mopidy-local

3.2 - Installation de Mopidy-Local

$ sudo pip3 install Mopidy-Local
[local]
media_dir = ~/Music
$ Ctrl C
$ mopidy
$ mopidy local scan 

4 - Installation d'extensions via pip

4.1 - Principe

$ sudo aptitude install python3-pip

$ python3 -V
Python 3.7.3

$ pip3 -V
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
$ sudo python3 -m pip install mopidy-musicBox-webclient

Vérifier les dépendances

$ sudo pip3 check mopidy-musicbox-webclient
pygobject 3.38.0 requires pycairo, which is not installed.

Dans le cas présent, pycairo est manquant et peut-être installé avec

$ sudo python3 -m pip install pycairo

4.2 - Installation de MusicBox-Webclient

'[Radio Streams].m3u8'
$ sudo pip3 install mopidy-musicBox-webclient
$ sudo systemctl restart mopidy
(PC_client) $ firefox http://192.168.0.20:6680/mopidy/
(PC_client) $ firefox http://192.168.0.20:6680/musicbox_webclient
http://174.36.206.197:8000/listen.pls?sid=1

Annexe 1 - Exemple d'obtention de fichiers audio formats variés

$ wget https://lasonotheque.org/UPLOAD/wav/1447.wav

convertir le fichier dans différents formats utilisés, par exemple flac, ogg, mp3 (nécessite ffmpeg)

$ for i in {flac,ogg,mp3}; do ffmpeg -i file_example_WAV_1MG.wav file_example_WAV_1MG.$i; done

$ ls file*
file_example_WAV_1MG.flac file_example_WAV_1MG.ogg file_example_WAV_1MG.mp3 file_example_WAV_1MG.wav

Annexe 2 - Exemple de playlist m3u de flux radios

$ cat radio.m3u8
#EXTM3U

#EXTINF:-1,France Inter http://direct.franceinter.fr/live/franceinter-midfi.mp3?ID=76zqey582k
#EXTINF:-1,France Musique http://opml.radiotime.com/Tune.ashx?id=s50774
#EXTINF:-1,France Culture http://opml.radiotime.com/Tune.ashx?id=s50768
#EXTINF:-1,France Bleue Loire Océan
http://opml.radiotime.com/Tune.ashx?id=s36096
#EXTINF:-1,FIP Nantes
http://opml.radiotime.com/Tune.ashx?id=s50770
#EXTINF:-1,Radio Classique
http://opml.radiotime.com/Tune.ashx?id=s74355
#EXTINF:-1,Radio Venise
http://174.36.206.197:8000/listen.pls?sid=1
#EXTINF:-1,Radio Italie Classique
http://176.31.107.8:8204/listen.pls?sid=1

#EXTINF:-1,Radio Sympa
https://radio11.pro-fhi.net:19095/stream