Cool S#!t in Linux: Pianobar

If I've installed Ubuntu for you, you may still be wondering why I prefer this OS to others. Here's a cool reason: Pianobar. It's a lightweight command line Pandora client.

^ Installing and using pianobar (25sec)

  1. Use Ctrl+Alt+T to open a terminal and paste the following in the terminal: curl -sL crow1170.com/static/iPB.sh | sudo -E bash -; pianobar
  2. Enter username and password (I suppose step 0 is make a Pandora account).
  3. There is no step 3.

You should now be hearing Pandora from your command line, without needing a web browser, receiving ads, or having limits on skips. It should never crash or otherwise stop on its own, and can be embedded in lots of small scale applications.


Be sure to check out other #linux posts to see other stuff you can do.


Here's what the script is doing:

curl -sL crow1170.com/static/iPB.sh | sudo -E bash -

This uses curl to download a file, (iPB.sh) and give that file to the bash command, which is being called with sudo (Super User DO) permissions. Normally, I strongly advise against running this sort of command. You're giving ultimate permissions to whomever wrote the file you're getting. On balance, though, the convenience can't be ignored. You're encouraged to understand the component commands and run them individually, but I imagine most people find that too tedious.

The script you've acquired will look like this:

#!/bin/bash
mkdir ~/.config;  
mkdir ~/.config/pianobar;
TLS=`openssl s_client -connect tuner.pandora.com:443 < /dev/null 2> /dev/null | openssl x509 -noout -fingerprint | tr -d ':' | cut -d'=' -f2`;
echo \#~/.config/pianobar/config > ~.config/pianobar/config; 
echo "tls_fingerprint = $TLS" >> ~/.config/pianobar/config;
sudo apt-get install pianobar;

Here's what each line does:

#!/bin/bash

This line tells your terminal where the interpreter that should be used, a file called bash in the directory bin.

mkdir ~/.config;
mkdir ~/.config/pianobar;

These lines create the appropriate folder for storing you pianobar config file. ~ refers to the home directory of the current user, so on my computer this made /home/crow/.config/pianobar/.

TLS=`openssl s_client -connect tuner.pandora.com:443 < /dev/null 2> /dev/null | openssl x509 -noout -fingerprint | tr -d ':' | cut -d'=' -f2`;

This doozy of a line does a few things. To begin with, it's creating a new variable TLS and setting it to whatever the result of the commands between the backticks (`). Not to be confused with single quotes, this character is on the same key as ~, which is just below the Esc key.

The rest of this command finds and parses the fingerprint Pandora is using for secure communications this year. The program should definitely do this itself but the developer put it on the todo list, figured he had a few years to get to it, and never got back to it. :shrug:

echo \#~/.config/pianobar/config > ~/.config/pianobar/config;
echo "tls_fingerprint = $TLS" >> ~/.config/pianobar/config;

These lines make a file with the fingerprint in the folder we created earlier. You can also put your username and password in this file to make signing in easier later.

sudo apt-get install pianobar;

Finally, we install the program from Ubuntu's repository. This command, apt-get requires sudo permissions and is being instructed to install pianobar. It could remove pianobar just as easily, or, for example, install cowsay.

Share this: