Adding Enclosures to RSS Items


Excellent, you've created your MP3 file and packed everything you want into it. You're ready to distribute your podcast. And you can do that with a little help from RSS.

Using the <enclosure> Element

Podcasts are all about the <enclosure> element, which was first introduced in RSS 0.92. This element is a child element of the RSS <item> element. There are three required attributes in this element:

  • The url attribute gives the online location of the enclosure. Don't forget, URLs must start with http://.

  • The length attribute gives the length of the enclosure in bytes.

  • The type attribute gives the MIME type of the enclosure, such as "audio/mpeg" for MP3 files. (For a list of the possible MIME types, go to www.iana.org/assignments/media-types/.)

All these items are pretty self-explanatory, except perhaps the MIME type enclosure. MIME, which stands for Multipurpose Internet Mail Extension, originally specified the type of data sent with email so computers would know what to do with that data. In time, MIME types evolved to describe hundreds of types of data; now, when you use the <enclosure> element, you have to specify the MIME type of the enclosure so the software you're using knows what to do. Some MIME types include audio/mpeg (which you use for MP3 files), video/mpeg (MPEG and MP4 video files), image/jpeg (JPEG files), and so on. You can see the full list of available types at www.iana.org/assignments/media-types/. The MIME type for podcast enclosures is usually audio/mpeg.

Here's an example of the <enclosure> element in an RSS 0.92 or 2.0 item:

        <item>         <title>Steve shovels the snow</title>         <author>steve@rssmaniac.com</author>         <description>It snowed once again. Time to         shovel!</description>         <pubDate>Thu, 08 Dec 2005 08:39:51 -0500</pubDate>         <link>http://www.rssmaniac.com/steve</link>         <enclosure url="http://www.rssmaniac.com/steve/snow.mp3"           length="4823902" type="audio/mpeg" />        </item> 


You can also use enclosures in RSS 1.0, although the syntax is different and the enclosure would look like this:

    <rss:item>            .            .            .       <enc:enclosure>         <enc:Enclosure>           <enc:type>audio/mpeg</enc:type>           <enc:length>4823902</enc:length>           <enc:url>http://www.rssmaniac.com/steve/snow.mp3</enc:url>         </enc:Enclosure>       </enc:enclosure>     </rss:item> 


That's what the <enclosure> element looks like. Now let's put it to work.

Adding Enclosures by Hand

There are many ways to add enclosures to your RSS feeds. For example, you could start with a feed, news.xml:

    <?xml version="1.0"?>    <rss version="2.0">     <channel>      <lastBuildDate>Thu, 08 Dec 2005 14:01:27 -0500</lastBuildDate>      <pubDate>Thu, 08 Dec 2005 14:01:34 -0500</pubDate>      <title>Steve's News</title>      <description>This feed contains news from Steve!</description>      <link>http://www.rssmaniac.com/steve</link>      <language>en-us</language>      <copyright>(c) 2006</copyright>      <managingEditor>Steve</managingEditor>      <image>       <title>Steve's News</title>       <url>http://www.rssmaniac.com/steve/Image.jpg</url>       <link>http://www.rssmaniac.com/steve</link>       <description>Steve's News</description>       <width>144</width>       <height>36</height>      </image>        <item>         <title>Steve shovels the snow</title>         <description>It snowed once again. Time to         shovel!</description>         <pubDate>Thu, 08 Dec 2005 08:39:51 -0500</pubDate>         <link>http://www.rssmaniac.com/steve</link>        </item>        <item>         <title>Now it's raining</title>         <description>It's raining out there and the sump pump is         going in here.</description>         <pubDate>Thu, 18 Dec 2005 08:39:51 -0500</pubDate>         <link>http://www.rssmaniac.com/steve</link>        </item>     </channel>    </rss> 


Each <item> element can contain an <enclosure> element, so you can just place an <enclosure> element in an item by hand.

    <?xml version="1.0"?>    <rss version="2.0">     <channel>      <lastBuildDate>Thu, 08 Dec 2005 14:01:27 -0500</lastBuildDate>      <pubDate>Thu, 08 Dec 2005 14:01:34 -0500</pubDate>      <title>Steve's News</title>      <description>This feed contains news from Steve!</description>      <link>http://www.rssmaniac.com/steve</link>      <language>en-us</language>      <copyright>(c) 2006</copyright>      <managingEditor>Steve</managingEditor>      <image>       <title>Steve's News</title>       <url>http://www.rssmaniac.com/steve/Image.jpg</url>       <link>http://www.rssmaniac.com/steve</link>       <description>Steve's News</description>       <width>144</width>       <height>36</height>      </image>        <item>         <title>Steve shovels the snow</title>         <description>It snowed once again. Time to shovel!         </description>         <pubDate>Thu, 08 Dec 2005 08:39:51 -0500</pubDate>         <link>http://www.rssmaniac.com/steve</link>         <enclosure url="http://www.rssmaniac.com/steve/snow.mp3"         length="673920" type="audio/mpeg" />        </item>        <item>         <title>Now it's raining</title>         <description>It's raining out there and the sump pump is         going in here.</description>         <pubDate>Thu, 18 Dec 2005 08:39:51 -0500</pubDate>         <link>http://www.rssmaniac.com/steve</link>        </item>     </channel>    </rss> 


That's all it takes to do a podcast. Now you have to upload your RSS feed file, news.xml, to a Web server so it has a URL and is available to RSS. You also need to upload your MP3 file to the URL you gave in news.xml (that is, http://www.rssmaniac.com/steve/snow.mp3) so that podcast-enabled software can download the podcast and read it.

Tip

You can upload your podcast with an FTP program. To find FTP software, go to www.tucows.com and search for FTP. You'll find more than 100 FTP software packages, many of them free, designed for various operating systems.


As you can see, if you write your RSS feeds from scratch, it's not difficult to add an enclosure. You can add an enclosure to any RSS item (only one enclosure per item, however) in version 0.92 or later RSS documents.

Note

Different Web servers have different ways of handling files and making them available for download. By default, the files you upload should be available for download publicly, but if not, you might need to change the protection setting of your enclosure files on the server. If you have trouble downloading an enclosure when you test your podcast, check with your server's tech staff. You might also want to increase the protection of your podcasts; on many servers, stored files can be over-written by anyone by default.


NewzAlert Composer

NewzAlert Composer is an RSS creator program that lets you create feeds (see Chapter 3, "Creating RSS Feeds"). And it's one of the programs that will let you add enclosures to your feed as well.

To add an enclosure to a particular RSS item in a feed, just select that feed item in the main window, and the item's details appear automatically when you choose the Topic Properties tab (Figure 7.7).

Figure 7.7. NewzAlert Composer, an RSS creator program, also lets you create podcasts.


Adding an enclosure is easy, but that enclosure has to already be available online, because you need a URL to create an enclosure in NewzAlert Composer. To create that enclosure, just click the button displaying an ellipsis (…) next to the Enclosure text box. Doing so opens the Enclosure Information dialog (Figure 7.8).

Figure 7.8. Enter the URL for your enclosure, its size in bytes, and its MIME type (audio/MPEG here) in the NewzAlert Composer's Enclosure Information dialog.


Note

Click the ellipsis button next to the File Size text box and navigate to your enclosure file. NewzAlert Composer will tell you the file's size in bytes.


After you click OK, NewzAlert Composer reappears, displaying the new enclosure's data (Figure 7.9).

Figure 7.9. NewzAlert Composer is displaying an item with an enclosure.


When you're ready to publish your new feed, select Publish > Publish Feed (as discussed in Chapter 3) to upload the RSS file, but not the enclosure. You're responsible for uploading the enclosure yourself, so use a good FTP program (such as the ones you can find at www.tucows.com).

Here's the actual RSS 2.0 created by NewzAlert Composer, including the new enclosure:

    <?xml version="1.0" encoding="ISO-8859-1"?>    <rss version="2.0">     <channel>      <generator>NewzAlert Composer v1.70.6, Copyright (c) 2004-2005      Castle Software Ltd, http://www.NewzAlert.com</generator>      <lastBuildDate>Mon, 02 Jan 2006 11:46:23 -0500</lastBuildDate>      <pubDate>Mon, 02 Jan 2006 11:47:43 -0500</pubDate>      <title>Steve's News</title>      <description><![CDATA[This feed contains news from      Steve!]]></description>      <link>www.rssmaniac.com.com/steve</link>      <language>en-us</language>      <copyright>(c) 2006</copyright>      <managingEditor>Steve</managingEditor>      <image>       <title>Steve's News</title>       <url>http://www.rssmaniac.com/steve/Image.jpg</url>       <link>www.rssmaniac.com/steve</link>       <description>Steve's News</description>       <width>144</width>       <height>36</height>      </image>        <item>         <title>Steve shovels the snow</title>         <description><![CDATA[It snowed once again.           Time to shovel!]]></description>         <pubDate>Fri, 09 Dec 2005 16:21:11 -0500</pubDate>         <link>http://www.rssmaniac.com/steve</link>         <enclosure url="http://www.rssmaniac.com/steve/snow.mp3"           length="673920" type="audio/mpeg" />        </item>     </channel>    </rss> 


NewzAlert Composer is a good product and gets the job done nicely. But one of the drawbacks is that you have to upload the podcast file yourself. There are some dedicated podcast programs that take care of that for you; those programs will be covered later in this chapter.

FeedForAll

FeedForAll is an RSS creator that lets you add enclosures to feeds easily (Figure 7.10).

Figure 7.10. Title, description, link, and publication date are required fields in the Feeds tab of RSS creator FeedForAll.


To add an enclosure to an item, choose the Items tab and select the item you want to add an enclosure to (Figure 7.11).

Figure 7.11. Select an item under the Items tab to add an enclosure in FeedForAll.


Now, because enclosures are optional in RSS items, select the Optional tab and enter your enclosure's data (Figure 7.12).

Figure 7.12. Add information about your enclosure in the Optional tab in FeedForAll.


As before, you have to enter the URL of the enclosure, its size in bytes, and its MIME type. (NewzAlert Composer gives you a drop-down menu that lists the MIME types, but in FeedForAll, you have to enter the MIME type by hand, so be sure you know the MIME type of your enclosure first.)

With FeedForAll, you choose File > Upload to upload your RSS file. And as with NewzAlert Composer, you have to upload your enclosure separately.

Here's the RSS 2.0 file created by FeedForAll, complete with the new enclosure.

    <?xml version="1.0" encoding="windows-1252"?>    <rss version="2.0">      <channel>        <title>Steve&apos;s News</title>        <description>This feed contains news from Steve!</description>        <link>http://www.rssmaniac.com/steve</link>        <docs>http://blogs.law.harvard.edu/tech/rss</docs>        <lastBuildDate>Mon, 2 Jan 2006 12:49:23 -0500</lastBuildDate>        <pubDate>Mon, 12 Dec 2005 12:05:50 -0500</pubDate>        <generator>FeedForAll v1.0 (1.0.2.0) unlicensed        version</generator>        <item>          <title>Steve shovels the snow</title>          <description>It snowed once again. Time to          shovel!</description>          <link>http://www.rssmaniac.com/steve</link>          <enclosure url="http://www.rssmaniac.com/steve/snow.mp3"          length="673920" type="audio/mpeg"></enclosure>          <pubDate>Mon, 12 Dec 2005 12:05:50 -0500</pubDate>        </item>      </channel>    </rss> 


Like NewzAlert Composer, FeedForAll is a useful tool that makes it easy to create RSS feeds with enclosures. But if you're just going to be creating podcasts, take a look at some of the dedicated podcast software.



Secrets of RSS
Secrets of RSS
ISBN: 0321426223
EAN: 2147483647
Year: 2004
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net