Use Pandora on the Commandline with Pianobar and ssh Proxy

I use Pandora pretty much all day while I work. I’m currently traveling abroad which means, it’s blocked. Typically what I would do is, log into my VPN. Go to Pandora. Start listening. There are a few problems with this. For starters, I’ve been using a very popular VPN. This mean, some services and sites are blocked. Or I have to constantly fill out a captcha.

I recently started using the amazing command line tool pianobar. Which lets you control and play Pandora in your terminal. Pianobar lets you use a http proxy, but I don’t trust shady public proxies, even for just pandora. Plus, it’s a pain to constantly find a new one, when it stops working. I’m SICK and tired of turning on my VPN on and off all the time. I just want it to alway work.

I also wanted to just simply ssh into my server and use that, instead of some random proxy. Or more complicated setup.

Here’s how I got everything working in one command.

Install pianobar:

brew install pianobar

Set up the config (on mac: .config/pianobar/config):

user = example@example.com
proxy = http://localhost:9090

I’m using a nifty go script to locally proxy the SOCK proxy to http. This is so pianobar can use an http proxy.

(Need to be setup to run a go script)

go get github.com/stevenirby/pianobarproxy
go/bin/pianobarproxy -socks5 :9080                                                                       

ssh into my server:

ssh -D localhost:9080 -C -N root@XX.XX.XXX.XXX

I’m not typing three commands, so let’s create a script:

pandora.sh

#!/bin/bash

function main() {
    trap 'jobs -p | xargs kill' EXIT

    echo "Starting pianobarproxy..."
    ~/go/bin/pianobarproxy -socks5 :9080 > /dev/null 2>&1 &
    sleep 3

    echo "Starting ssh proxy..."
    ssh -D localhost:9080 -C -N root@XX.XX.XXX.XXX &
    sleep 6

    pianobar
}

main

Symlink so I can run this one command and listen to music with one command.

ln -n pandora.sh /usr/local/bin/pandora

Now you just run the command:

pandora

Now it just works ™.

2 Comments on “Use Pandora on the Commandline with Pianobar and ssh Proxy

    • Thank you! I actually switched from Pandora to Google Play Music. So I don’t use the tool anymore, but it was pretty nice when I did.

Leave a Reply

Your email address will not be published. Required fields are marked *