mwolson.org Blog - /Tech/Projects

Thu, 01 Mar 2007

First CL program: turn a directory into an RSS feed

I want to use Democracy Player to play episodic video content, so that it not only has an interface similar to that of a TV channel, but also keeps track of which episodes I haven't seen yet.

The problem is that this content is stored locally, and democracyplayer is completely incapable of adding arbitrary files to a channel (or creating a new channel) on its own. Each channel must correspond with an RSS feed. The solution was to write a script that given a directory and the title of the channel, generates an RSS feed with links to each file in that directory, in alphabetical order.

I decided to try doing this with a custom Common Lisp program. Luckily, I found an XML/RSS feed-generating library. I made Debian and Ubuntu packages for it in my repository, which didn't take too long.

I had a lot of trouble with trying to figure out how to get cl-launch to work properly (I have version 2.03 installed), so I went with a simpler solution. The main issue was that the second command in the program was not able to find the xml-emitter library, though it worked fine when I pasted the code into an instance of the CLisp interpreter. Weird. I'd appreciate it if someone could show me the right way to invoke cl-launch for this particular case.

The code is available at http://mwolson.org/static/dist/lisp/dir2rss. All that is required is to make it executable, and then it can be run directly as if it were a shell script. Note: The outpath argument should begin with http:// rather than a local path or file:// in order to get democracyplayer to accept it — this means that you'll have to have a webserver running and figure out how to keep random visitors from accessing it in order to make practical use of this.

Update
The script now takes three arguments rather than two. The new 2nd argument is the prefix for the locations in the generated RSS feed. Also, the source code has been moved to its own file rather than pasted here verbatim.

Add a comment

Name: 
Your email address: 
Your website: 
 
Comment: