Raspberry Pi SortTV Recipe

I set up my Raspberry Pi again. I used the New Out of Box Software (NOOBS) for the initial setup to test between OpenELEC and RaspBMC, but something went wrong along the way. For instance, I was missing some firmware components like /opt/vc/include. Installing via “Raspbmc installer for Linux and OS X.”

curl -O http://svn.stmlabs.com/svn/raspbmc/release/installers/python/install.py
chmod +x install.py
sudo python install.py

curl downloads the file to your current working directory. The flag “-O” tells curl to use the same name as the remote name. In this case, the file will be called “install.py” on your computer. chmod changes file modes. +x makes it searchable/executable by everyone if it is already searchable/executable by anyone. Install to your SD card. Once it finishes, it will ask this.

Would you like to setup your post-installation settings [ADVANCED]? [y/N]

If you want to install to a USB drive, which is much faster than SD, then say yes. After the process completes, plug in your SD card, USB, ethernet cable, HDMI into the Pi, and away we go. Wait for everything to install. After XBMC loads up, log in via SSH.

ssh pi@ip.add.r.ess

Password is “raspberry.” If you try it before it’s finish installing the OS and XBMC, it won’t let you in even though a prompt shows up for your password. Change your password now, yo.


To SSH into the Pi with your public SSH DSA key (skips the password prompt in the future), follow this excellent guide. Now run an update and get yourself set up. NB: the numerous lines are meant for clarity since packages can be run within the same command separated by spaces.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
sudo apt-get install man-db
sudo apt-get install expat
sudo apt-get install libexpat1-dev

Bluetooth keyboard. My Bluetooth adapter needs firmware installed.

sudo apt-get install firmware-atheros
sudo su

Bluetooth setup.

sudo apt-get install dbus
sudo apt-get install libdbus-1-dev
sudo update-rc.d -f dbus defaults
sudo reboot
sudo apt-get install bluez blueman bluetooth
sudo update-rc.d bluetooth defaults

SortTV requires Perl, so let’s get set up for that.

Install these modules, which are necessary for all the modules SortTV requires. I just like to install these first so when I run the final command it’s more clean and there are no errors thrown. Install the dependencies of the dependencies first before the dependencies. Whatever, I do what I want. First up is a new perl. File::Glob is included in perl-5.18.2 and higher. I never thought to install perl-5.19.10, but the process is the same.

sudo apt-get install curl
\curl -L http://install.perlbrew.pl | bash # I used to use CPAN to install perlbrew, but that was waaaay too troublesome by comparison. The Perlbrew homepage gives you a couple options.

The output of the last command should tell you to add this line to your ~/.bashrc.

source ~/perl5/perlbrew/etc/bashrc

Pretty standard. Use nano to edit the file.

nano ~/.bashrc

Then we install it. This part takes something like 24 hours. Maybe not exactly, but I left it overnight and during work.

perlbrew install perl-5.18.2

Give it another reboot.

sudo reboot

After it’s done, switch the new perl installation to your system default.

perlbrew switch perl-5.18.2

Make sure YAML is set. You have to change and save the setting in the CPAN shell.

sudo cpan YAML
sudo perl -MCPAN -e shell
o conf yaml_module YAML
o conf commit

Then the final modules. For the most up to date dependencies, check the README at the SortTV source page. v1.37 was just released, so go get it.

sudo cpan File::Copy::Recursive File::Glob LWP::Simple TVDB::API Getopt::Long Switch WWW::TheMovieDB JSON::Parse XML::Simple

I had to log in as root to get Switch to install.

Schedule SortTV to run every day with crontab.

crontab -e
0 5 * * * sudo perl /home/pi/sorttv/sorttv.pl # this command runs SortTV every day at 5 AM

Some recommend using CPAN minus (cpanm) over CPAN, but I found it to have less success.

Update Apr. 9, 2014: made some changes to some instructions. SortTV is now at v1.37, and File::Glob requires perl-5.18.2. Oddly, this time around I had to use sudo to get the sorttv.pl script running. Not sure what changed, but it wouldn’t run without.

Update Apr. 20, 2014: sudo was necessary because I was running RaspBMC inside of Raspbian. Running regular RaspBMC doesn’t require sudo. Also, I couldn’t get SortTV 1.37 to communicate with XBMC, so instead, I’m running a separate command to scan my video library. Thanks to shadow.

0 6 * * * curl –data-binary ‘{ “jsonrpc”: “2.0”, “method”: “VideoLibrary.Scan”, “id”: “mybash”}’ -H ‘content-type: application/json;’ http://localhost:8080/jsonrpc # My webserver port defaulted to 8080 on RaspBMC 13.0, so change to whatever applies for you

0 6 * * * curl –data-binary ‘{ “jsonrpc”: “2.0”, “method”: “VideoLibrary.Clean”, “id”: “mybash”}’ -H ‘content-type: application/json;’ http://localhost:8080/jsonrpc


Christian. Audio. Technology. Go-Getter. Concise.

Tagged with: , , , , , , , , , ,
Posted in Hacks, Technology

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s