Broadcatching, iTunes, a "mini" Apple TV

Recently, I got a used Mac Mini from a friend; I decided to put it to good use as a media station in my living room, and it does indeed work pretty well (after fixing it up with codecs that are in use in the real world, but that’s not the topic of this article (-:).

One thing that I find very useful is the ability to import movie files (that one might download from the vast and unfriendly-to-copyright-holders internet, as described here for instance) into iTunes on my desktop mac and have the Front Row thing on the living room machine play them over the network. The steps one needs to take in order to get this working are many and tedious, and so I’ve created an AppleScript to do all the hard work for me. It:

  • Converts an .avi movie (they usually come encoded as DivX or Xvid) into a standalone .mov file using Quicktime Player (this doesn’t transcode),
  • extracts the Show name, Season, Episode number, Episode name from the file name via a friend’s service called “renamr” (a telnet 2.0 service, he calls it),
  • imports the file into iTunes, tags it nicely, and
  • cleans up after itself.

The files thus imported will pop up in the nicely remote-controllable interface, marked as “unwatched,” and wait for me to finally get some spare time to sit down and watch them. (Which might very well be after the WGA strike ends, so it all should work out nicely in the end.)

If you find yourself wishing for a similar solution, download this file, read the comments in the beginning, skip over the MIT-style licence, and read the code until you are convinced I’m not doing anything stupid or malicious. Then, have fun using it!

CXML-RPC update: changed interface, includes server part

I didn’t really like the DWIM interface for type translations on the client, so I made the type information mandatory. (-:

This means that instead of:

* (xrpc:call "http://localhost:8080/RPC2" "addNumbers" '(1 2 3.0)) ; WRONG

You get to do this:

* (xrpc:call "http://localhost:8080/RPC2" "addNumbers" '(:integer 1
                                                         :double 2
                                                         :double 3.0))
6.0

This doesn’t look vastly superior, but consider this case:

* (xrpc:call "http://localhost:8080/RPC2" "weekDay" `(:time ,(get-universal-time)))
0

Where before, you had to construct an xml-rpc-date structure; ew. This also allows nicer handling of (unsigned-byte 8) vectors (you can base64-encode them now), and you don’t have to construct yucky xml-rpc-struct objects anymore: just use alists. The decoding functions now return the type tag that they saw in the response or request.

Speaking of requests, the server is now finished, lifting CXML-RPC to more or less the same level as s-xml-rpc. It implements the introspection functions specified in xmlrpc-c’s documentation, and the faults_interop spec. You can define methods for different handlers, which means that you can attach more than one handler to different URLs and they can expose different sets of methods to the world. This might be handy for those running virtual hosts.

In response to yesterday’s post, Rafal Strzalinski pointed me at Ivan Boldyrev’s s-xml-rpc-hunchentoot, which adapts the s-xml-rpc server functions for use with hunchentoot’s handlers. There’s no port to DRAKMA for the client part.

I think you should give CXML-RPC a try if you either want to expose multiple sets of methods on different handlers, or you don’t want to install aserve just for an xml-rpc client. (-:

XML-RPC client library using Drakma and CXML

A few weeks ago, I tried using S-XML-RPC for use with a hunchentoot-based web interface to rtorrent. Unfortunately, it comes with a long list of dependencies that are already implemented better by Ediware such as drakma: it can speak HTTPS, connect via proxies, and allows cookies (although I’m not aware of any xml-rpc implementation that supports this (-:).

So I re-implemented s-xml-rpc’s client part to use the libraries that are already available in clbuild, and got a pretty pleasant-to-use library. To simply invoke an xml-rpc method, use:

* (xrpc:call "http://betty.userland.com/RPC2" "examples.getStateName" '(:integer 41))
"South Dakota"

* (xrpc:call "http://time.xmlrpc.com/RPC2" "currentTime.getCurrentTime" ())
#<CXML-RPC::XML-RPC-DATE 20071202T06:56:43>

It’s entirely undocumented right now, and some names (and interfaces) may be subject to change, but I’m making it available now anyway, at my git repository.

The plans for the near future (e.g. next weekend) include a server part based on Hunchentoot, and, um, test cases and documentation. Stay tuned!