mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-06 17:04:30 +00:00
Fixed enclosure in file size
This commit is contained in:
@@ -135,6 +135,7 @@ INSTALLED_APPS = (
|
||||
'django_facebook',
|
||||
'compressor',
|
||||
'djcelery',
|
||||
'podcast',
|
||||
#'debug_toolbar',
|
||||
'crispy_forms',
|
||||
'sorl.thumbnail',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ urlpatterns = django.conf.urls.patterns(
|
||||
url(r'^js/(?P<template_name>\w+)/$', 'spa.templates.get_javascript'),
|
||||
url(r'^tplex/(?P<template_name>\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)),
|
||||
|
||||
48
templates/inc/xml/podcast.xml
Normal file
48
templates/inc/xml/podcast.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
|
||||
<channel>
|
||||
<ttl>60</ttl>
|
||||
<!-- Automatically feed your weblog name and description to iTunes -->
|
||||
<title>Deep South Sounds Podcast</title>
|
||||
<description>Deep House Music with a Cork twist</description>
|
||||
<!-- You can also autofeed the link to your podcast weblog -->
|
||||
<link>http://www.deepsouthsounds.com/podcast/</link>
|
||||
<language>en-IE</language>
|
||||
<copyright>All your muzik is belong to us</copyright>
|
||||
<itunes:subtitle>Deep House Music with a Cork twist</itunes:subtitle>
|
||||
<itunes:author>Deep South Sounds</itunes:author>
|
||||
<itunes:summary>Deep House Music with a Cork twist</itunes:summary>
|
||||
<itunes:owner>
|
||||
<itunes:name>Deep South Sounds</itunes:name>
|
||||
<itunes:email>admin@deepsouthsounds.com</itunes:email>
|
||||
</itunes:owner>
|
||||
<!-- This is the image that shows in your iTunes listing -->
|
||||
<itunes:image href="http://static.deepsouthsounds.com/img/dss-large.png"/>
|
||||
<itunes:category text="Music">
|
||||
<itunes:category text="Music Podcast"/>
|
||||
</itunes:category>
|
||||
<!--
|
||||
This portion starts the actual listing of your podcast episodes. The above
|
||||
just gives info on your podcast show. That's why we specify the weblog tag
|
||||
here.
|
||||
-->
|
||||
{% for item in items %}
|
||||
<item>
|
||||
<title>{{ item.title }}</title>
|
||||
<itunes:author>Episode author</itunes:author>
|
||||
<itunes:subtitle>{{ item.title }}</itunes:subtitle>
|
||||
<itunes:summary>{{ item.description }}</itunes:summary>
|
||||
<enclosure url="{{ item.get_download_url }}" length="{episode_size}" type="audio/x-m4a"/>
|
||||
<!-- url to your episode. I'm using the title permalink but any tag that generates a unique
|
||||
URL to your episode will do. -->
|
||||
<guid>item.get_download_url</guid>
|
||||
<!-- The date/time stamp for your podcast. Again, iTunes is super-strict about this. If your
|
||||
date/time stamp is not exactly how Apple wants it your feed will break. -->
|
||||
<pubDate>{{ item.get_download_url }}</pubDate>
|
||||
<!-- Insert episode length. -->
|
||||
<itunes:duration></itunes:duration>
|
||||
<itunes:keywords>deep, house, music</itunes:keywords>
|
||||
</item>
|
||||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
||||
Reference in New Issue
Block a user