1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.contrib.sites.models import Site
6 from django.contrib.syndication.views import Feed
7 from django.core.urlresolvers import reverse
9 from catalogue import models
11 def absolute_url(url):
12 return "http://%s%s" % (Site.objects.get_current().domain, url)
15 class AudiobookFeed(Feed):
16 description = "Audiobooki ostatnio dodane do serwisu Wolne Lektury."
21 'daisy': 'application/zip',
25 'all': 'WolneLektury.pl - audiobooki we wszystkich formatach',
26 'mp3': 'WolneLektury.pl - audiobooki w formacie MP3',
27 'ogg': 'WolneLektury.pl - audiobooki w formacie Ogg Vorbis',
28 'daisy': 'WolneLektury.pl - audiobooki w formacie DAISY',
31 def get_object(self, request, type):
34 def title(self, type):
35 return self.titles[type]
38 return reverse('audiobook_feed', args=(type,))
40 def items(self, type):
41 objects = models.BookMedia.objects.order_by('-uploaded_at')
43 objects = objects.filter(type__in=('mp3', 'ogg', 'daisy'))
45 objects = objects.filter(type=type)
48 def item_title(self, item):
51 def item_description(self, item):
53 artist = item.get_extra_info_value().get('artist_name', None)
54 if artist is not None:
55 lines.append(u'Czyta: %s' % artist)
56 director = item.get_extra_info_value().get('artist_name', None)
57 if director is not None:
58 lines.append(u'Reżyseruje: %s' % director)
59 return u'<br/>\n'.join(lines)
61 def item_link(self, item):
62 if item.book_set.exists():
63 return item.book_set.all()[0].get_absolute_url()
67 def item_guid(self, item):
68 return absolute_url(item.file.url)
70 def item_enclosure_url(self, item):
71 return absolute_url(item.file.url)
73 def item_enclosure_length(self, item):
76 def item_enclosure_mime_type(self, item):
77 return self.mime_types[item.type]
79 def item_pubdate(self, item):
80 return item.uploaded_at