Install pianobar and run it under proxy server “tor”

Why Pianobar

Well, do you know Pandora uses flash? if you open their web in your browser then your system is going to cry! and if you have less resource memory & CPU like then you won’t like flash in your browser.

There are more issues, like the web plays adds and audio has low bit-rate i.e., low quality. If you need high quality music i.e., 190 kbps and without any adds then you need a subsription.

But you can luckly get rid of adds and get high bit-rate audio via Pandora API. Here comes Pianobar, a free command line based client that does all you need.

Again, I followed few blogs to get it running, few of them are here; Instructables,

On linus

sudo apt-get install pianobar

on Mac

Easier way is to use either MacPorts or Homebrew. To install via MacPorts to the following

sudo port install pianobar

I’ll guide you to use Homebrew. first install Homebrew source

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
brew install pianobar

If you get error on the above installation then may be the link is dead and you need to get the updated URL. People also use different way to install them, here is another way. source

curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local

Compile manually; first install depenties and then Pianobar according to this soruce

sudo port install libao faad2 libmad cmake git-core
git clone git://github.com/PromyLOPh/pianobar.git
cd pianobar
cmake . && make && sudo make install

Now you can launch Pianobar with

pianobar

It’ll ask you to enter user name and password, following station name, like below

Welcome to pianobar! Press ? for a list of commands.
[?] Username:
[?] Password:
(i) Login… Ok.
(i) Get stations… Ok.
0) some name Radio
1) some name Radio
2) some name Radio
3) some name Radio

[?] Select station:

After the login you can press ? to view the action keys, like pressing n can choose next song.

Configure Pianobar

We can configure Pianobar with user name and password in a text file where we could also specify to use proxy and even more. By default Pianobar will look for a configuration file under ~/.config/pianobar/config, so all we have to do is to create a config file in that location.

Create .config under your home directory like below if you don’t have one.

mkdir -p ~/.config/pianobar
cd ~/.config/pianobar
touch config
nano config

Let’s add some details to the cofig file

tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0
user = myemail@mail.com
password = mypassword

At this moment I don’t have more details on tls_fingerprint, but may be in future I’ll have some.

If you run pianobar on your terminal, it’s going login automatically, wow! that’s nice. Still we can do more here, let’s move on further.

Run under Proxy

If you are located outside of US then you want to use free/paid proxy server to get access to Pandora, look at my previous post deals with free proxie servers. Remember that Pianobar can handle http proxy but not the SOCKS.

Add the following at the bottem of your config file.

control_proxy = http://xxx.xxx.xxx.xxx:80

Replace xxx.xxx.xxx.xxx with the IP your found on free proxy sites and also the port number 80. Now you should able to use Pianobar from outside of US.

Ok, that looks fine, but hey! don’t you think it’s silly to edit config file on every launch?, yes it’s. There is work around for this, you can configure tor to automatically pickup the proxy.

Configure tor

For installing tor look at my earlier post, if you run it then you’ll see something like below on ~5-th line;

[notice] Opening Socks listener on 127.0.0.1:9050

So you could cofigure your Pianobar to listen to port 9050, you may expect it’s all done, but it’s not going to work because tor works on SOCKS and Pianobar doesn’t handle SOCKS and required http proxy. So what we are going to do? there are scripts around which does listen to SOCKS and forwards it to http proxy. It was very hard for me to get one working. I was trying pianobarproxy, delegate, Polipo and few more. None of them worked initially but I found a working method with Polipo and I’ll explain you here. It’s taken from different resources found here and in superuser.Install Polipo from Homebrew.

brew install Polipo

Now we need to configure Polipo to listen to tor’s port 9050 and forward it to localhost. Create a text file anywhere with the following info,

socksParentProxy = 127.0.0.1:9050
diskCacheRoot=""

Now we can tell Polipo to use this configuration file as belwo.

polipo -c ~/Downloads/config.txt

You can also add configuration file to the location /etc/polipo/config then you don’t need to specify the configuration file (source). You can also find a template here. You can do this as below.

cd /etc
sudo mkdir polipo
sudo touch config
sudo nano config

In nano editor copy and the paste the follwing and press ctrl+o and ctrl+x.

socksParentProxy = 127.0.0.1:9050
diskCacheRoot=""

Remember that Polipo default listening port is 8123 and we have add this port to Pianobar config file. Add this info.

control_proxy = http://127.0.0.1:8123

We all done, open three tabs on terminal, on one type tor, in the next one type the above Polipo command and in the last tab type pianobar, you must see Pianobar running.

Advertisements

Listen to Pandora from outside of US with proxy

Pandora: an internet radio can play music similar to the song or artist you like. Basically it creates a station based on your interest and plays similar songs, the more interesting part is you can say “I like this or don’t” even you can say “I tired of this” then Pandora puts on the shelf for a month. So Pandora helps you to find music of your interets.

I’m going to explain you the possible ways to access Pandora outside of US, more importantly the free approach.

Proxy servers

The best way is to use free proxy servers. Hidemyass is a good place for free proxies, but it’s tedious to configure your browser on each instance. Mediahint provides a browser plugin which automatically sets the proxy when you visit Pandora, so you don’t need search for free proxies and configure browser.

Use tor

Here I’ll walk through the installation and configuration of tor on mac and must be easier on Linux. On mac install tor from Homebrew (if you don’t have Homebrew then install it first).  I followed to OpenPandora to configure tor, this is a good place to keep eye on the discussion area.

brew install tor
cd /usr/local/Cellar/tor/0.2.3.25/etc/tor
touch torrc
nano torrc

The above method to use Homebrew sometime ends on error like couldn’t link libevent, so the alternative way to install tor is to use MacPorts as below.

sudo port install tor

Now we need to configure tor as above and the easier way to find the location for configuration file is to run tor and now you’ll see tor will say Configuration file"/opt/local/etc/tor/torrc" not present, so we got the location.

cd /opt/local/etc/tor/
sudo touch torrc
sudo nano torrc

Add the following to the nano editor and press ctrl+oenter and ctrl+x. note: I need exitnode to land in US.

StrictExitNodes 1
ExitNodes {US}

Exicute tor, now you can see tor starts running and look at nearly fifth line as below, it must be giving you output with local host (127.0.0.1) and port number on which tor is forwarding.

tor
......
......
[notice] Opening Socks listener on 127.0.0.1:9050

It’s important to note that it’s not a http proxy rather it’s socks, so you need to configure you browser to use socks proxy on port 9050, enjoy!

In the next post I’ll explaing you “how to configure pianobar to listen to Pandora.”