Pianobar: Command line Pandora client HOWTO

In the past few weeks, I’ve found myself installing and configuring Pianobar a lot. It’s an open source command line client for the popular Internet music streaming service, Pandora. In rebuilding a couple of machines recently, I have found myself installing and configuring it a few times, and I keep stumbling over it, because it’s broken in the Ubuntu and Debian repositories, so in order to get this really great application to work, it takes a few more steps than a quick apt-get install command.

This little writeup is at least in part for my own benefit, since I’m sick of the stumbling and trying to remember, wait, what did I do to get this to work again? So if it helps any of my readers out, even better!

Apt-get won’t work, but this isn’t that much more difficult

When I first tried Pianobar, I installed it from the repositories, and immediately found it unusable. I basically got a TLS error when it tried to authenticate when logging in with my Pandora One account, and as of the time of the writing of this, that is still the case.

Further research indicated that this was an issue with the version in the repos, and the only way to get around this was to build it from source.

No problem. I might be doing the lazy thing by running things like Mint and other Debian based distros these days, but hey… I spent 8 or 9 years running Slackware as my main distro, so I’m no stranger to compiling things from source!

Still, this is a bit twitchy to configure, which is why I’m writing this.

Step one: Install Git

Ready for a little command line action? Good. The first step here is to install Git, if you don’t already have it.

For those of you running something Debian based, that’s just a simple command:

sudo apt-get install git

If you need to compile Git from source, or install it with a different package manager, you probably already know how to do that, so I’ll just move on to the next step.

Step two: Grab the latest Pianobar code from Git

Just so you know, this will create a “pianobar” subdirectory in whatever directory from which you run this.

git clone https://github.com/PromyLOPh/pianobar.git

Step three: Dependencies

Now you need to install the stuff that Pianobar needs in order to compile and run:

sudo apt-get install libao-dev libmad0-dev libfaad-dev libgnutls-dev libjson0-dev libgcrypt11-dev

Step four: Compile and install

This is the moment of truth. If any of the above steps threw any errors, this part won’t work:

cd pianobar

make && sudo make install

Step five: Config file stuff

Finally, you need a config file. In your home directory, under .config, if there isn’t one already, create a pianobar directory, and put an empty text file called “config” in there containing this text.

The key element here is the bottom chunk, which is the part I kept on stumbling over in getting Pianobar to work:

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 = B0A1EB460B1B6F33A1B6CB500C6523CB2E6EC946

Run it!

Pianobar is run simply by typing pianobar into a terminal. I actually like to run it from one of my virtual consoles (ctrl+alt+f1, for example) so that it isn’t even taking up a window on my desktop.

I posted this in last week's laptop rebuild post, but I figure it belongs here too. Pianobar in all its command line glory!

I posted this in last week’s laptop rebuild post, but I figure it belongs here too. Pianobar in all its command line glory!

I’m not going to do a full rundown of how to use pianobar; if you got this far, you can figure that much out from here. Hint: hitting the “?” key will pretty much give you all you need.

Oh yeah, and if you don’t like typing your Pandora account credentials every time, add this at the bottom of your config file:

user = your@user.name
password = password

Or, if you prefer,

password_command = gpg --decrypt ~/password

Then it will log in automagically every time you run Pianobar.

Enjoy!

25 thoughts on “Pianobar: Command line Pandora client HOWTO

  1. I wonder if compiling from source with the version in the repository would have worked

    apt-get source –compile [package]

    You still get the same version from source and compile it, the only advantage I can see is it being part of your package manager to update down the road

  2. As a long time Pandora / Pithos user I recently had the need to run pianobar on a Raspberry Pi.

    For the ~/.config/pianobar/config file I only needed the user and password, none of the other partner or tls stuff.

    Thanks for the write-up.

  3. I have multiple pandora accounts (1 for music and 1 for comedy) and i got tired of changing the config file each time to switch the accounts. So, I created a bash function to handle this for me and created a copy of each account config file and named them music and comedy, respectively. Im sure if you use a different shell you can figure out how to use the same format to do the job.

    pandora ()
    {
    if [ “$1” == “music” ]; then
    cat ~/.config/pianobar/music > ~/.config/pianobar/config
    pianobar
    else
    cat ~/.config/pianobar/comedy > ~/.config/pianobar/config
    pianobar
    fi
    }

    and in terminal i have 3 options.. if i type pianobar it uses the last config used. If i type pandora comedy, it plays the comedy account and If i type pandora music it will play the music account.

    Pianobar is my ONLY prerequisite for a distro… it is my “must have” application…

    • That’s really cool, I would never have thought of doing that. Thanks for the comment, I’ll be coming back to this when I try it out!

      • ***UPDATE***
        I actually kept working on this and I created a bash script to handle pretty much everything in a couple steps…

        Just change the items in parenthesis and you’re listening…

        #!/bin/bash
        Comedy=”Comedy”
        Music=”Music”
        QuickMix=”QuickMix”
        Motown=”Motown”
        SRV=”SRV”
        Rock=”Rock Hits”
        Pop=”90s Hits”
        choice=`zenity –height=300 –width=300 –list –title=”Select Pandora Station” –radiolist –text ‘What do you want to hear?’ –column ‘Select…’ –column ‘Station’ FALSE “$Pop” FALSE “$Motown” FALSE “$SRV” FALSE “$Rock” TRUE “$Comedy”`
        #choice=`zenity –height=300 –width=300 –list –title=”Select Pandora Station” –checklist –text ‘What do you want to hear?’ –column ‘Select…’ –column ‘Station’ FALSE “$Pop” FALSE “$Motown” FALSE “$SRV” FALSE “$Rock” TRUE “$Comedy”`
        comedy=”user = (COMEDYACCOUNT)”
        music=”user = (MUSICACCOUNT)”
        station1=”autostart_station = 1520437119959913498″
        station2=”autostart_station = 387866612585652527″
        station3=”autostart_station = 2602056020430086447″
        station4=”autostart_station = 387866603995717935″
        station5=”autostart_station = 2648891397547417903″
        station6=”autostart_station = 2685365711523995951″
        station7=”autostart_station = ”
        station8=”autostart_station = ”
        station9=”autostart_station = ”
        station10=”autostart_station = ”
        station11=”autostart_station = ”
        password=”password = (YOURPASSWORD)”
        script=”event_command = /home/(YOURHOMEFOLDER)/.config/pianobar/eventcommand.sh”
        song=”format_nowplaying_song = [1;32m%t[1;36m ☠ [1;33m%a[1;36m ☠ [1;32m%l[31m%r[1;36m”
        playing=”format_nowplaying_station = Station [1;32m%n[1;36m (%i)”
        format=”format_list_song = %i) %a – %t%r”
        pipe=”fifo = /home/(YOURHOMEFOLDER)/.config/pianobar/ctl”
        sophiks420nglist=”history = 25″
        #savedir=”save_dir = ~/Music”
        #tls=”tls_fingerprint = 13CC51AC0C31CD96C55015C76914360F7AC41A00″
        if [ “$?” == “1” ]; then
        exit
        elif [ “$choice” == “$Motown” ]; then
        echo -e “$music\n$station3\n$password\n$script\n$song\n$playing\n$format\n$pipe\n$songlist\n$tls” > ~/.config/pianobar/confignowhereman
        pianobar
        elif [ “$choice” == “$QuickMix” ]; then
        echo -e “$music\n$station2\n$password\n$script\n$song\n$playing\n$format\n$pipe\n$songlist\n$tls” > ~/.config/pianobar/config
        pianobar
        elif [ “$choice” == “$SRV” ]; then
        echo -e “$music\n$station4\n$password\n$script\n$song\n$playing\n$format\n$pipe\n$songlist\n$tls” > ~/.config/pianobar/config
        pianobar
        elif [ “$choice” == “$Rock” ]; then
        echo -e “$music\n$station5\n$password\n$script\n$song\n$playing\n$format\n$pipe\n$songlist\n$tls” > ~/.config/pianobar/config
        pianobar
        elif [ “$choice” == “$Pop” ]; then
        echo -e “$music\n$station6\n$password\n$script\n$song\n$playing\n$format\n$pipe\n$songlist\n$tls” > ~/.config/pianobar/config
        pianobar
        elif [ “$choice” == “$Comedy” ]; then
        echo -e “$comedy\n$station1\n$password\n$script\n$song\n$playing\n$format\n$pipe\n$songlist\n$tls” > ~/.config/pianobar/config
        pianobar
        else
        exit
        fi

  4. I keep getting an error that eventcmd cannot be found. However, it’s there. Also, I am continuing to get the TLS error. I am on build 2012.05.06. Any thoughts as to where I’m going wrong? I’m working on Raspbian, and am very new to it, but have some programming experience. Any input would be appreciated.

  5. On my Raspberry Pi, I got compile errors because I was missing libavcodec, libavfilter, libavutil, and libavformat. Once I apt-got the -dev files for those, I was able to compile.

    • Pianobar on a Raspberry Pi… that’s a pretty good idea. What else are you running on that hardware? Or is this a dedicated command line Pandora device? 🙂

  6. I’ve been working on this off and on for a few weeks, been to several web sites, tried lots of different settings learning new things with each one. But the instructions in your blog helped it all come together and I now have music streaming from Pandora through my Raspberry Pi for the first time today! Thank you very much for this post!

  7. Okay, I’m having a bit of a head scratcher. I installed Homebrew and Pianobar on Mac OSX Yosemite. It works great! But I’ve been trying to find the config file and can’t. There’s no config file located at ~/.config/pianobar/config. There’s no pianobar folder either. Any thoughts?

  8. I can’t get the config file to work. I think it’s because I can’t find my .config folder. It wasn’t even there when I tried to view hidden folders and I can’t do the “Go to folder” in Finder because it can’t find it. I made one and made the pianobar folder in there then put the config in but it doesn’t work. Any ideas? Mac OS X 10.11 BTW.

    • Never tried this on Mac OS, but I would suggest creating the .config folder if it doesn’t exist already. Then, under that, create the pianobar folder to contain the config file I described above.

  9. Pingback: Installing Pianobar on Raspberry Pi – Upods.net
  10. Pingback: Installing Pianobar on Raspberry Pi | Upods.net
  11. works great, definitely us PGP or some other mechanism (don’t know what is allowed or supported) to encrypt your passwords on your hard drives. Pianobar still seems to be commercial free, Thank God!, and hope it stays that way.

Leave a comment