Building an RSS podcast feed, Part 1

So, you want to set up an RSS feed for a podcast? Ah, young grasshopper, there is much data to munge and so little code to munge it with … at least code that you can live with.

I recently had the need to create an RSS feed for a podcast and discovered that, while you can do a lot of the heavy lifting yourself, it is much easier to use a tool for the purpose.

Before we start let me just make it clear what an RSS feed is: It is a file-based list of descriptions of, and meta data about, content items (HTML blog content or audio or video files) that is intended to be updated at some regular interval. There are a number of RSS formats and versions but the most common by far is RSS 2.0.

If you are just starting out in the podcast biz you could resort to creating a really simple starter RSS 2.0 feed using a service like Podcast RSS Feed Generator. As they say on the cooking shows, "here's one I made earlier":

<?xml version="1.0"?> <rss version="2.0"> <channel> <title>Test</title> <link></link> <description>Testing feed generator</description> <language>en-us</language> <copyright>(c), 2009.</copyright> <lastBuildDate>Tue, 2 Jun 2009 01:47:34 GMT</lastBuildDate> <generator> Podcast Generator</generator> <webMaster></webMaster> <ttl>1</ttl> <item> <title>Enclosure 1</title> <description>A test enclosure</description> <pubDate>Tue, 2 Jun 2009 01:47:34 GMT</pubDate> <enclosure url="" length="147,657" type="audio/mpeg"/> </item> </channel> </rss>

This generator (rating, 2 out of 5) only produces the text of a very simple feed and skips a lot of the hardcore features and options available in RSS 2.0.

Despite its limitations the Podcast RSS Feed Generator provides a pretty good demo of the basics. You'll notice first of all that RSS Version 2.0 is XML 1.0 compliant and if you want your feed to work correctly you'll have to make sure you write correct XML.

A feed is defined within the <channel></channel> tags and includes the name of the channel (<title></title>), the uniform resource identifier (URI) of the channel (<link></link>) along with a description, the language used, publisher's copyright, and other obvious meta-information.

I'm sure you can figure out the intent of all of the other tags in the example above except maybe "<ttl>", that's the "time to live", the number of minutes that a client-side cached version is valid for.

The TTL value used in the example defines that, if the feed was read more than one minute ago, the client must assume that any locally cached copy of that channel's feed they might have will be obsolete. A more appropriate value might be, say, "120" or "1440".

There are a few other tags that along with <ttl></ttl> are called "syndication hints". Hints "suggest" to feed clients when and what frequency of access are appropriate for a feed. The other tags are (<skiphours><hour></hour> … </skiphours> and <skipdays><day></day> … </skipdays>) which are meant to tell clients not to bother accessing the feed at those hours and on those days. Of course, this doesn't mean that the clients will obey the constraints and, in fact, many clients, by default, poll the feeds they monitor every hour no matter what the feed suggests.

Each individual episode of a podcast is defined within "<item></item>" tags (the generator only allows you to create a single item) and may include specifications for author, category, comments, description, enclosure, guid (a unique id for the item most often the URI of a permanent link to the item), link to the Web page associated with the item, publishing date, source and title.

The topic of what RSS features publishers and clients should implement for performance considerations and why is discussed in a 2004 article that's well worth reading: "HowTo RSS Feed State" by Randy Charles Morin.

The problem with Podcast RSS Feed Generator is that it is only useful for generating a first pass at a feed that lists only a single item. That said, unlike many other feed generators which are commercial, it doesn't wrap your feed in advertising.

So, if you want to create a well-formed, easily managed RSS feed sans advertising you're going to need better tools, which is what we'll discuss next week.

Gibbs in Ventura, Calif. to

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.

Copyright © 2009 IDG Communications, Inc.

IT Salary Survey: The results are in