31 - Implementing a Podcast Feed in ExpressionEngine

The final step in the all-native-EE podcast implementation is getting the actual podcast feed template in place.  In this chapter I’ll do that - and also implement the autorecognition code so that smart browsers like Firefox will indicate the availability of a feed.

 
Download the EE Code for 31 - Implementing a Podcast Feed in ExpressionEngine

Up to this point our church site Audio Messages section had two ways for site visitors to consume the audio versions of the church weekend messages - they could download the MP3 to play locally in their choice of player, or they could use the Wimpy button to listen to the message right on the site.

However what both of these methods miss is the central draw of true podcasting—in that, once subscribed to a feed, users get subsequent new episodes automatically.  While use of podcasting may or may not successful in your church depending on the demographic getting the podcast feed published is so simple that there’s really no good reason not to do it.  You might be surprised to see where your audience comes from - I know our little church here in W. MI has people in the Seattle area that feel like members because they can listen to the messages on their iPod and interact with the church using the website.

What’s the Plan, Stan?
Overall, all I needed to:

  • Add a Length field to the audio-messages weblog
  • Edit Content to add lengths
  • Add length field to audio-messages/index and audio-messages/comments
  • Implement the podcast template
  • Link the podcast in the Audio Messages sidebar
  • Add the autodiscovery code to the site’s HTML header

Adding a Length Field
So in the last chapter I remarked that if I were doing this site for an actual client I’d add a length field - so when site visitors click the “play” button they’d know long of a message they were going to hear.  As it turns out, in order to publish a podcast feed using the iTunes spec, I need a length field anyway.  I added a field named “message_length” to the Audio Messages field group that drives the audio-messages weblog.  I created just a text entry field, chose no styling, and didn’t make the field searchable. 

Editing Content
Once the field was in place I went back and edited my content in that weblog to enter a value for the length. Having an A/V background I first entered values in the hh:mm:ss format - then found that iTunes wants only positive integers for length. I went back and just put in the number of minutes for length.  So, for example, for a sermon that was just over an hour rather than putting in “01:03:45” I just rounded and put in “64”.

Updating the audio-messages Templates
With new content now that can be displayed, I updated the audio-messages/index and audio-messages/comments templates to pull it back out.  I added the following to the weblog:entries tag on both:

{if message_length}
    
<p>Length:&nbsp;<strong>{message_length} minutes</strong></p>
{/if} 

Note that the template supplies the “minutes” text, so all content admins will need to enter is just a numerical value.  It’s a good idea to make a note of this in the help comments for the specific field, along with providing an example.

The Podcast Template
Now - onto the main task at hand.  The big question here is - where to start?  Apple has a page on Making a Podcast, and included in that is an example feed.  One step closer is the Podcast Template on the ExpressionEngine wiki.  I used that on a recent client project and found that it still needed some tweaks - so what I did was grab the template I had done for a client and used it as my starting point for this chapter. 

I created a new template in the audio-messages template group, named it podcast, and chose a template type of “RSS”.  Below is the code for that template - give it a quick scan and I’ll point out some issues I had while creating it. 

{exp:rss:feed weblog="audio-messages"}
<?xml version
="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<
channel>
<
ttl>60</ttl>
<
title>Train-EE Example Church Site Podcast</title>
<
link>http://church.train-ee.com</link>
<language>en-us</language>
<
copyright>Boyink InteractiveTrain-ee.com</copyright>
<
description>Sermon Messages from Our Example Church</description>
<
itunes:subtitle>Real LifeReal StrugglesReal Answers. </itunes:subtitle>
<
itunes:author>Michael Boyink</itunes:author>
<
itunes:summary>{exp:xml_encode}The example church site from Train-ee.com shows Christian web developers how to implement a church website on the ExpressionEngine content management system.  ExpressionEngine is powering this podcast feed.{/exp:xml_encode}</itunes:summary>
<
itunes:owner>
<
itunes:name>Michael Boyink</itunes:name>
<
itunes:email>eeforme@train-ee.com</itunes:email>
</
itunes:owner>
<
itunes:image href="http://church.train-ee.com/train-ee-podcast.png" />
<
itunes:category text="Religion &amp; Spirituality">
<
itunes:category text="Christianity"/>
</
itunes:category>
<
itunes:explicit>no</itunes:explicit>
{exp:weblog:entries weblog="audio-messages"}
<item>
<
title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
<
itunes:author>Michael Boyink</itunes:author>
<
itunes:subtitle>{exp:xml_encode}{title}{/exp:xml_encode}</itunes:subtitle>
<
itunes:summary>{exp:html_strip}{exp:xml_encode}{message_summary}{/exp:xml_encode}{/exp:html_strip}</itunes:summary>
<
enclosure url="{site_url}audio_files/{audio_file}" length="{message_length}" type="audio/mpeg" />
<
guid>{title_permalink=audio-messages/comments}</guid>
<
pubDate>{entry_date format="%D, %d %M %Y %H:%i:%s %O"}</pubDate>
<
itunes:duration>{message_length}</itunes:duration>
<
itunes:keywords>Boinktrainee</itunes:keywords>
</
item>
{/exp:weblog:entries}
</channel>
</
rss>
{/exp:rss:feed} 

Validating Your Feed
A handy resource to use while working with RSS feeds in general is the Feed Validator - however while the validator has iTunes-specific error messaging, I did note that in it’s validation results for an iTunes feed it makes recommendations for an Atom feed (specifically the “rel=self” where it wants you to put a link to the podcast feed in the podcast feed).  I’ll admit that my expertise runs out somewhere in this process, but after putting in the rel=self code and getting a different error it just seems like that recommendation isn’t correct for a iTunes type feed.  If anyone knows more about these specific issues I’d appreciate some comments.  I ended up just stopping at getting a valid feed and didn’t implement the Atom-related recommendations.

Overall the things you’ll need to change are pretty obvious - the title, the link, the graphic etc.  However if you’re using this code as the basis for a non-church related podcast you’ll need to change the category and subcategory - and you’ll need to choose from a predefined list that Apple maintains. That list is at the bottom of the Making a Podcast page I linked to above.

I did use the HTML Strip Plugin in the summary field as the validator didn’t like the content there otherwise.  Also of note is Apples expectation around the use of the Keywords field as it’s not what you might expect.  It’s not parallel to meta-tag keywords.  Apple has this to say:

Minimize keyword usage. Almost nothing belongs in the keywords tag that isn’t better handled in the title or

tag. The best use for keywords is to include common misspellings of your name or title, to ensure your podcast is still searchable despite a misspelling. To prevent keyword abuse, iTunes indexes only the first 12 keywords found in this tag.
Source: http://www.apple.com/itunes/whatson/podcasts/specs.html

The Working Feed
Here’s the rendered feedOne caveat I do want to point out is that I’m not an iTunes user - so I was unable to verify if this feed would actually show up in iTunes.

Linking to the Podcast Template
I want to link to the new podcast template in two ways - the first being a visual link right on the audio-messages templates. Since the link will be both on the audio-messages and audio-messages/comments templates I created a new embedded template that both parent templates can use.  The new template is named sidebar_podcast_link and the code is :

<div class="navcontainer">
<
h3>Podcast User?</h3>
    <
ul class="navlist">
        <
li><a href="{path='audio-messages/podcast'}">Feed Me!</a></li>
    </
ul>
</
div


Then in the parent templates I just put the embed statement under the statements for the category and archive nav:

<div class="content_page_left">
    
{embed="embeds/sidebar_category_nav" my-section="audio-messages"}
    {embed
="embeds/sidebar_archive_nav" my-section="audio-messages"}
    {embed
="embeds/sidebar_podcast_link"}
</div

That does it for the visual link.

RSS Autodiscovery
The last thing I want to do is use autodiscovery code such that the browser and other devices to automatically find the feed.  I can do this by adding the following code to embeds/html_header

{if segment_1=="audio-messages"}
    
<link rel="alternate" type="application/rss+xml" title="Train-ee Free Tutorials" href="{path='audio-messages/podcast'}" />
{/if} 

With this in place I can visit the audio-messages section of the site and see Firefox light up it’s RSS icon in the address bar.  I used the conditional so that this code would only run for the audio-messages section.  You might decide to just have it there across the entire site - it’s up to you.

Next up I’ll cover implementing the podcast using Hipcast, rather than doing everything in EE.

 

Category Navigation

<< Previous Entry   

Next Entry >>

 

Previous Comments

Picture of Kevin

by Kevin

Date: Saturday, December 20th, 2008
Comment: #1

Mike,

Thanks for the great amount of detail you went into for the “Feed” section. This is the section I was most interested as the examples online weren’t quite “tweaked” enough for corporate use.

I was wondering, after you complete a series (like the small business site) online, how much do you change the content before you put it into book form?  Do you ever have an “ah ha” moment when you think of a completely better way of implementing, then change that in your books?

Have a blessed Christmas and have a great New Year!

Kevin

Mike Boyink

by Mike Boyink (Author)

Date: Sunday, December 21st, 2008
Comment: #2

Well…based on my vast experience of writing books…;)

With the small business book it was more of an editorial rough draft to less rough book process.  We found many places where I wasn’t consistent in how I referenced CP items, etc. 

For that book there was some EE cleanup in that I re-did the site on it’s own rather than being part of Boyink.com - so template group names were better and paths were cleaner.

For the church site I don’t see much changing in the EE implementation approach, but assume the book will be filled in with more screen captures, and better/re-written text.

I think some of the early chapters might end up getting condensed for clarity as well. 

So is the real question “will the book be worth buying when it’s all here on Train-ee for free?” ;)

I might also choose to do some extra things in the book just to add some value to it…we’ll see.

Picture of Brandon Richards

by Brandon Richards

Date: Tuesday, April 28th, 2009
Comment: #3

Hey Mike,
One thing you can do to eliminate the need to setup fields for the feed enclosures is to use the feed enclosure plugin http://expressionengine.com/downloads/details/feed_enclosures/ within the feed like:

{exp:feed_enclosures tag=“rss” parse_list=“y”}{podcast_file}{/exp:feed_enclosures}

Picture of Jan

by Jan

Date: Tuesday, June 2nd, 2009
Comment: #4

Hi Mike,

Just got the first “real” comment on the developing Church website, and I want to pass it on to you because you are so much a part of the success! (It’s comment #2, and it’s from an Elder).

http://www.gloryofgodcocoa.org/index.php/weblog/comments/god_moves_in_contemporary_ways/

I can’t thank you enough, and I can’t say it big enough to encompass all you’ve done and are doing.

BTW don’t miss the footer…

Jan

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, June 2nd, 2009
Comment: #5

Hey Jan -

Thanks for the comment and the link!

Picture of Jan

by Jan

Date: Tuesday, June 2nd, 2009
Comment: #6

I’m sure someone probably told you by now, but if not, you’ll be happy to know the feed does work perfectly with iTunes!

Picture of Brian Kalwat

by Brian Kalwat

Date: Sunday, July 19th, 2009
Comment: #7

Brilliant. Sheer Brilliance. Finally all anyone needs to update the podcast is the audio file and a web browser… :D

Picture of Brian Kalwat

by Brian Kalwat

Date: Wednesday, August 26th, 2009
Comment: #8

Hey Mike,

I’ve been working on this for a few hours now, and when I try to view the rendered template for the RSS feed, all it says is “No input file specified.” Can I send you my source or something? Not sure where I went wrong.

Mike Boyink

by Mike Boyink (Author)

Date: Thursday, August 27th, 2009
Comment: #9

Hey Brian—

Have you tried Googling that error message?

Picture of Brian Kalwat

by Brian Kalwat

Date: Thursday, August 27th, 2009
Comment: #10

Yeah, and I came to realize that it wasn’t just the page. I updated a setting in my general setting and it’s fixed…..except I received an email from iTunes this morning telling me my feed was rejected… again. :(

Picture of John

by John

Date: Monday, September 14th, 2009
Comment: #11

Argh… getting some errors… any ideas?
———————————————————————————————-

This page contains the following errors:

error on line 1 at column 16: Namespace prefix ee on last_update is not defined
error on line 3 at column 6: XML declaration allowed only at the start of the document

Below is a rendering of the page up to the first error.

1252967328

Picture of John

by John

Date: Monday, September 14th, 2009
Comment: #12

Nevermind that last comment.

I had the template type as “XML” rather than “RSS”.  Rookie mistake!

Picture of Jan McLarty

by Jan McLarty

Date: Saturday, December 3rd, 2011
Comment: #13

Hi Mike,
Is there any reason the podcast and wimpy button that worked in ee v1.6 will not work in ee v2.3? I have gone over all the templates, even pulled out all the embeds on my audio-messages/index template and can’t figure why I’m getting a PHP error. I’ve had a help request in at the ee forum since Dec 1 that is being ignored.

ERROR:
The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "DB_Cache" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home1/jchostco/public_html/gogac/gg/expressionengine/modules/channel/mod.channel.php on line 3686

Picture of Boyink

by Boyink

Date: Monday, December 5th, 2011
Comment: #14

No idea Jan - I’ve not tried it on EE2.

Add Your Comment

Commenting is not available in this channel entry.

Unless otherwise stated all content is © Michael Boyink of Train-ee.com & Boyink Interactive. Please don't steal - I've got kids to feed...

dy>