<?xml version="1.0" encoding="utf-8"?>
<!--! This file is a part of MediaCore, Copyright 2009 Simple Station Inc.

	MediaCore is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	MediaCore is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<rss xmlns:py="http://genshi.edgewall.org/"
     xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
     xmlns:media="http://search.yahoo.com/mrss/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     version="2.0">
	<channel>
		<title py:content="podcast.title" />
		<link py:content="h.url_for(action='view', qualified=True)" />
		<language>${translator.locale.territory and '%s-%s' % (translator.locale.language, translator.locale.territory.lower()) or translator.locale.language}</language>
		<docs>http://www.rssboard.org/rss-specification</docs>
		<atom:link href="${h.url_for(qualified=True)}" rel="self" type="application/rss+xml" />

		<description py:content="podcast.subtitle" />
		<itunes:subtitle py:content="podcast.subtitle" />
		<itunes:summary py:content="h.strip_xhtml(podcast.description)" />

		<itunes:category py:if="podcast.category"
		                 py:with="category = podcast.category.split(' &gt; ')"
		                 text="${category[0]}">
			<itunes:category py:if="len(category) > 1"
			                 text="${category[1]}" />
		</itunes:category>

		<py:with vars="author_name = podcast.author.name;
		               author_email = podcast.author.email;">
			<managingEditor>${author_email}<py:if test="author_name"> (${author_name})</py:if></managingEditor>
			<itunes:author py:content="author_name" />
			<itunes:owner>
				<itunes:email py:content="author_email" />
				<itunes:name py:content="author_name" py:if="author_name" />
			</itunes:owner>
		</py:with>

		<itunes:explicit py:choose="podcast.explicit">
			<py:when test="None">no</py:when>
			<py:when test="True">yes</py:when>
			<py:otherwise>clean</py:otherwise>
		</itunes:explicit>

		<image py:with="thumb = h.thumb(podcast, 's', qualified=True)">
			<url py:content="thumb.url" />
			<title py:content="podcast.title" />
			<link py:content="h.url_for(action='view', qualified=True)" />
			<width py:content="thumb.x" />
			<height py:content="thumb.y" />
		</image>
		<itunes:image href="${h.thumb_url(podcast, 'l', qualified=True)}" />
		<!--! iTunes image should be square and 600x600 or larger -->

		<copyright py:content="podcast.copyright" />

<!--!	<pubDate />
		<lastBuildDate />
		<ttl />
		<category />
		<rating /> -->

		<item py:for="media in episodes"
		      py:with="permalink = h.url_for(controller='/media', action='view', slug=media.slug, podcast_slug=podcast.slug, qualified=True)">
			<title py:content="media.title" />
			<guid py:content="permalink" />
			<pubDate py:content="media.publish_on.strftime('%a, %d %b %Y %H:%M:%S %Z')" />
			<comments py:content="permalink + '#comments'" />
			<author>${media.author.email}<py:if test="media.author.name"> (${media.author.name})</py:if></author>
			<itunes:author py:if="media.author.name" py:content="media.author.name" />
			<description py:content="media.description_plain" />
			<itunes:summary py:content="media.description_plain" />
			<itunes:subtitle py:if="media.subtitle" py:content="media.subtitle" />
			<itunes:subtitle py:if="not media.subtitle" py:content="h.truncate(media.description_plain, 120)" />
			<itunes:duration py:if="media.duration" py:content="media.duration" />
			<itunes:keywords py:content="', '.join(tag.name for tag in media.tags)" />
			<media:thumb py:with="thumb = h.thumb(media, 'm', qualified=True)"
			                 url="${thumb.url}" width="${thumb.x}" height="${thumb.y}" />
			<py:with vars="file = h.pick_podcast_media_file(media)">
				<enclosure py:if="file" py:attrs="dict(
					url = h.url_for(controller='/media', action='serve', id=file.id, container=file.container, slug=media.slug, qualified=True),
					length = file.size or None,
					type = file.mimetype,
				)" />
				<media:content py:if="file" py:attrs="dict(
					url = h.url_for(controller='/media', action='serve', id=file.id, container=file.container, slug=media.slug, qualified=True),
					medium = file.type,
					type = file.mimetype,
					fileSize = file.size or None,
					duration = media.duration or None,
					isDefault = 'true',
					expression = 'full',
					lang = 'en',
				)" />
			</py:with>
		</item>

	</channel>
</rss>
