Commit 1fe7d8ac authored by Julian Rother's avatar Julian Rother
Browse files

Implemented RSS 2.0 podcast feeds for course videos

parent 7549403c
......@@ -40,6 +40,28 @@ def feed(handle=None):
course['updated'] = updated
return Response(render_template('feed.atom', course=course, entries=entries), 200, {'Content-Type': 'application/atom+xml'})
def rss_feed(handle):
course = query('SELECT * FROM courses WHERE handle = ? AND visible', handle)[0]
formats = query('''SELECT formats.* FROM formats
JOIN videos ON videos.video_format =
JOIN lectures ON = videos.lecture_id
WHERE lectures.course_id = ?
ORDER BY formats.player_prio DESC''', course['id'])
fmt = query('SELECT * FROM formats WHERE id = ?', request.values.get('format_id', formats[0]['id']))[0]
items = query('''SELECT lectures.*, "video" AS sep, videos.*
FROM lectures
JOIN courses ON = lectures.course_id
JOIN videos ON = videos.lecture_id
WHERE = ? AND videos.video_format = ?AND courses.visible AND lectures.visible AND videos.visible
ORDER BY videos.time_created DESC
LIMIT 100''', course['id'], fmt['id'])
chapters = query('SELECT chapters.* FROM chapters JOIN lectures ON = chapters.lecture_id WHERE lectures.course_id = ? AND NOT chapters.deleted AND chapters.visible ORDER BY time ASC', course['id'])
for item in items:
item['updated'] = max(item['video']['time_created'], item['video']['time_updated'], item['time_created'], item['time_updated'], key=fixdate)
return Response(render_template('feed.rss', course=course, format=fmt, formats=formats, items=items, chapters=chapters), 200, {'Content-Type': 'application/rss+xml; charset=UTF-8'})
def courses_feed():
courses = query('SELECT * FROM courses WHERE visible AND listed ORDER BY time_created DESC LIMIT 100')
from server import *
import subprocess
from time import mktime
from email.utils import formatdate
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
......@@ -154,6 +156,10 @@ def human_time(d):
def rfc3339(d):
return d.strftime('%Y-%m-%dT%H:%M:%S+02:00')
def rfc822(d):
return formatdate(mktime(d.timetuple()))
def get_announcements(minlevel=0):
offset = timedelta()
{% macro title(fmt) %}
{{ course.title }} ({{ fmt.description }}) — Video AG, FSMPI
{%- endmacro %}
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="" xmlns:psc="" version="2.0">
<title>{{ title(format) }}</title>
<link>{{ url_for('course', handle=course.handle, _external=True) }}</link>
<description><![CDATA[{{ course.description }}]]></description>
<generator>Website der Video AG (+</generator>
<url>{{ url_for('static', filename='logo.png', _external=True) }}</url>
<title>{{ title(format) }}</title>
<link>{{ url_for('course', handle=course.handle, _external=True) }}</link>
<atom:link rel="self" type="application/rss+xml" title="{{ title(format) }}" href="{{ url_for('rss_feed', handle=course.handle,, _external=True) }}"/>
{% for fmt in formats %}
{% if != %}
<atom:link rel="alternate" type="application/rss+xml" title="{{ title(fmt) }}" href="{{ url_for('rss_feed', handle=course.handle,, _external=True) }}"/>
{% endif %}
{% endfor %}
{% for item in items %}
<title>{{ item.title }}</title>
<link>{{ url_for('lecture',, course=course.handle, _external=True) }}</link>
<pubDate>{{ item.updated|rfc822 }}</pubDate>
<guid>{{ }}</guid>
<description><![CDATA[{{ item.comment|e }}]]></description>
<psc:chapters xmlns:psc="" version="1.2">
{% for chapter in chapters|selectattr('lecture_id','equalto', %}
<psc:chapter start="{{ chapter.time }}" title="{{ chapter.text }}"/>
{% endfor %}
<enclosure url="{{ url_for('files',, _external=True) }}" length="{{ }}" type="{{ format.mimetype }}"/>
{% endfor %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment