Skip to content
Snippets Groups Projects
Commit fccadfa4 authored by Julian Rother's avatar Julian Rother
Browse files

Fixed RSS feed handling of empty courses

parent 9d00ede5
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ def fixdate(d):
@app.route('/feed')
@app.route('/<handle>/feed')
@handle_errors(None, 'Diese Veranstaltung existiert nicht!', 400, IndexError)
@handle_errors(None, 'Diese Veranstaltung existiert nicht!', 404, IndexError)
def feed(handle=None):
id = None
course = {'id': None, 'title': 'Neueste Videos', 'time_created': None, 'time_updated': None}
......@@ -41,6 +41,7 @@ def feed(handle=None):
return Response(render_template('feed.atom', course=course, entries=entries), 200, {'Content-Type': 'application/atom+xml'})
@app.route('/<handle>/rss')
@handle_errors(None, 'Die Veranstaltung oder das Format existiert nicht!', 404, IndexError)
def rss_feed(handle):
course = query('SELECT * FROM courses WHERE handle = ? AND visible', handle)[0]
formats = query('''SELECT formats.* FROM formats
......@@ -49,13 +50,17 @@ def rss_feed(handle):
WHERE lectures.course_id = ?
GROUP BY formats.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]
if not formats:
formats = query('SELECT * FROM formats WHERE id = 4 OR id = 5 OR id = 10') # 360p, 720p, 1080p
if 'format_id' not in request.values:
return redirect(url_for('rss_feed', handle=handle, format_id=formats[0]['id']))
fmt = query('SELECT * FROM formats WHERE id = ?', request.values.get('format_id', request.values['format_id']))[0]
items = query('''SELECT lectures.*, "video" AS sep, videos.*
FROM lectures
JOIN courses ON courses.id = lectures.course_id
JOIN videos ON lectures.id = videos.lecture_id
WHERE courses.id = ? AND videos.video_format = ? AND courses.visible AND lectures.visible AND videos.visible
ORDER BY videos.time_created DESC
ORDER BY lectures.time DESC
LIMIT 100''', course['id'], fmt['id'])
chapters = query('SELECT chapters.* FROM chapters JOIN lectures ON lectures.id = chapters.lecture_id WHERE lectures.course_id = ? AND NOT chapters.deleted AND chapters.visible ORDER BY time ASC', course['id'])
for item in items:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment