Comfy Football with Quicksilver and an Xbox

Since there is a bunch of people out there watching the World Cup by all means imaginable via a number of oddball streaming sources, I've been repeatedly asked all sorts of things:

  • What is the best streaming client for the (to which I invariably reply "VLC")
  • What is the easiest way to hook up a computer (of any sort) to the
  • Where are the best quality streams

...and other assorted nonsense. Considering that I do not care one whit about football (there, I've said it), saying it kind of gets on my nerves is a massive understatement.

Then I started wondering about the technicalities of it, so I went over to Google/Video and started wondering "OK, so what if I wanted to watch this from the sofa?"

It turns out that I have an Xbox - a modded one, running XBMC - that is one of the many somewhat successful iterations at building my own audio and video media centre. It's crap for audio (due to the loud fan), so it's been gathering dust for a while.

But the video quality is superb (too good for streaming video, actually, although Quicktime movie trailers push its limits a bit), so I started looking for an easy way to send URLs to an Xbox.

As it turns out, there's quite a bit of prior art around. For starters, XBMC can be remotely controlled via a browser, but not to play specific URLs. There is a widget that talks to the server, but somehow it doesn't work for me - I might need to upgrade.

But I soon found something called URLPaster, which includes a PC application for sending URLs to the Xbox - and it's nothing more than a nice little script (XBMC has a built-in interpreter that I never found much use for):

# TeknoJuce @ #XBMC on efnet

import xbmc, xbmcgui, socket, os

host   = ''                 # '' = Localhost
port   = 45569              # Port
buf    = 1024
addr   = (host,port)

TBN    = 'Q:\\scripts\\'

encrypt = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)

i = '1'
while i == '1': #Run Sockets until pc-app tells it to quit.
        data,addr = encrypt.recvfrom(buf)
        if not data:
                print "Client has closed loop!"
                varData = str(data)
                i, URL = varData.split('|')
                lf = open(TBN + 'URL.LOG', 'a')
                lf.write(URL + "\n")

This receives an URL as an UDP packet and plays it, as well as keeping a log. There's also a companion script to view the log (you can get the whole thing at the XBMCScripts site), but I didn't bother.

I just tossed it into the Xbox's XBMC/scripts folder via FTP, went to the scripts menu and clicked on it to leave the daemon running (if you get the complete package, you can also set it to autoexec when you boot your Xbox).

Now all that remained was sending URLs to it from a (or just about anything, really). Since I had netcat installed, it was a trivial affair to type:

echo -n '1|' | nc -w 1 -v -u 45569

...and have a Rails screencast playing on my (note the -n to avoid sending a newline).

But I'm a diehard user, so I created a little to do the above for me:

using terms from application "Quicksilver"
  on process text t
    do shell script "echo -n '1|" & t & "' | nc -w 1 -v -u 45569"
  end process text
end using terms from

I then saved this as Play on Xbox.scpt in the ~/Library/Application Support/Quicksilver/Actions folder, restarted , and presto:

There you have it. The overall solution probably needs better URL escaping, but it works just fine.

XBMC in its present form will play just about anything from any sort of stream, so you might be able to watch the World Cup on it. As far as I know, there might even be a specific client for the Xbox already - and as I said, I don't particularly care; it was just an interesting problem to solve, and with a nice, simple, unobtrusive solution to boot.

I tried to read up on the hubbub around the net, and came across six or seven different streaming clients I never heard of before - in fact, if you started investigating streaming media at this point, you'd think the main drivers for technological innovation in our civilization are either sex or football.

Me, I'll be moving on to figure out how to add screencast URLs to for watching on those dull Sunday afternoons. I've already found a couple of clients for XBMC, but all of them are overkill and I'd like something much simpler - a single menu that acts as a playlist.

Ah well. So much tinkering, so little time...