Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
7e19a60f
Commit
7e19a60f
authored
Oct 14, 2017
by
Julian Rother
Browse files
Implemented legacy stream handler, closes
#253
parent
f9a8cd41
Changes
1
Hide whitespace changes
Inline
Side-by-side
livestreams.py
View file @
7e19a60f
...
...
@@ -7,3 +7,37 @@ def livestream_thumbnail():
for
v
in
genlive
(
livestreams
):
sorter
.
schedule_thumbnail
(
v
[
'lecture_id'
],
v
[
'path'
])
@
app
.
route
(
'/internal/streaming/legacy_auth'
,
methods
=
[
'GET'
,
'POST'
])
def
streamauth
():
internal
=
False
for
net
in
config
.
get
(
'FSMPI_IP_RANGES'
,
[]):
if
ip_address
(
request
.
headers
[
'X-Real-IP'
])
in
ip_network
(
net
):
internal
=
True
if
request
.
values
[
'app'
]
!=
'live'
:
return
'Bad request'
,
400
if
not
internal
:
return
'Forbidden'
,
403
if
request
.
values
[
'pass'
]
!=
'caisoh8aht0wuSu'
:
return
'Forbidden'
,
403
if
request
.
values
[
'call'
]
==
'publish'
:
matches
=
query
(
"SELECT lectures.* FROM lectures JOIN courses ON lectures.course_id = courses.id WHERE courses.handle = ? ORDER BY lectures.time DESC"
,
request
.
values
[
'name'
])
now
=
datetime
.
now
()
match
=
{
'id'
:
-
1
}
for
lecture
in
matches
:
if
lecture
[
'time'
]
-
timedelta
(
minutes
=
30
)
<=
now
and
\
now
<=
lecture
[
'time'
]
+
timedelta
(
minutes
=
lecture
[
'duration'
]):
match
=
lecture
break
if
'lecture'
in
request
.
values
:
match
=
{
'id'
:
request
.
values
[
'lecture'
]}
try
:
modify
(
"INSERT INTO streams (handle, active, visible, lecture_id, description, poster) VALUES (?, 0, 1, -1, "", "")"
,
request
.
values
[
'name'
])
except
:
pass
modify
(
"UPDATE streams SET active = 1, lecture_id = ? WHERE handle = ?"
,
match
[
'id'
],
request
.
values
[
'name'
])
elif
request
.
values
[
'call'
]
==
'publish_done'
:
modify
(
"UPDATE streams SET active = 0 WHERE handle = ?"
,
request
.
values
[
'name'
])
else
:
return
'Bad request'
,
400
return
'OK'
,
200
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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