Personal TV Project: Part One

At the very start of getting this server back on I said I didn’t know what I wanted this server for. I just had a few domains sitting round doing nothing so I thought I’d get myself a new server.

I want to learn new way of doing things and in order to do this you need to have a proper application. If you don’t have an application that you find interesting you will never actually get round to developing anything on it.

One of my pet hates is tv listings websites. They are woeful and they base their site round the premise that you want to know what is on now. This drives me nuts, if I am in a position to care about what is on now chances are I am at home and can use the Sky Planner to see what’s on. I want to know what is on in a few days time based on the following:

  1. Do I like that genre?
  2. Do I like the stars in it?

That’s it. That is what I base my tv viewing on :) It is nothing fancy, yet any tv listing website I look at it always tells me what is on now and gives me no star information worth anything. Also most of them now have adopted some flash/ajaxy grid listing that you would get on a paper version of the listings. While this grid listing works well on a print out or even on an Ipad – it doesn’t suit me on my computer. So with this in mind I got to working on it. For the last month or so I have been working on it every so often before I go to bed so progress will be very slow. I intend to release a new entry/update on this project every few so often. So if you are interested stay tuned :)

Installing xml-tv on centos was not fun. I don’t have the .bash_history for it anymore but it took an age. In debian all you do is

apt-get install xml-tv
Or something similar to the above, on centos it took /ages/. But sure, that’s what I wanted – I now know about the inner workings of xml-tv which might come in useful someday. I set my config file to get the channels I wanted, luckily it asks me what package I have (sky) and where I am (Northern Ireland) and that seemed to get all the channels I wanted.

Years back I had a tv-listings website – it got the XML from XMLTV.org and rendered it out onto my own site. This was before the days of the iPhone and sky+. It worked well – I had the usual stuff – a watchlist, rss, searching etc. Then as time went on it got old and crusty and I left it to die. But I decided to pull some of it out of the archives, why would I bother re-inventing the wheel again – there are some files in that archive that I wont ever use again? However this script still did what it said on the tin. I got it all going just had to boot up my old server and dump the database out. The script I now run every three days looks like this:

#!/bin/sh -f
tv_grab_uk_rt > /tmp/tv.xml
/usr/local/bin/run_tv_update

The problem now becomes the interface. I don’t really want a website to render out channel listings anymore. TV Listings have moved on in five years. I couldn’t hope to emulate some of them – I currently use TVGuide UK on my iPhone which links into my sky+. It is great but I don’t use it to browse through the listings – it wont work the way I want it so I just don’t bother.

As good as the Sky+ Planner is it isn’t great for looking a few days or weeks ahead. A while back I came across Sons of Anarchy on Sky+ Anytime – but I can’t find it on there anymore and I never made a note of what channel it was on, never mind when :( I know that Ron Pearlman is in it though – so I used this as a test case. I found out the id of the Ron Pearlman from the script I ran above:

mysql> select id, name from star where name like ‘Ron P%’;
+——-+————-+
| id    | name        |
+——-+————-+
| 27339 | Ron Paul    |
| 29647 | Ron Payne   |
| 15521 | Ron Pember  |
| 19468 | Ron Perkins |
|  5766 | Ron Perlman |
+——-+————-+
5 rows in set (0.00 sec)

Great! Now to find out what he is in, I run this query:

SELECT p.id, p.title, sub_title, c.name, ctg.name, b.start_time, b.end_time, b.broadcast_date
FROM programme p, programme_star ps, broadcasts b, channel c, category ctg
WHERE ps.star = 5766
AND ctg.id = p.category
AND c.channelid = b.channel
AND p.id = ps.programme
AND b.programme = ps.programme
AND b.broadcast_date >= ’2011-01-09′
The above query returns me 69 rows mostly the same shows over and over again. I wanted to group them up so I wrote a shell script to do it. This was alright for a while but having to search the star each time was starting to annoy me. So I wrote a simple web interface which has seemed to work but while it was a web interface I thought it would be better if I associated an image with a star, just to make it easier to browse.

I wrote a quick script (using IMDB::Persons) that goes through every star in the database and tries to look  up the IMDB page for a star, if it can find one it will download the photo, use Image::Magick to create a thumbnail and go onto the next one. At the time of writing I have about 30% of them done, it is taking a while – but the script just runs in the background and sleeps every so often (its a sneaky script but at least its polite).

I want to add an auto-suggest function to the script so I don’t have to hit return everytime, it would be quite simple to do. While I am there I also want add in a function that will also search programme names. Given time I want to extend this further. But that is enough for now I will extend to it later. What I am about to show you is a result of ten mins here and ten mins there. I hope by the end of the week (time willing) that I will have a nice ajax autosuggest page to replace this one and by this time next week the afore mentioned programme search.

Try it out if you want by trying the live demo. Try searching for Ron Perlman to see the above example work.

  • TV Project (2)