<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">

{% regroup object_list by show as show_list %}{% for show in show_list %}<channel>
    <title>{{ show.grouper.title }}</title>
    <link>{{ show.grouper.link }}</link>
    <description>{{ show.grouper.description|striptags }}</description>
    {% if show.grouper.language %}<language>{{ show.grouper.language }}</language>{% endif %}
    <copyright>&#x2117; &amp; &#xA9; {% now "Y" %} {{ show.grouper.organization }}. {{ show.grouper.copyright }}.</copyright>
    <managingEditor>{% for author in show.grouper.author.all %}{% if forloop.first %}{% else %}{% if forloop.last %} and {% else %}, {% endif %}{% endif %}{{ author.email }}{% endfor %}</managingEditor>
    {% if show.grouper.author.email or show.grouper.webmaster.email %}<webMaster>{% if show.grouper.webmaster.email %}{{ show.grouper.webmaster.email }}{% else %}{% endif %}</webMaster>{% endif %}
    <lastBuildDate>{{ show.list.0.date|date:"r" }}</lastBuildDate>
    {% if show.grouper.category_show %}<category{% if show.grouper.domain %} domain="{{ show.grouper.domain }}"{% endif %}>{{ show.grouper.category_show }}</category>{% endif %}
    <generator>Django Web Framework</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    {% if show.grouper.ttl %}<ttl>{{ show.grouper.ttl }}</ttl>{% endif %}
    {% if show.grouper.image %}<image>
      <url>{{ show.grouper.image.url }}</url>
      <title>{{ show.grouper.title }}</title>
      <link>{{ show.grouper.link }}</link>
    </image>{% endif %}
    <itunes:author>{{ show.grouper.organization }}</itunes:author>
    <itunes:owner>
        <itunes:name>{% for author in show.grouper.author.all %}{% if forloop.first %}{% else %}{% if forloop.last %} and {% else %}, {% endif %}{% endif %}{% if author.first_name or author.last_name %}{% if author.first_name and author.last_name %}{{ author.first_name }} {{ author.last_name }}{% endif %}{% if author.first_name and not author.last_name %}{{ author.first_name }}{% endif %}{% if author.last_name and not author.first_name %}{{ author.last_name }}{% endif %}{% else %}{{ author.username }}{% endif %}{% endfor %}</itunes:name>
        <itunes:email>{% for author in show.grouper.author.all %}{{ author.email }}{% if forloop.last %}{% else %}, {% endif %}{% endfor %}</itunes:email>
    </itunes:owner>
    {% if show.grouper.subtitle %}<itunes:subtitle>{{ show.grouper.subtitle }}</itunes:subtitle>{% endif %}
    <itunes:summary>{% if show.grouper.summary %}{{ show.grouper.summary|striptags }}{% else %}{{ show.grouper.description|striptags }}{% endif %}</itunes:summary>
    {% if show.grouper.image %}<itunes:image href="{{ show.grouper.image.url }}" />{% endif %}
    {% if show.grouper.category.all %}{% for category in show.grouper.category.all %}{% if category.name %}<itunes:category text="{{ category.parent.name }}">
      <itunes:category text="{{ category.name }}" />
    </itunes:category>
    {% else %}<itunes:category text="{{ category.parent.name }}" />
    {% endif %}{% endfor %}{% endif %}
    {% if show.grouper.explicit %}<itunes:explicit>{{ show.grouper.explicit|lower }}</itunes:explicit>{% endif %}
    {% if show.grouper.block %}<itunes:block>yes</itunes:block>{% endif %}
    {% if show.grouper.redirect %}<itunes:new-feed-url>{{ show.grouper.redirect }}</itunes:new-feed-url>{% endif %}
    
    {% for episode in show.list %}

      {% for enclosure in episode.enclosure_set.all %}<item>

	{% if enclosure.file %}
          <title>{{ episode.title }}{% if enclosure.title %}: {{ enclosure.title }}{% endif %}</title>
          <link>{{ enclosure.file.url }}</link>
          <description>{{ episode.description|striptags }}</description>
          <author>{% for author in show.grouper.author.all %}{{ author.email }}{% if forloop.last %}{% else %}, {% endif %}{% endfor %}</author>
          {% if episode.category %}<category{% if episode.domain %} url="{{ episode.domain }}"{% endif %}>{{ episode.category }}</category>{% endif %}
          <enclosure url="{{ enclosure.file.url }}" length="{{ enclosure.file.size }}" type="{{ enclosure.mime }}" />
          <guid isPermalink="true">{{ enclosure.file.url }}</guid>
          <pubDate>{{ episode.date|date:"r" }} GMT</pubDate>
          <itunes:author>{% for author in episode.author.all %}{% if forloop.first %}{% else %}{% if forloop.last %} and {% else %}, {% endif %}{% endif %}{% if author.first_name or author.last_name %}{% if author.first_name and author.last_name %}{{ author.first_name }} {{ author.last_name }}{% endif %}{% if author.first_name and not author.last_name %}{{ author.first_name }}{% endif %}{% if author.last_name and not author.first_name %}{{ author.last_name }}{% endif %}{% else %}{{ author.username }}{% endif %}{% endfor %}</itunes:author>
          {% if episode.subtitle %}<itunes:subtitle>{{ episode.subtitle }}</itunes:subtitle>{% endif %}
          <itunes:summary>{% if episode.summary %}{{ episode.summary|striptags }}{% else %}{{ episode.description|striptags }}{% endif %}</itunes:summary>
          {% if episode.minutes and episode.seconds %}<itunes:duration>{{ episode.minutes }}:{{ episode.seconds }}</itunes:duration>{% endif %}
          {% if episode.keywords %}<itunes:keywords>{{ episode.keywords }}</itunes:keywords>{% endif %}
          {% if episode.explicit %}<itunes:explicit>{{ episode.explicit|lower }}</itunes:explicit>{% endif %}
          {% if episode.block %}<itunes:block>yes</itunes:block>{% endif %}
	{% endif %}
        </item>
      {% endfor %}
    {% endfor %}
    
</channel>
{% endfor %}
</rss>
