[GUIDE] MPD + Despotify


16 posts
by SheepOnMeth » Tue Jun 26, 2012 10:41 pm
Hello everybody, this guide is for everyone with a Spotify Premium account, a Raspberry Pi running Archlinux with the sound working (I did not test it on other distribution), knowledge on how to build a source code on Linux and 15 ~ 20 minutes :) .

The simple solution to use a Spotify account to play music on the Raspberry Pi is Despotify. But the client is too minimalist for me. You can not control it with other tools or use it with other interface.
MPD, on the other hand is know to be a powerful application.

MPD is " a flexible, powerful, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol."

MPD is not http://mpd.wikia.com/wiki/What_MPD_Is_and_Is_Not.

One year ago @simonkagstrom start working on a plugin for MPD : Spotify support via despotify http://thread.gmane.org/gmane.comp.audio.musicpd.devel/1928

I use it everyday (if the soundcard doesn't crash) to play my Spotify playlist on my Pi, and I can control my Raspotify Box with my Android device via MPDroid https://play.google.com/store/apps/details?id=com.namelessdev.mpdroid&hl=fr

Because the Despotify version hack by Simon Kagstrom is not maintain, my solution is not very clean.

Step 1 : Install the not working Despotify version of @simonkagstrom on your Pi
(You need to be root / sudo.)
    Install these packages
Code: Select all
pacman -Sy libtool git openssl mpg123 libvorbis ncurses libao git base-devel

    Download the code
Code: Select all
 git clone git://github.com/SimonKagstrom/despotify.git

    Build the code
Code: Select all
cd despotify/src && make && make install && sudo make install


Step 2 : Install MPD
    Download the code
Code: Select all
 git clone git://git.musicpd.org/master/mpd.git

    Options
You can disable or enable plugin/sound server/ ... :
Code: Select all
 cd mpd && ./autogen.sh --enable-despotify

If everything is good, at the end you will have something like that :
Code: Select all
########### MPD CONFIGURATION ############

Archive support:
   (-bzip2) (-ISO9660) (-ZIP)
Client support:
   (+IPv6) (+TCP) (+UNIX Domain Sockets)
File format support:
   (+AAC) (-C64 SID) (+FFMPEG) (+FLAC) (-FluidSynth) (-GME) (+libsndfile)
   (-MikMod) (-MODPLUG) (+MAD) (+MPG123) (+MP4) (-Musepack)
   (-OggTremor) (+OggVorbis) (-WAVE) (-WavPack) (-WildMidi)
Other features:
   (+libsamplerate) (+inotify) (+SQLite)
Metadata support:
   (+ID3)
Playback support:
   (+ALSA) (-FFADO) (+FIFO) (+File Recorder) (+HTTP Daemon) (+JACK)
   (+libao) (-Media MVP) (+OSS) (-OpenAL) (-OS X) (-Pipeline)
   (+PulseAudio) (-ROAR) (-SHOUTcast) (-Solaris) (-WinMM)
Streaming encoder support:
   (+FLAC) (+LAME) (+Ogg Vorbis) (-TwoLAME) (+WAVE)
Streaming support:
   (+CDIO_PARANOIA) (+CURL) (+Despotify) (-Last.FM) (+Soundcloud)
   (+MMS) (-SOUP)


Be sure to have +ALSA & +Despotify.
    Build the code
Code: Select all
make && sudo make install


Step 3 : Uninstall Despotify
    Uninstall
Code: Select all
cd despotify/src && sudo make uninstall


Step 4 : Install the working version of Despotify
    Install this package
Code: Select all
pacman -Sy svn

    Download the code
Code: Select all
 svn co https://despotify.svn.sourceforge.net/svnroot/despotify/src despotify

    Build the code
Code: Select all
 cd despotify && make && sudo make install


Step 5 : Configuration of MPD
The file to edit is /etc/mpd.conf . " You should have a copy of an example config in one of two places on your computer: /usr/doc/mpd.conf.example or /usr/local/doc/mpd.conf.example" http://mpd.wikia.com/wiki/Music_Player_Daemon_Example_Config

To simplify, you can use mine, but you will need to create some file and dir :
Code: Select all
mkdir -p ~/.mpd/playlists

Code: Select all
touch ~/.mpd/{mpd.db,mpd.log,mpd.pid,mpdstate}


My mpd.conf : http://pastebin.com/PNaxGYJb

4 things need to be change from my mpd.conf : music_directory (dir with your mp3s), user (name of the user), despotify_user (Spotify user) & despotify_password (Spotify password) .

Save the file at /etc/mpd.conf

Step 6 : Start MPD
Code: Select all
sudo mpd  /etc/mpd.conf &


Step 7 : Client
I use ncmpcpp, but they are many : http://mpd.wikia.com/wiki/Clients
MPC is a simple MPD client via command line.
Code: Select all
pacman -Sy mpc ncmpcpp

    Start your MPD client
Image

Step 8 : Add a song / a playlist from Spotify to the MPD playlist
Code: Select all
mpc load spt://[SPOTIFY URI]

The spotify URI can be found with the desktop client.
For example :
Code: Select all
mpc load spt://spotify:track:1li0jGGRIaMaNNRBV8JXZ4


Image

Step 9 :
Enjoy 8-)

If you have any question, please ask on the forum or @SheepOnMeth. I will do my best to help you.
Posts: 9
Joined: Wed May 30, 2012 1:39 pm
by volcacius » Fri Jul 20, 2012 7:11 pm
check out mopidy, it's an MPD server written specifically for spotify and it's based on official libspotify, it works quite well.
Posts: 2
Joined: Fri Jul 20, 2012 7:08 pm
by SheepOnMeth » Sat Jul 21, 2012 1:30 pm
Hi, indeed.

Mopidy is very simple to install and to use. It's working well on my x86.
I'm trying to install it on my Pi.
Thx for the tip.
Posts: 9
Joined: Wed May 30, 2012 1:39 pm
by emempe » Sat Jul 21, 2012 8:48 pm
Did you have any luck with mopidy? I can't get it to work ... see here: https://github.com/mopidy/mopidy/issues/153

Your guide for MPD looked interesting. I have troubles building MPD though. I got the most recent version of despotify. It compiled and works with the provided clients (simple and despotify).

When I clone MPD from git and run
Code: Select all
./autogen.sh --enable-despotify
everything looks fine.
Code: Select all
make
throws a lot of errors then, something despotify related which I don't understand. The complete output is here: http://pastebin.com/T73ZJC7H

Does anybody have an idea what's going wring there? I'd really like to use my Pi as a Spotify box ;)
Posts: 2
Joined: Sat Jul 21, 2012 8:41 pm
by SheepOnMeth » Sat Jul 21, 2012 8:58 pm
You need to use the patch version of despotify, when you compile mpd. Then install the last version of despotify. :)
Posts: 9
Joined: Wed May 30, 2012 1:39 pm
by volcacius » Sun Jul 22, 2012 11:15 am
Mopidy needs wheezy. There's probably a way to get it running on squeeze, but eventually I decided that upgrading my arm box to wheezy was the simpliest solution (obviously being an unstable release it has its caveats). See my issue here https://github.com/mopidy/mopidy/issues/154
Posts: 2
Joined: Fri Jul 20, 2012 7:08 pm
by emempe » Mon Jul 23, 2012 8:38 am
Unfortunately, Mopidy doesn't work on Wheezy for Raspberry Pi. There is a weird issue with libspotify: It compiled but pyspotify/Mopidy can't find the library in /usr/local/lib. I tried "export LD_LIBRARY_PATH ..." etc but nothing worked. Which version of libspotify are you using?
Posts: 2
Joined: Sat Jul 21, 2012 8:41 pm
by SheepOnMeth » Mon Jul 23, 2012 9:42 am
Segmentation error with Archlinux, when I start mopidy. I use libspotify armv6.
Posts: 9
Joined: Wed May 30, 2012 1:39 pm
by mcatominey » Mon Aug 27, 2012 10:05 pm
There are now working instructions for how to get Mopidy running on a RaspberryPi on the github wiki: https://github.com/mopidy/mopidy/wiki/MopidyOnRaspberryPi
Posts: 1
Joined: Mon Aug 27, 2012 10:03 pm
by bz31 » Mon Sep 24, 2012 1:16 pm
Hi,
The best current solution is
Logitech Media Player + SqueezePlay + Triode Spotify Plugin
+ Logitech Squeezebox Controller App(on mobile phones).
Posts: 1
Joined: Mon Sep 24, 2012 1:05 pm
by jmvh » Thu Oct 04, 2012 9:39 am
I previously had no luck getting Mopidy to work but now as the 0.8.0 version is available, it works like a charm. The installation instructions on GitHub are accurate, though I could not get proper audio through the analogue output before installing Pulseaudio and setting MIXER = u'pulsemixer' in the Mopidy config file.

I'm running the Soft-float Debian “wheezy” image.
Posts: 1
Joined: Thu Oct 04, 2012 9:33 am
by gfoot » Sun Oct 28, 2012 2:30 am
If you're using the official libspotify library, it is important to run a soft-float OS image, as the official library is built that way. If you don't, it will fail to load the library, without telling you why (it will just say it could not be found).
Posts: 1
Joined: Sun Oct 28, 2012 2:23 am
by rollebolle » Thu Nov 29, 2012 10:43 pm
Nice guide, thanks, got it working on debian wheezy hard float, but i had to:
- install some extra packages, think it was libglib2
- configure mpd with --enable-alsa
- use absoulte paths in the mpd.conf

But what I wonder.. is there any nice way to save playlists from spotify? sure I can use mpc to load a playlist and then save it, but then the .m3u file created only contains spotify links and no names (plus it doesnt seem to work at least from droidmpd). I tried adding metainfo about the tracks with the #EXTINF tag, but no luck?
Posts: 3
Joined: Wed Nov 28, 2012 7:43 pm
by kefa » Sun Jan 13, 2013 9:45 am
Hi SheepOnMeth,

Thanks for your guide - I wanted to use your guide rather than Mopidy as I am keen to getting HTTP streaming FLAC files working so that I can stream spotify to my amp (http://blog.kefa.co.uk/?p=31) - I would use Mopidy and USB DAC but currently there are too many issues with USB dropouts at present). I am running Debian Wheezy (armel) with the latest firmware version (Linux kefa-mpd 3.6.11+ #352 PREEMPT Wed Jan 9 17:16:53 GMT 2013 armv6l GNU/Linux).

If I install vanilla mpd from the debian repository (using apt-get install mpd) I can stream perfectly.

However, if I recompile MPD with despotify enabled (with ./autogen.sh --enable-despotify --enable-flac) as outlined above it compiles OK and I can startup mpd but if I add spotify playlists these do not play and mpd exits unexpectedly (without any error messages and nothing in mpd.log).

Any ideas why this might be happenning - any suggestions from the forum?

Your help would be greatly appreciated!

many thanks!
Posts: 4
Joined: Sat Jan 12, 2013 11:52 pm
Location: London, UK
by kefa » Sun Jan 13, 2013 11:36 am
Following on from this, I just ran mpd in debug mode to generate some more output: mpd --stderr --no-daemon --verbose /etc/mpd.conf

Code: Select all
root@kefa-mpd:~# mpd --stderr --no-daemon --verbose /etc/mpd.conf
config: loading file /etc/mpd.conf
path: path_set_fs_charset: fs charset is: UTF-8
database: reading DB
daemon: opening pid file
daemon: writing pid file
state_file: Loading state file /var/lib/mpd/state
client: [0] opened from 127.0.0.1:52888
client: [0] process command "add spt://spotify:track:1MvG1vrfmLuW558hWvDhL6"
add to playlist: spt://spotify:track:1MvG1vrfmLuW558hWvDhL6
playlist: queue song 1:"spt://spotify:track:1MvG1vrfmLuW558hWvDhL6"
client: [0] command returned 0
decoder_thread: probing plugin pcm
decoder: audio_format=44100:16:2, seekable=false
output: opened plugin=httpd name="Kefa Music HTTP Stream" audio_format=44100:16:2
Segmentation fault


From searching around (see https://bugs.launchpad.net/ubuntu/+sour ... bug/943691): I'm wondering whether this is something to do with using armel rather than armhf or a bug in floating point versions of libvorbisenc2. Also, it's odd that it seems to be using a pcm plugin rather than ogg plugin (but hey, I'm a bit out of my depth here - possibly this could be better placed on an mpd forum).
Posts: 4
Joined: Sat Jan 12, 2013 11:52 pm
Location: London, UK
by kefa » Sun Jan 13, 2013 3:01 pm
I have raised the following bug on the mpd bug tracker site.

http://bugs.musicpd.org/view.php?id=3645

However, any suggestions/thoughts would be greatly appreciated.
Posts: 4
Joined: Sat Jan 12, 2013 11:52 pm
Location: London, UK