The life and times of the younger, lesser spotted chicken.

Thursday, August 25, 2005

XMLTV && PuddleTV continued...

After a full afternoon of fiddling with the XMLTV scripts, as well as port forwarding to update Gorilla's portage, I think I have created a solution for showing whats coming up on SABC[1,2,3] and ETV, live, on PuddleTV.

The first problem I had to tackle was an irregularity in the tv_grab_za and tv_grep script. The tv_grep script does exactly what you'd expect it to do, from the name, it just 'grep's for certain arguments or parameters, and gives you the filtered result. The tv_grep script comes with a command to show the part of the schedule that hasn't already aired, ie. only from the current time, until the end of the cached schedule. The problem with this extension is that when asking it to show all shows that are coming up, it seems to start with shows that aired two hours previously. The obvious cause of this would be a badly interpreted current time/date. The fact that it is two hours difference made me immediately suspect SAST vs UTC. South Africa is +2 hours on GMT, and because of this, I suspected that the script wasn't taking this into account.

After a bit of fiddling, I found that it was trying to take this time zone difference into consideration, but for some reason wasn't being very successful with the adjustment. It would take the read out from a `date` command and then parse it, and based on whether there was a time zone mentioned, it default to just UTC or GMT time. For some reason, it wasn't interpretting SAST and so would take the current time as UTC and then make the adjustment for my time zone, and end up two hours early. The solution, after some bashing, came about quite randomly. I thought that because it isn't reading the SAST right, it might only be able to interpret certain symbols or time zones. I added an extra UTC to the end of a customized `date` command and voila, it worked. All of a sudden the script was doing as it was supposed to, and it was interpretting the correct time zone. After wording through my train of thought and attempts to fix it, in this blog, I have realised that it doesn't really make that much sense, but bygons, it works :-)

The second problem this afternoon was the issue of an out of date portage on gorilla.scw. He can't see campus, and as a result, his rsync in Gentoo doesn't work. An out of date portage isn't the worst thing in the world, because I can just make my PC fetch the files and then scp them across to gorilla. That works in most cases, but not when XMLTV has a dependency list of over 50 tiny perl packages. I tried making a snapshot of my portage and untar'ing it over gorilla's current portage with no luck. The easiest work around, I found, was to just:

$ ssh -L 80:ftp.rucus.ru.ac.za:80 flipflop@flipflop.scw.ru.ac.za

And then run the emerge -f xmltv command to fetch all the files through my PC. I will look into fixing rsync soon. It apparently uses SSH, so a simple ssh forward to my box should do the trick. I'm too excited to try figure it out now... I finally have the scripts for the schedule display on PuddleTV and I want to see it in action ASAP!

The scripts weren't too difficult to come up with, and with a bit of fancy footwork, I have emerged with two bash scripts. The one script ssh's to flipflop.scw and instructs it to fetch the TV schedules for the next 7 days from DSTV. Again, this is needed because gorilla himself can't see DSTV.co.za. flipflop.scw fetches the new schedule every three days (instructed to by the crontab) and then scp's it back to gorilla and effectively updates it. The use of sshkeys makes this possible, so I don't have to be there to type in the password to scp and ssh to and from the two boxes. The fetch script is below:

#/bin/bash
TVDIR="/home/flipflop/PuddleTV"
export http_proxy="http://username:password@cache.ru.ac.za:3128"
tv_grab_za --days 7 > $TVDIR/sabc_schedule.raw
scp $TVDIR/sabc_schedule.raw gorilla:~/PuddleTV/
rm $TVDIR/sabc_schedule.raw


It is frustrating because of gorilla's inability to see campus, but this kindof work around has become second nature to me, through the development of PuddleTV. The next script is the script which filters the schedule and then outputs the necessary, and needed, information to a local file. The file is then cat'd (with some more fancy footwork) and given to 'convert' which, through the use of the 'text' function, writes the programme information to a blankly (but PuddleTV prepared) jpeg image. This image is then replicated twenty times and then, using mencoder, made into a movie running at 2 frames per second. The result is a 10 second long video showing the next 15 shows that are to come onto the 'free' SA TV channels, in order of screening. The script is as follows:

#/bin/bash
TVDIR="/home/flipflop/PuddleTV"
tv_sort $TVDIR/sabc_schedule.raw | tv_grep --on-after "`date +%x' '%X' 'UTC`" --on-before tomorrow | tv_to_text | head -n 15 | grep "\-\-" > $TVDIR/temp/sabc_list
convert -font helvetica -pointsize 30 -fill blue -draw "text 10,110 '`cat $TVDIR/temp/sabc_list | sed 's/\t/ /g'`'" $TVDIR/schedule_pics/sabcschedule.jpg $TVDIR/temp/schedule_sabc.jpg
for i in `seq 1 20`
do
cp $TVDIR/temp/schedule_sabc.jpg $TVDIR/temp/schedule_sabc-$i.jpg
done
mencoder "mf://$TVDIR/temp/schedule_sabc-*.jpg" -mf fps=2 -o $TVDIR/videoclips/sabc_schedule.avi -ovc lavc -lavcopts vcodec=mpeg4
rm $TVDIR/temp/*


This script is run every five minutes on gorilla. I may change this so that it happens less often, like every ten minutes maybe, because the schedule doesn't change that often, and every ten minutes should be more than sufficient (and accurate). The only thing I want to add to this script is the addition of a timestamp in the top corner. This isn't too difficult, as it is already implemented into my original PuddleTV schedule generator.

I am in the process of emerging XMLTV onto gorilla, and the minute it is finished, I will fire up the scripts on the PuddleTV, realtime, and see how they perform. I plan on making the advert show, just about as often as the PuddleTV schedule. Once again, PuddleTV is developing, and every time I release another one of these scripts, it makes me think about how awesome it would be to actually package PuddleTV and release it as an actual ebuild for Gentoo. Oh well, some day :-)

Wednesday, August 24, 2005

Fish River Point


We stayed here last weekend for Andrew Elliotts 22nd birthday. Besides the weather, it was incredible. The two houses were in an abandoned firestation, adjacent to a lighthouse.

XMLTV && PuddleTV

One of my friends, Andrew Illgner, pointed out an awesome Linux based utility, xmltv, which fetches web based TV station schedules and formats them into standard XML. It even has a script set aside for South Africa, and can fetch all of the DSTV channel's schedules in a couple of seconds. It takes quite a few parameters and is pretty customizable in that regard. As well as the actual fetching script, the package comes with a couple other scripts for manipulation of the actual XML output. Scripts which 'grep' for certain form values, names etc. as well as scripts which order and arrange the output into seperate channels or days, for instance.

The only shortcoming I've found so far, is that some of the scripts which cut the output to only show the schedule that is relevant to user at the current time, seems to report programmes which happened two hours ago. In other words, the script seems to believe that it is GMT and not GMT +2, like South Africa is. I'm sure there is a way to correct this, and if there isn't, then I may have to hack away at the scripts to find out how to correct this. Before using the fetching script, a simple export of the http_proxy environment variable sorts out any proxy issues you would have, like we do, sitting behind a firewall.

I plan to incorporate this XMLTV utility into PuddleTV. I want to add more onto my ~/.mplayer/input.conf, so that a user can push one of the 'F' keys and it will display what is coming up on SABC[1,2,3] and ETV. It shouldn't be too hard, because I already have other scripts which osd_cat things to the screen to show settings or upcoming movies. It should just be a case of fiddling the output so that it is human readable (from the XML document) and then osd_cat'ing line by line onto the screen. After that, I was thinking about implementing actual adverts, showing the upcoming schedule on the available 'free' TV channels, using the current mplayer/convert script I built for displaying PuddleTV's schedule, realtime.

Below, I've detailed how I used the XMLTV utility and some of the outputs it's capable of:

First of all, export your http_proxy variable if you have to access http through a proxy server:

$ export http_proxy="http://username:passwd@proxy.address.com"

Next, depending on where you live (different scripts are built for different countries), run the fetch script configuration:

$ tv_grab_za --configure

This allows you to select which channels it must fetch information for, so as to not be fetching a shitload of channels every time from the server. After this is done, you can tell it to fetch the channels and output the XML to something other than STDOUT.

$ tv_grab_za --days 7 > list.xml

It takes about a minute and the result it an XML formatted list.xml of the schedules for the channels you selected over the next seven days. The command line I'm using to parse for PuddleTV is as follows: (I've only just fiddled around with it for an hour or so, so I still plan on refining it quite a bit before deploying it as an actual output for PuddleTV)

$ tv_grep --channel 48.dstv.com --on-after "Thu Aug 25 00:22:39 SAST 2005" list.xml | tv_to_text - | head -n 5

... and the output:

08-24 (Wednesday)

22:00--22:30 News SABC 3
22:30--23:15 The Oprah Winfrey Show // Diary Of a Mad Black Woman SABC 3
23:15--23:45 Crossing Over With John Edward II SABC 3

... Cool eh!? Now go for it, emerge xmltv.

Tuesday, August 23, 2005

Nokia N-Gage && Worms World Party

So stoked, just got Worms World Party for my stocky little Nokia N-Gage. It's really awesome, just like playing it on the PC but on a much smaller screen. It comes with a whole range of voice packages and nationalities, all crammed into a little 32Mb MMC. It even supports N-Gage Arena which you can play over GPRS, as well as bluetooth multiplayer support. Imagine sitting in a room with three other N-Gage owners playing Worms against each other, wow. The only sacrifice for playing Worms on your cell (whilst you wait for something to compile :-P ), is battery life. It's expected though, when you see the graphics and sound it's constantly pushing out. It's not the biggest problem, considering the full battery cycle charge time of just over an hour.

Anyways, it's a real winner and, the best Symbian S60 based game I've played so far. So yeah, check it out at www.ngageworld.com, and if I'm feeling really generous I may even snap some pics with my digicam for you :-)

Monday, August 22, 2005

XMMS2 and Euphoria

I am currently trying to get XMMS2 to build on my Gentoo box. For those who don't know, XMMS is the Winamp of Linux, and XMMS2 is a very unstable, under development port which attempts to emulate the skins of Winamp5. They currently can't use official Winamp5 skins but have released some pretty kief skins which make XMMS2 look very similar.

I'm keen on having an XMMS which isn't a standard "Winamp2" rectangle. I want something that is "morphable" or ... neater. Something which can fit into the corners of my desktop and look as snug as my e17 installation. I haven't blogged about it yet, but I am currently using enlightenment DR17 as my window manager in Gentoo. It's incredible. It's all in CVS at the moment, so no official releases have been made, but what I have running at the moment is just the ultimate eye-candy. Check out these screenshots of my desktop: [1] [2]

It wasn't easy, and DR17 is currently still very buggy, which made customizing and fiddling very difficult with many a segfault and unhandled exceptions. Either way, I got it running, and now I'm pretty stoked with it. The only short coming I've found so far is it's incompatibility with my for some reason. MPlayer seems to halt e17 and force you to back out of X and then restart it before you can do anything again. I've been looking around the net but can't seem to find anybody experiencing the same problem. It's tough finding any help because of how developmental e17 is. I'm sure it isn't something too serious, but for now I will just use Xine for videos.

Monday, August 01, 2005

We can rebuild him, we can make him stronger.

Gorilla ails. I can hear him crying. I have the technology, I can make him stronger, faster, better than ever before.

In an effort to save space on gorilla, a while ago, I started deleting what I thought was unimportant information. Turns out that a whole lot of what I deleted was critical to portage, and the result was a b0rked ports tree and so much more. It didn't bother me at first because gorilla was all sorted, he didn't need any more applications, and was running like a pearler. Unfortunately, his cron stopped working for some reason, and although I tried my bestest to correct the problem, I was unable to. The simple resolution to re-emerge another cron or the same cron was also quickly aborted after realisation of the portage problem which existed on gorilla.

The next best solution: A reinstallation of Gentoo onto the machine. But this time, because I know what to expect, I can do it better. There was a bit of a dogshow surrounding Gorilla's limited space issues last time, which can be avoided this time, resulting in a smoother installation and post installation of Gentoo.

So far, I have booted him off a Gentoo install CD, and with the files I backed up before reinstallation, have already flashed the new portage tree and it's recompilation of all the necessary packages is imminent. Dealing with an old 2gb (for the root) and 1gb hard drive (for auxillary) is frustrating, but sufficient.

Progress will be documented and blogged. Stay tuned.

Friday, July 29, 2005

The airport official can only show you the door. You must walk thr ough it.

Point is, is that you'll only know how many people are inside the toilets if you check it out for yourself.