Question

I am trying to create an program that automatically creates iTunes Podcast RSS feeds. The problem I am running into is I dont know how to create the require XML elements. I tried to create two tags here in two different ways. First I used "itunes:" for subtitle and it doesnt work it throws an exception that I cant use the colon in my name. The second one (image) outputs this

<image xmlns="http://www.itunes.com/dtds/podcast-1.0.dtd" href="http://someurkl.com/myimgp.png"/>

Is there any way to get this to work with ASP.net? Or can you point me the right direction of documentation or a tutorial that can show me how to create a feed for a iTunes podcast.

My Code:

XNamespace itunesNS = "http://www.itunes.com/dtds/podcast-1.0.dtd";

SyndicationFeed feed = new SyndicationFeed(title, description, new Uri(link));

feed.ElementExtensions.Add(new XElement("itunes:" + "subtitle", subTitle).CreateReader());
feed.ElementExtensions.Add(new XElement(itunesNS + "image", new XAttribute("href", imageUrl)).CreateReader());

Format Required By iTunes:

<itunes:subtitle>My Subtitle Here</itunes:subtitle>

Example Feed from Apple:

<?xml version="1.0" encoding="UTF-8"?>

<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
    <title>All About Everything</title>
    <link>http://www.example.com/podcasts/everything/index.html</link>
    <language>en-us</language>
    <copyright>&#x2117; &amp; &#xA9; 2005 John Doe &amp; Family</copyright>
    <itunes:subtitle>A show about everything</itunes:subtitle>
    <itunes:author>John Doe</itunes:author>
    <itunes:summary>All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our Podcast in the iTunes Store</itunes:summary>
    <description>All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our Podcast in the iTunes Store</description>
    <itunes:owner>
        <itunes:name>John Doe</itunes:name>
        <itunes:email>john.doe@example.com</itunes:email>
    </itunes:owner>
    <itunes:image href="http://example.com/podcasts/everything/AllAboutEverything.jpg" />
    <itunes:category text="Technology">
    <itunes:category text="Gadgets"/>
    </itunes:category>
    <itunes:category text="TV &amp; Film"/>
    <item>
        <title>Shake Shake Shake Your Spices</title>
        <itunes:author>John Doe</itunes:author>
        <itunes:subtitle>A short primer on table spices</itunes:subtitle>
        <itunes:summary>This week we talk about salt and pepper shakers, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!</itunes:summary>
        <itunes:image href="http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg" />
        <enclosure url="http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a" length="8727310" type="audio/x-m4a" />
        <guid>http://example.com/podcasts/archive/aae20050615.m4a</guid>
        <pubDate>Wed, 15 Jun 2005 19:00:00 GMT</pubDate>
        <itunes:duration>7:04</itunes:duration>
    </item>

    <item>
        <title>Socket Wrench Shootout</title>
        <itunes:author>Jane Doe</itunes:author>
        <itunes:subtitle>Comparing socket wrenches is fun!</itunes:subtitle>
        <itunes:summary>This week we talk about metric vs. old english socket wrenches. Which one is better? Do you really need both? Get all of your answers here.</itunes:summary>
        <itunes:image href="http://example.com/podcasts/everything/AllAboutEverything/Episode2.jpg" />
        <enclosure url="http://example.com/podcasts/everything/AllAboutEverythingEpisode2.mp3" length="5650889" type="audio/mpeg" />
        <guid>http://example.com/podcasts/archive/aae20050608.mp3</guid>
        <pubDate>Wed, 8 Jun 2005 19:00:00 GMT</pubDate>
        <itunes:duration>4:34</itunes:duration>
    </item>

    <item>
        <title>Red, Whine, &amp; Blue</title>
        <itunes:author>Various</itunes:author>
        <itunes:subtitle>Red + Blue != Purple</itunes:subtitle>
        <itunes:summary>This week we talk about surviving in a Red state if you are a Blue person. Or vice versa.</itunes:summary>
        <itunes:image href="http://example.com/podcasts/everything/AllAboutEverything/Episode3.jpg" />
        <enclosure url="http://example.com/podcasts/everything/AllAboutEverythingEpisode1.mp3" length="4989537" type="audio/mpeg" />
        <guid>http://example.com/podcasts/archive/aae20050601.mp3</guid>
        <pubDate>Wed, 1 Jun 2005 19:00:00 GMT</pubDate>
        <itunes:duration>3:59</itunes:duration>
    </item>
</channel>
</rss>

No correct solution

OTHER TIPS

TL;DR

Looks like you need to define a custom namespace for the itunes: tag in the area of your code that generates your rss.


Here is some info originally written by Lukasz Karolak, that might help you.

Let’s assume we would like to have a RSS feed, which in fact would serve as a podcast, e.g. for iTunes. The software from Apple uses some information from their custom-defined RSS-tags, with an itunes prefix, for example:

<itunes:author>Anonymous One</itunes:author>

Without this prefix it’s very easy. Our SyndicationItem class provides us a functionality to extend the standard item’s elements:

SyndicationItem item = new SyndicationItem();
item.ElementExtensions.Add(customTagString.Empty, "My test");

The second attribute is the namespace which comes into play in the next step. In order to add the tag prefix as mentioned before, one has start with adding the namespace to the feed instance:

SyndicationFeed feed = new SyndicationFeed();
XmlQualifiedName n=new XmlQualifiedName("itunes","http://www.w3.org/2000/xmlns/");
String itunesNs = "http://www.itunes.com/dtds/podcast-1.0.dtd";
feed.AttributeExtensions.Add(n, itunesNs);

Now that we have added the new namespace to the feed, we can start adding custom item elements within that namespace.

SyndicationItem item = new SyndicationItem();
item.ElementExtensions.Add(new SyndicationElementExtension("author",
     itunesNs, "Famous author"));

That should solve the issue with custom tags with custom prefixes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top