Use for the Pi

Reading time ~4 minutes

A few days ago, I described my Trek through Raspberry Pi and Wifi configs (including APs). Today, I want to talk about a possible use for such a setup.

TL;DR:

The simple CLI I had in mind isn’t working right now. I ended up using MPD (more exactly: Mopidy) with both a CLI client and a Web client, either of them work fine.

At first I wanted to use it to compile my apps, and serve them. Note, I’m using WebPack to compile my app, with a lot of plugins on the way. I thought my Pi would be strong enough to do that, even at a slower pace, but after 10 minutes of waiting for webpack to boot, I gave up. Ironically, as per Murphy’s laws, as soon as I disconnected the Pi from a power source I saw that it finally made the initial compile. It wouldn’t have been efficient anyway.

My second idea then was to make it a remote Spotify client. I didn’t want much from it: just a command line interface so I could pick / skip a song, volume control was optional.

Full process supplied below:

Despotify

The first thing I found that would match my criteria was Despotify. It’s supposed to be a simple CLI version of Spotify that would work with Spotify premium accounts. Turns out, it’s not working that well.

First off, I used this guide to set things up (and I do recommend following up if you intend to try it out yourself), but ended up changing a few things.

For instance, at Part One - Step 2 that command no longer works. Here’s how to fix it:

# From
$ svn co https://despotify.svn.sourceforge.net/svnroot/despotify despotify
# change it to
$ svn checkout svn://svn.code.sf.net/p/despotify/code/ despotify-code

and the cloning will work. Secondly, the build-script needed a change for my setup (might not apply to all). To use my fix, edit

1
Makefile
and edit line
1
9
like so:

# From
8:  CFLAGS = -Wall -Wextra -ggdb -std=gnu99
9:  LDFLAGS = -lz -lvorbisfile

# To
8:  CFLAGS = -Wall -Wextra -ggdb -std=gnu99
9:  LDFLAGS = -lz -lvorbisfile -lpthread

and that will get rid of the installation problems you might have later on. This has, however made my installation not work at all. The simple util will crash on any attempt, and the GUI (-ish) one will not even make a single search. Perhaps I did something wrong (like lpthread being crucial and me being an idiot for not making sure it exists and just ignoring it).

Enter Mopidy

Mopidy is a nice wrapper over MPD, which (as linked above) is a media server of sorts. Mopidy will allow you to stream Spotify from a local server. I followed their installation and configuration guides, especially those with regards to the raspberry pi. Something that was not very clear from the instructions is that you actually need to install the Spotify Extension and a UI / client for it to work properly. I used the extension, Mopify web client and ncmpcpp as a gui client. Both kind of work the same, but different at the same time. Mopify can access the Songs library, and generally works better, while ncmpcpp works without http and can only access playlists. Both, however, work just fine with next/previous/play/pause. Here are the steps to get these started:

# As far as apt-get is concerned, we can install the spotify extension and ncmpcpp
$ sudo apt-get install mopidy-spotify ncmpcpp

# For the rest, we'll need PIP
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo pythin get-pip.py

# And now to install mopify
$ sudo pip install Mopidy-Mopify

From here, just some configuration is needed. Here is mine, for comparison:

1
~/.conf/mopidy/mopidy.conf

[mpd]
hostname = ::

[http]
hostname = ::

[mopify]
enabled = true
debug = true

[spotify]
enabled = true
username = <username>
password = <password>

[audio]
output = alsasink

At this point, I could access the web client (mopify) by going to:

1
http://<Pi's address>:6800/

and use the GUI there, or ssh into the Pi and use ncmpcpp:

# SSH into it
$ ssh pi@thepiip

# Use ncmpcpp
$ ncmpcpp

It is a very slow process especially if you have a large library like mine. More often than not it’s a long wait until a song starts, but the streaming is good, and the quality is at least decent. Hope this helps someone.

Until next time, ‘ave a good one!

Github Issuess and Jekyll

I've recently made a small update to my blog, and I'd like to share the how, the why and the what. I'm also going to take the time and as...… Continue reading

Back Together

Published on September 12, 2015

Raspberry Pi - Wifi

Published on September 08, 2015