Install Pianobar (Pandora) on Raspberry Pi

Posted by Max Power | Posted in Raspberry Pi | Posted on 04-11-2014-05-2008

0

In this post we will install Pianobar, an application for streaming Pandora on the Raspberry Pi.

Install the Prerequisites

sudo apt-get -y install git pkg-config libevent-pthreads-2.0-5 libao-dev libgnutls28-dev libmad0-dev libfaad-dev libjson0-dev libgcrypt11-dev

Compile Pianobar

Now lets download Pianobar from github. Apparently the one from apt-get is out of date (reference).
git clone git://github.com/prattmic/pianobar.git
cd pianobar
make
sudo make install

Note: You may get it from https://github.com/PromyLOPh/pianobar as well (this one may be more up to date).

Configure Pianobar

Now lets configure pianobar. First create the Pianobar config file (or copy it from /usr/share/doc/pianobar/contrib/config-example).
mkdir -p .config/pianobar
Navigate to the new directory and create the config file
cd ~/.config/pianobar
sudo nano config

Copy the following into the config file:
# This is an example configuration file for pianobar. You may remove the # from
# lines you need and copy/move this file to ~/.config/pianobar/config
# See manpage for a description of the config keys
#
# User
user = YOUR_EMAIL_ADDRESS
password = YOUR_PASSWORD
# or
#password_command = gpg --decrypt ~/password
#
# Proxy (for those who are not living in the USA)
#control_proxy = http://127.0.0.1:9090/
#
# Keybindings
act_help = ?
act_songlove = +
act_songban = -
act_stationaddmusic = a
act_stationcreate = c
act_stationdelete = d
act_songexplain = e
act_stationaddbygenre = g
act_songinfo = i
act_addshared = j
act_songmove = m
act_songnext = n
act_songpause = p
act_quit = q
act_stationrename = r
act_stationchange = s
act_songtired = t
act_upcoming = u
act_stationselectquickmix = x
act_voldown = (
act_volup = )
#
# Misc
#audio_quality = low
#autostart_station = 123456
#
#event_command = /home/pi/.config/pianobar/scripts/eventcmd.sh
#fifo = /home/pi/.config/pianobar/ctl
#sort = quickmix_10_name_az
#love_icon = [+]
#ban_icon = [-]
volume = -30
#
# Format strings
format_nowplaying_song = SONG: %t | %a | %l
format_nowplaying_station = STATION: %n | %i
format_msg_time = TIME: %s
# No special prefix on songs, stations or info
format_msg_nowplaying = %s
format_msg_info = %s
#
# high-quality audio (192k mp3, for Pandora One subscribers only!)
#audio_quality = high
#rpc_host = internal-tuner.pandora.com
#partner_user = pandora one
#partner_password = TVCKIBGS9AO9TSYLNNFUML0743LH82D
#device = D01
#encrypt_password = 2%3WCL*JU$MP]4
#decrypt_password = U#IO$RZPAB%VX2
#
tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0

Replace the following lines with your username and password for Pandora
user = YOUR_EMAIL_ADDRESS
password = YOUR_PASSWORD

Note: If you get the error “Login… Network error: TLS handshake failed.”, Pandora may have changed the tls_fingerprint (it is correct as of 12/3/2014). Or your login credentials may be wrong. You can get the current tls_fingerprint following these steps…

First create a file (placement of the file is not important)
cd
sudo nano pandora_tls

Now copy in this code (refrence: https://gist.github.com/r35krag0th)
#!/bin/bash
##
## A simple little shell script that will return the current
## fingerprint on the SSL certificate. It's crude but works :D
##
## Author: Bob Saska (r35krag0th) <git@r35.net>
##
openssl s_client -connect tuner.pandora.com:443 < /dev/null 2> /dev/null | \
openssl x509 -noout -fingerprint | tr -d ':' | cut -d'=' -f2

Then run the script
sudo bash pandora_tls
It will then return to you the latest tls_fingerprint and you can replace the one in the config file with that one.

Run Pianobar

Now lets launch Pianobar
cd
pianobar

Note: The volume may be low. Use “)” to increase the volume and “(” to reduce the volume. Use “q” to quit. The other commands are shown below.  If you need to change the audio source to the 3.5mm jack, run the following command…
sudo amixer cset numid=3 1

Keyboard Controls

act_help = ?
Show keybindings.

act_songlove = +
Love currently played song.

act_songban = –
Ban current track. It will not be played again and can only
removed using the pandora.com web interface.

act_stationaddmusic = a
Add more music to current station. You will be asked for a
search string. Just follow the instructions. If you’re clueless
try ‘?’ (without quotes).

act_bookmark = b
Bookmark current song or artist.

act_stationcreate = c
Create new station. You have to enter a search string and select
the song or artist of your choice.

act_stationdelete = d
Delete current station.

act_songexplain = e
Explain why this song is played.

act_stationaddbygenre = g
Add genre station provided by pandora.

act_history = h
Show history.

act_songinfo = i
Print information about currently played song/station.

act_addshared = j
Add shared station by id. id is a very long integer without “sh”
at the beginning.

act_songmove = m
Move current song to another station

act_songnext = n
Skip current song.

act_songpause = p
Pause/Continue

act_quit = q
Quit pianobar.

act_stationrename = r
Rename currently played station.

act_stationchange = s
Select another station.

act_songtired = t
Ban song for one month.

act_upcoming = u
Show next songs in playlist.

act_stationselectquickmix = x
Select quickmix stations.

audio_format = {aacplus,mp3,mp3-hifi}
Select audio format. aacplus is default if both libraries (faad,
mad) are available. mp3-hifi is available for Pandora One
customers only.

autostart_station = stationid
Play this station when starting up. You can get the stationid by
pressing i or the key you defined in act_songinfo.

control_proxy = http://host:port/
Non-american users need a proxy to use pandora.com. Only the
xmlrpc interface will use this proxy. The music is streamed
directly.

event_command = path
File that is executed when event occurs. See section EVENTCMD

history = 5
Keep a history of the last n songs (5, by default). You can rate
these songs.

password = plaintext_password
Your pandora.com password. Plain-text.

proxy = http://host:port/
Use a http proxy. Note that this setting overrides the
http_proxy environment variable.

sort = {name_az, name_za, quickmix_01_name_az, quickmix_01_name_za,
quickmix_10_name_az, quickmix_10_name_za}
Sort station list by name or type (is quickmix) and name.
name_az for example sorts by name from a to z,
quickmix_01_name_za by type (quickmix at the bottom) and name
from z to a.

user = your@user.name
Your pandora.com username.

*taken from http://manpages.ubuntu.com/manpages/maverick/man1/pianobar.1.html

Refrences

  • https://learn.adafruit.com/pi-wifi-radio/raspberry-pi-setup-2-of-3
  • http://www.instructables.com/id/Wireless-Raspberry-Pi-Radio-Pianobar/?ALLSTEPS

Write a comment