diff --git a/dss/settings.py b/dss/settings.py index 1eb21ac..c22fb5a 100644 --- a/dss/settings.py +++ b/dss/settings.py @@ -135,6 +135,7 @@ INSTALLED_APPS = ( 'django_facebook', 'compressor', 'djcelery', + 'podcast', #'debug_toolbar', 'crispy_forms', 'sorl.thumbnail', diff --git a/requirements.txt b/requirements.txt index 1010e22..deeb25f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,6 +16,7 @@ git+git://github.com/PaulUithol/backbone-tastypie.git#egg=backbone-tastypie git+git://github.com/maraujop/django-crispy-forms.git#django-crispy-forms git+git://github.com/tschellenbach/Django-facebook.git#django-facebook git+git://github.com/hpoul/sct-communitytools.git#django-sct +git+git://github.com/jefftriplett/django-podcast.git#django-podcast django-grappelli humanize django-debug-toolbar diff --git a/spa/models/Mix.py b/spa/models/Mix.py index 17d18df..ff9706a 100644 --- a/spa/models/Mix.py +++ b/spa/models/Mix.py @@ -1,3 +1,4 @@ +from django.contrib.sites.models import Site from django.db.models.signals import post_save from django.dispatch import Signal, receiver import os @@ -53,6 +54,9 @@ class Mix(_BaseModel): def get_absolute_url(self): return '/mix/%i' % self.id + def get_download_url(self): + return 'http://%s/audio/download/%s' % (Site.objects.get_current().domain, self.pk) + def get_waveform_path(self): return os.path.join(settings.MEDIA_ROOT, "waveforms/", "%s.%s" % (self.uid, "png")) diff --git a/spa/podcast.py b/spa/podcast.py index 32cad98..a540cb5 100644 --- a/spa/podcast.py +++ b/spa/podcast.py @@ -1,37 +1,14 @@ -import PyRSS2Gen -from django.contrib.sites.models import Site -from django.http import HttpResponse -from xml.etree.ElementTree import Element, SubElement, Comment, tostring -import datetime -import os +from django.shortcuts import render_to_response, render +from django.template import RequestContext, Context from spa.models import Mix def get_default_podcast(request): - mixes = Mix.objects.all() - items = [] - for mix in mixes: - items += [ - PyRSS2Gen.RSSItem( - title = mix.title, - link = 'http://%s:%s/audio/download/%s' % (Site.objects.get_current().domain, request.META['SERVER_PORT'], mix.pk), - enclosure = - PyRSS2Gen.Enclosure('http://%s:%s/audio/download/%s' % - (Site.objects.get_current().domain, request.META['SERVER_PORT'], mix.pk), - os.path.getsize(mix.local_file.path), "audio/mpeg"), - description = mix.description, - pubDate = mix.upload_date, - categories = [PyRSS2Gen.Category("Music")], - guid = 'http://%s:%s%s' % (Site.objects.get_current().domain, request.META['SERVER_PORT'], mix.get_absolute_url())) - ] - - rss = PyRSS2Gen.RSS2( - title = "Deep South Sounds Podcast", - link = "http://deepsouthsounds.com", - description = "Deep house music with a Cork twist", - lastBuildDate = datetime.datetime.now(), - items=items) - - return HttpResponse(rss.to_xml(), mimetype="text/xml") + return render( + request, + 'inc/xml/podcast.xml', + {'items': mixes}, + content_type='text/xml' + ) diff --git a/spa/urls.py b/spa/urls.py index df5093c..7763056 100644 --- a/spa/urls.py +++ b/spa/urls.py @@ -30,6 +30,8 @@ urlpatterns = django.conf.urls.patterns( url(r'^js/(?P\w+)/$', 'spa.templates.get_javascript'), url(r'^tplex/(?P\w+)/$', 'spa.templates.get_template_ex'), (r'^podcast\.xml', 'spa.podcast.get_default_podcast'), + (r'^podcast', 'spa.podcast.get_default_podcast'), + (r'^podcasts', 'spa.podcast.get_default_podcast'), (r'^social/', include(social.urls)), (r'^ajax/', include(ajax.urls)), (r'^audio/', include(audio.urls)), diff --git a/templates/inc/xml/podcast.xml b/templates/inc/xml/podcast.xml new file mode 100644 index 0000000..4fe8fce --- /dev/null +++ b/templates/inc/xml/podcast.xml @@ -0,0 +1,48 @@ + + + + 60 + + Deep South Sounds Podcast + Deep House Music with a Cork twist + + http://www.deepsouthsounds.com/podcast/ + en-IE + All your muzik is belong to us + Deep House Music with a Cork twist + Deep South Sounds + Deep House Music with a Cork twist + + Deep South Sounds + admin@deepsouthsounds.com + + + + + + + + {% for item in items %} + + {{ item.title }} + Episode author + {{ item.title }} + {{ item.description }} + + + item.get_download_url + + {{ item.get_download_url }} + + + deep, house, music + + {% endfor %} + + \ No newline at end of file