Podcast Subscriptions

Please note that all blog posts before 8 April 2007 were automatically imported from LiveJournal.  To see the comments and any LiveJournal-specific extras such as polls and user icons, please find the source posting at http://brianenigma.livejournal.com/2005/04/

If you take a peek at my LJ style, you might notice that I added a little section for the podcasts to which I am currently subscribed. It was a bit of a hack, hence the text getting truncated. LiveJournal does not let you include iframes or JavaScript in your style, so there is no real way to access offsite content except through an image. In this case, I only had a fixed width for the image there. The whole image is clickable and brings you to a page with more description and individual links. Technically, I might be able to do something with imagemaps, but that felt like too much work to figure out.

Subscribed Podcasts

The whole thing is a mishmash of technologies–AppleScript, XSL/T, command-line apps, etc.–but is nicely wrapped in a shell script that can be called from a cron job (assuming you have your SSH keys set up to upload the stuff to the webserver). The whole thing amounts to this:


#!/bin/sh
OPMLFILE=/tmp/subscriptions.$$.opml
TXTFILE=subscriptions.txt
HTMLFILE=index.html

if [ “$1” == “” ]; then
echo “For remote copying, put SCP connect string on command line”
fi

# Run the Apple/OSA Script, don’t print the comment lines
osascript -e ‘tell application “NetNewsWire” to export subscriptions including groups false to file “‘$OPMLFILE'”‘ 2>&1 | grep -v ‘^##’
# Make the text
xsltproc opmltohtml.xsl $OPMLFILE > $HTMLFILE
xsltproc opmltotxt.xsl $OPMLFILE > $TXTFILE
rm -f $OPMLFILE
# Make the image
text2gif < $TXTFILE > subscriptions.gif
convert subscriptions.gif -crop 100×9999+0+0 subscriptions.sized.gif
mv subscriptions.sized.gif subscriptions.gif
# Copy the files
if [ “$1” != “” ]; then
scp -q $HTMLFILE subscriptions.gif $1
fi

The shell script contains a little bit of AppleScript to tell my RSS/Podcast app to export its subscriptions. The subscriptions just happen to be in XML format, so they can be transformed to some nifty text and HTML. The text is then stuffed into a GIF file. Finally, the image and HTML are uploaded to my webserver. Violá!

Posted in: Code

Leave a Reply

Your email address will not be published.