Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Video AG Infrastruktur
website
Commits
eb05ba41
Commit
eb05ba41
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
moved chapters to own file
parent
efed38e6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
chapters.py
+34
-0
34 additions, 0 deletions
chapters.py
server.py
+1
-33
1 addition, 33 deletions
server.py
with
35 additions
and
33 deletions
chapters.py
0 → 100644
+
34
−
0
View file @
eb05ba41
from
server
import
*
@app.route
(
'
/internal/newchapter/<int:lectureid>
'
,
methods
=
[
'
POST
'
,
'
GET
'
])
def
suggest_chapter
(
lectureid
):
time
=
request
.
values
[
'
time
'
]
text
=
request
.
values
[
'
text
'
]
assert
(
time
and
text
)
try
:
x
=
datetime
.
strptime
(
time
,
'
%H:%M:%S
'
)
time
=
timedelta
(
hours
=
x
.
hour
,
minutes
=
x
.
minute
,
seconds
=
x
.
second
).
total_seconds
()
time
=
int
(
time
)
except
ValueError
:
flash
(
'
Falsches Zeitformat,
"
%H:%M:%S
"
wird erwartet. Z.B.
"
01:39:42
"
für eine Kapitel bei Stunde 1, Minute 39, Sekunde 42
'
)
submitter
=
None
if
not
ismod
():
submitter
=
request
.
environ
[
'
REMOTE_ADDR
'
]
id
=
modify
(
'
INSERT INTO chapters (lecture_id, time, text, time_created, time_updated, created_by, submitted_by) VALUES (?, ?, ?, ?, ?, ?, ?)
'
,
lectureid
,
time
,
text
,
datetime
.
now
(),
datetime
.
now
(),
session
.
get
(
'
user
'
,
{
'
dbid
'
:
None
})[
'
dbid
'
],
submitter
)
if
'
ref
'
in
request
.
values
:
return
redirect
(
request
.
values
[
'
ref
'
])
return
'
OK
'
,
200
@app.route
(
'
/internal/chapters/<int:lectureid>
'
)
def
chapters
(
lectureid
):
chapters
=
query
(
"
SELECT * FROM chapters WHERE lecture_id = ? AND NOT deleted AND (visible OR ?) ORDER BY time DESC
"
,
lectureid
,
ismod
())
if
not
chapters
:
return
'
No chapters found
'
,
404
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
'
})
This diff is collapsed.
Click to expand it.
server.py
+
1
−
33
View file @
eb05ba41
...
...
@@ -578,39 +578,6 @@ def changelog():
def
files
(
filename
):
return
redirect
(
config
[
'
VIDEOPREFIX
'
]
+
'
/
'
+
filename
)
@app.route
(
'
/internal/newchapter/<int:lectureid>
'
,
methods
=
[
'
POST
'
,
'
GET
'
])
def
suggest_chapter
(
lectureid
):
time
=
request
.
values
[
'
time
'
]
text
=
request
.
values
[
'
text
'
]
assert
(
time
and
text
)
try
:
x
=
datetime
.
strptime
(
time
,
'
%H:%M:%S
'
)
time
=
timedelta
(
hours
=
x
.
hour
,
minutes
=
x
.
minute
,
seconds
=
x
.
second
).
total_seconds
()
time
=
int
(
time
)
except
ValueError
:
flash
(
'
Falsches Zeitformat,
"
%H:%M:%S
"
wird erwartet. Z.B.
"
01:39:42
"
für eine Kapitel bei Stunde 1, Minute 39, Sekunde 42
'
)
submitter
=
None
if
not
ismod
():
submitter
=
request
.
environ
[
'
REMOTE_ADDR
'
]
id
=
modify
(
'
INSERT INTO chapters (lecture_id, time, text, time_created, time_updated, created_by, submitted_by) VALUES (?, ?, ?, ?, ?, ?, ?)
'
,
lectureid
,
time
,
text
,
datetime
.
now
(),
datetime
.
now
(),
session
.
get
(
'
user
'
,
{
'
dbid
'
:
None
})[
'
dbid
'
],
submitter
)
if
'
ref
'
in
request
.
values
:
return
redirect
(
request
.
values
[
'
ref
'
])
return
'
OK
'
,
200
@app.route
(
'
/internal/chapters/<int:lectureid>
'
)
def
chapters
(
lectureid
):
chapters
=
query
(
"
SELECT * FROM chapters WHERE lecture_id = ? AND NOT deleted AND (visible OR ?) ORDER BY time DESC
"
,
lectureid
,
ismod
())
if
not
chapters
:
return
'
No chapters found
'
,
404
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
=
[]
...
...
@@ -664,3 +631,4 @@ import l2pauth
if
'
JOBS_API_KEY
'
in
config
:
import
jobs
import
timetable
import
chapters
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment