Skip to content
Snippets Groups Projects
Commit 63ff5434 authored by Andreas Valder's avatar Andreas Valder
Browse files

added chapter display, not yet editable #22

parent 58beea4e
No related branches found
No related tags found
No related merge requests found
......@@ -396,6 +396,16 @@ def suggest_chapter(lectureid):
return redirect(request.values['ref'])
return 'OK', 200
@app.route('/chapters/<int:lectureid>')
def chapters(lectureid):
chapters = query("SELECT * FROM chapters WHERE lecture_id = ? and visible ORDER BY time DESC", lectureid)
last = None
for c in chapters:
c['start'] = c['time']
c['end'] = last['start'] if last else 9999
last = c
return Response(render_template('chapters.srt',chapters=chapters), 200, {'Content-Type':'text/vtt'})
@app.route('/sitemap.xml')
def sitemap():
pages=[]
......
{% macro vtttime(time) %}{{ '%02d:%02d:%02d.000'|format( time//3600, (time//60)%60, time%60) }}{% endmacro %}
WEBVTT
{% for c in chapters|sort(attribute='start') %}
{{ loop.index }}
{# time format is 'minutes:seconds.ms' we expect full seconds #}
{{ vtttime(c['start']) }} --> {{ vtttime(c['end']) }}
{{ c['text'] }}
{% endfor %}
......@@ -49,6 +49,7 @@
{% for v in videos|sort(attribute='player_prio', reverse=True) %}
<source type="video/mp4" src="{{ config.VIDEOPREFIX }}/{{ v.path }}" title="{{ v.format_description }}"/>
{% endfor %}
<track srclang="en" kind="chapters" src="{{ url_for('chapters',lectureid=lecture.id) }}" />
</video>
<script>
$(function($)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment