Commit b4c40af6 authored by Andreas Valder's avatar Andreas Valder
Browse files

Merge branch 'master' of git.fsmpi.rwth-aachen.de:videoagwebsite/videoagwebsite

parents f6616863 56861916
......@@ -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
......@@ -379,7 +379,7 @@ def index():
item['courses'] = query('SELECT * FROM courses WHERE (visible AND listed) AND `%s` = ? ORDER BY `%s`'%(item['param'], item['param']), item['param2'])
elif item['type'] == 'video':
item['lecture'] = {'id': item['param']}
livestreams = query('''SELECT streams.handle AS livehandle, streams.lecture_id, "formats" AS sep, formats.*
streams = query('''SELECT streams.handle AS livehandle, streams.lecture_id, "formats" AS sep, formats.*
FROM streams
JOIN lectures ON lectures.id = streams.lecture_id
JOIN formats ON formats.keywords = "hls"
......@@ -391,7 +391,7 @@ def index():
JOIN formats ON (videos.video_format = formats.id)
WHERE videos.lecture_id = ? AND videos.visible
ORDER BY formats.prio DESC
''', item['param'])+genlive(livestreams)
''', item['param'])+genlive(streams)
return render_template('index.html', latestvideos=livestreams+latestvideos, upcomming=upcomming, featured=featured)
@app.route('/courses')
......
......@@ -404,7 +404,7 @@ $('#embedcodebtn').popover(
{% endfor %}
</ul>
</div></li>
<li>{{ moderator_editor(('featured',item.id,'param2'), item.param2) }}</li>
<li>{{ moderator_editor(('featured',item.id,'param2'), item.param2, reload=True) }}</li>
</ul>
{% endif %}
Die vollständige Liste findest du <a href="{{ url_for('courses') }}">hier</a>.
......@@ -416,7 +416,7 @@ $('#embedcodebtn').popover(
{{ player(item.lecture, item.videos, autoplay=False)}}
{% endif %}
{% if ismod() %}
<div>ID des Videos: {{ moderator_editor(('featured',item.id,'param'), item.param) }}</div>
<div>ID des Videos: {{ moderator_editor(('featured',item.id,'param'), item.param, reload=True) }}</div>
{% endif %}
<div>{{ moderator_editor(('featured',item.id,'param2'), item.param2) }}</div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment