@@ -15,16 +15,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program in a file in the toplevel directory called
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
#
from datetime import datetime
import itertools
import operator
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
from django.contrib.syndication.views import Feed, add_domain
from django.shortcuts import render
from django.utils.feedgenerator import Rss201rev2Feed
from .models import Cast
@@ -52,14 +49,16 @@ class CastFeedBase(Feed):
if hasattr(item, attr):
if hasattr(getattr(item, attr), 'year'):
year = getattr(getattr(item, attr), 'year')
break
return {'year': year}
def for_podcast_feed_extra_kwargs(self, obj):
return { 'managingEditorNames' : 'Bradley and Karen',
return {
'managingEditorNames': 'Bradley and Karen',
'rssImage': {'url': 'http://faif.us/img/cast/faif_144x144.jpg',
'width': '144', 'height': '144'},
'webMaster': 'oggcast@faif.us (Bradley and Karen)',
'dcCreator': 'oggcast@faif.us (Bradley and Karen)',
'iTunesExplicit': 'No',
'iTunesBlock': 'No',
@@ -70,19 +69,24 @@ def for_podcast_feed_extra_kwargs(self, obj):
'category': {'name': 'Government & Organizations', 'scheme': 'http://www.itunes.com/dtds/podcast-1.0.dtd',
'subcats': ['Non-Profit']},
'keywords': 'open source, opensource, freesoftware, software freedom, legal, law, linux, free, license, gpl, lgpl, agpl, bsd',
'iTunesAuthor': 'Software Freedom Conservancy',
'iTunesSubtitle': 'Bi-Weekly Discussion of Legal, Policy, and Any other Issues in the Free, Libre, and Open Source Software (FLOSS) Community',
'copyrightHolder': self.copyright_holder(),
'copyrightLicense' : self.license_no_html() }
'copyrightLicense': self.license_no_html(),
}
def for_podcast_item_extra_kwargs(self, item):
return { 'duration' : item.duration,
'duration': item.duration,
'year': item.date_created.year,
'intheitembkuhn' : item.__dict__.__str__()}
'intheitembkuhn': item.__dict__.__str__(),
def podcast_helper_add_root_elements(self, handler):
handler.addQuickElement('managingEditor', self.feed['author_email']
+ ' (' + self.feed['managingEditorNames'] + ')')
handler.startElement('image', {})
handler.addQuickElement('url', self.feed['rssImage']['url'])
@@ -136,12 +140,13 @@ def podcast_helper_add_root_elements(self, handler):
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)
def podcast_helper_add_item_elements(self, handler, item):
handler.addQuickElement("itunes:explicit", self.feed['iTunesExplicit'])
handler.addQuickElement("itunes:block", self.feed['iTunesBlock'])
handler.addQuickElement("itunes:keywords", self.feed['keywords'])
# handler.addQuickElement('dc:creator', self.feed['dcCreator'])
handler.addQuickElement("itunes:author", item['author_name'])
@@ -233,28 +238,31 @@ class Mp3CastFeed(CastFeed):
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 add_domain(self.current_site.domain, item.ogg_path, self.is_secure)
return item.ogg_length
feed_dict = {
'cast-ogg': OggCastFeed,
'cast-mp3': Mp3CastFeed,
# make each feed know its canonical url
for k, v in feed_dict.items():
v.get_absolute_url = '/feeds/%s/' % k
def view(request):
"""Listing of all available feeds
"""
feeds = feed_dict.values()
return render(request, "feeds.html", {'feeds': feeds})