Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Projects
Groups
Snippets
Sign up now
Login
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
63ff5434
Commit
63ff5434
authored
Sep 11, 2016
by
Andreas Valder
Browse files
added chapter display, not yet editable #22
parent
58beea4e
Changes
3
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
63ff5434
...
...
@@ -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
=
[]
...
...
templates/chapters.srt
0 → 100644
View file @
63ff5434
{% 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 %}
templates/macros.html
View file @
63ff5434
...
...
@@ -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
(
$
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment