Installing Pianobar - Part 5

After connecting with PuTTY, remotely, to the PI. Our first task is to upgrade this version of Raspbian with its latest packages. (Important Note: Linux and Raspbian are case sensitive, so use caps or normal letters when typing where needed)

(For upgrading the PI firmware itself, check out the details here: Upgrading GPU Firmware)

Updating and Upgrading Raspbian
So from the prompt: (Which should look like pi@MatsrasPi ~$ )
Type in:

sudo apt-get -q -y update

(Or you can copy and paste the command into the window. Do this by highlighting and copy the command, then switch to Putty and use the right-hand mouse button, which will automatically paste in the command.)

After that command, which can take up to 5 minutes, do the next command:

sudo apt-get -q -y dist-upgrade

This will take a lot longer (20-30 mins), as it will need to download the latest packages. It may also ask you if you would like to download these upgrades, so type 'y' and press enter on the keyboard to allow for these changes. After that completes, its always a good idea to reboot the pi, to allow packages to restart. Use this command to complete this:

sudo reboot

You should receive a message saying that "Server unexpectedly closed network connection". Click on the 'OK' button, and then close the terminal window.



You'll have to wait for about 2 minutes to try reconnecting to the PI using PuTTY, as its rebooting.

Installing Git, library files, Audio codecs and Pianobar
Most of the software that is available for download from a website, which we will be doing via commands on the Pi via PuTTY. Before we can download these programs, we need to install some software to help with getting the packages from the repository called Github.

Github is a site that allows code developers somewhere to store their work and allow others to have access to it.

Git install
So we need to install git software, after we have logged back in, we use the following command:

sudo apt-get install git

Once that has completed, we can download the supporting library packages to help with compiling some of the programs.

Library Supporting Files
Use the following command to download these files:

sudo apt-get install git git libao-dev libgcrypt11-dev libgnutls28-dev libfaad-dev libmad0-dev libjson0-dev make pkg-config libfuse-dev libcurl4-openssl-dev libxml++2.6-dev libssl-dev

You may again be asked if you would like to install, type 'y' and press enter on the keyboard. This again may take a while depending on download speed. (Mine took about 4 mins.)

Next we can now download the supporting audio codec for Pianobar.

FFmpeg Install
This install will require compiling, to work on the PI, which can take a while to do. Depending on different things, compiling will take up to 30 mins to do. So you may have to leave this for a while to complete the process. First off, we need to download FFmpeg:

sudo git clone https://github.com/FFmpeg/FFmpeg.git

This file is about 165mbs large, so again.. waiting.... We now have to go into the new folder for FFmpeg:

cd FFmpeg
In here, we add the commands for starting the compiling of this package:

sudo ./configure --enable-shared --disable-everything --enable-demuxer=mov --enable-decoder=aac --enable-protocol=http --enable-filter=volume --enable-filter=aformat --enable-filter=aresample --disable-programs --disable-doc
sudo make clean
sudo make
sudo make install
cd -
We will also need to add the path for the library to our config:

LD_LIBRARY_PATH=/usr/local/lib
sudo ldconfig

After all this is complete, we can finally install Pianobar.

Installing Pianobar
The next commands will download Pianobar and compile it:
sudo git clone https://github.com/PromyLOPh/pianobar.git
cd pianobar
sudo make clean
sudo make
sudo make install
cd -

Once this has been completed, we now have to configure pianobar by creating a config file.

Configuring Pianobar
The configuration file for Pianobar controls the connection to the Pandora and details your login and password details. We need to create this file ourselves, so firstly we need to create the directories to store this file.

sudo mkdir -p ~/.config/pianobar

This will create the 2 folders needed for the file. We then need to created the file to store in that directory.

sudo nano ~/.config/pianobar/config

Nano is like a notepad editor that you can use to create files needed. It will open a new window, allowing you to write in config details or, in our case, paste in.

# 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@user.name
password = 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 = 0

# Format strings
#format_nowplaying_song = n %
#format_nowplaying_station = Stationmt_list_song = %i) %a - %t%r
# 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 = 13CC51AC0C31CD96C55015C76914360F7AC41A00



When you have finished pasting the above, and scrolling up and down to make sure it's all there. You will need to scroll to the top and change the settings for your Pandora account. Change 'your@user.name' to the account email address you used. and also change 'password' to the one you use with Pandora.

When ready, press ctrl and x, to exit out of Nano. It will then come up with a question asking if you want to save it. press 'y' and then 'enter' on the keyboard to save the file.

To check the file is there, repeat this command, and it will open the file with your saved settings

sudo nano ~/.config/pianobar/config

'Ctrl & x' to quit out of nano again

TLS Certificate Update (only do this if tls_handshake fail)
The tls code at the bottom of the config file we created can change from time to time, (and right now the code its the latest) but if you use this script from User r35krag0th, over at Github,  has written a simple script to grab the latest key.

Simply create the script file like so:

sudo nano pandora_tls
and then you need to add this content to it:
#!/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 to run it:
sudo bash ./pandora_tls
It should then return the latest TLS cert needed.

EDIT: I seem to be getting a error in Pianobar about the key not being recognised, but It still seems to work. I'll keep an eye out for a possible fix.

Changing Audio Levels
When I first got this working, the standard audio level from the PI was really bad, making it worst when you turned it up.
So before we crank up Pianobar and Pandora, we need to change the audio level.

In the terminal window, type in:
alsamixer

 It should display like above, and you can see in the middle that the level is set to a low 42, which is the standard for the PI. We need to change this to a new level of 78. So using the up arrows on the keyboard, press up till you get to the level 78. When your finished press the Esc key to quit out.

To check the level is still at 78, just type

alsamixer

back in, and it will show you that new level.

Which all these changes, we now need to reboot the Pi. So like before:

sudo reboot


Comments

Popular posts from this blog

Configuring Allied Telesis Switches with PuTTy

FASTER - Arma 3 Server Manager (#Arma3_DIYDGS) Part 1

#DIYDGS - The Basics - Learning Steam_CMD