@@ -26,16 +26,19 @@ from django.utils.feedgenerator import Rss201rev2Feed
from .models import Cast
# FIXME: Settings here should not be hard-coded for given casts, but
# should instead have settings from the main screen.
class CastFeedBase(Feed):
def copyright_holder(self): return "Bradley M. Kuhn, Karen M. Sandler"
def copyright_holder(self):
return "Bradley M. Kuhn, Karen M. Sandler"
def license_no_html(self): return "Licensed under a Creative Commons Attribution-Share Alike 3.0 USA License."
def license_no_html(self):
return "Licensed under a Creative Commons Attribution-Share Alike 3.0 USA License."
def item_copyright(self, item):
year = 2008
for attr in ('pub_date', 'date_created', 'date_last_modified'):
if hasattr(item, attr):
if hasattr(getattr(item, attr), 'year'):
@@ -129,18 +132,20 @@ def podcast_helper_add_root_elements(self, handler):
handler.addQuickElement("itunes:author", self.feed['iTunesAuthor'])
handler.addQuickElement('atom:link', '', {'rel': "self", 'href': self.feed['feed_url'],
'type': "application/rss+xml"})
years = {}
for ii in self.items: years[ii['year']] = 1
for ii in self.items:
years[ii['year']] = 1
copyrightString = ""
ll = years.keys()
sorted(ll)
for yy in ll: copyrightString += "%d, " % yy
for yy in ll:
copyrightString += "%d, " % yy
copyrightString += "%s. %s" % (self.feed['copyrightHolder'], self.feed['copyrightLicense'])
handler.addQuickElement('copyright', copyrightString)
handler.addQuickElement('media:copyright', "Copyright (C) " + copyrightString)
@@ -153,12 +158,13 @@ def podcast_helper_add_item_elements(self, handler, item):
handler.addQuickElement("itunes:duration", item['duration'])
if 'enclosure' in item:
handler.addQuickElement('media:content', '', {'url': item['enclosure'].url,
'fileSize': item['enclosure'].length,
'type': item['enclosure'].mime_type})
# http://www.feedforall.com/itune-tutorial-tags.htm
# http://www.feedforall.com/mediarss.htm
class iTunesFeedType(Rss201rev2Feed):
def root_attributes(self):
attrs = super().root_attributes()
attrs['xmlns:itunes'] = 'http://www.itunes.com/dtds/podcast-1.0.dtd'
@@ -232,23 +238,29 @@ class CastFeed(CastFeedBase):
#<itunes:author>
# If applicable, at the item level, this tag can contain information
# about the person(s) featured on a specific episode.
class Mp3CastFeed(CastFeed):
def item_enclosure_mime_type(self): return "audio/mpeg"
def item_enclosure_mime_type(self):
return "audio/mpeg"
def item_enclosure_url(self, item):
return add_domain(self.current_site.domain, item.mp3_path, self.is_secure)
def item_enclosure_length(self, item):
return item.mp3_length
class OggCastFeed(CastFeed):
def item_enclosure_mime_type(self): return "audio/ogg"
return "audio/ogg"
return add_domain(self.current_site.domain, item.ogg_path, self.is_secure)
return item.ogg_length
feed_dict = {
'cast-ogg': OggCastFeed,