Commit a357d26c authored by Julian Rother's avatar Julian Rother
Browse files

Added live_source thumbnails and changed thumbnail job parameters

parent 92732788
...@@ -8,7 +8,7 @@ import string ...@@ -8,7 +8,7 @@ import string
def livestream_thumbnail(): def livestream_thumbnail():
livestreams = query('SELECT streams.lecture_id, streams.handle AS livehandle FROM streams WHERE streams.active') livestreams = query('SELECT streams.lecture_id, streams.handle AS livehandle FROM streams WHERE streams.active')
for v in genlive(livestreams): for v in genlive(livestreams):
schedule_job('thumbnail', {'lectureid': str(v['lecture_id']), 'path': v['path']}) schedule_job('thumbnail', {'src': v['path'], 'filename': 'l_%i.jpg'%lecture['id']})
@app.route('/internal/streaming/legacy_auth', methods=['GET', 'POST']) @app.route('/internal/streaming/legacy_auth', methods=['GET', 'POST'])
@app.route('/internal/streaming/legacy_auth/<server>', methods=['GET', 'POST']) @app.route('/internal/streaming/legacy_auth/<server>', methods=['GET', 'POST'])
...@@ -113,6 +113,12 @@ def streamdrop(id): ...@@ -113,6 +113,12 @@ def streamdrop(id):
return redirect(request.values['ref']) return redirect(request.values['ref'])
return 'Ok', 200 return 'Ok', 200
@sched_func(120)
def live_source_thumbnail():
sources = query('SELECT * FROM live_sources WHERE clientid IS NOT NULL')
for source in sources:
schedule_job('thumbnail', {'src': 'rtmp://%s/src/%i'%(source['server'], source['id']), 'filename': 's_%i.jpg'%source['id']})
@app.route('/internal/streaming/auth/<server>', methods=['GET', 'POST']) @app.route('/internal/streaming/auth/<server>', methods=['GET', 'POST'])
def streamauth(server): def streamauth(server):
internal = False internal = False
...@@ -126,6 +132,7 @@ def streamauth(server): ...@@ -126,6 +132,7 @@ def streamauth(server):
if not sources: if not sources:
return 'Not found', 404 return 'Not found', 404
modify('UPDATE live_sources SET server = ?, server_public = ?, clientid = ?, last_active = ?, preview_key = ? WHERE id = ?', server, request.args.get('public_ip', server), request.values['clientid'], datetime.now(), gentoken(), sources[0]['id']) modify('UPDATE live_sources SET server = ?, server_public = ?, clientid = ?, last_active = ?, preview_key = ? WHERE id = ?', server, request.args.get('public_ip', server), request.values['clientid'], datetime.now(), gentoken(), sources[0]['id'])
live_source_thumbnail()
ret = Response('Redirect', 301, {'Location': '%i'%sources[0]['id']}) ret = Response('Redirect', 301, {'Location': '%i'%sources[0]['id']})
ret.autocorrect_location_header = False ret.autocorrect_location_header = False
return ret return ret
......
...@@ -44,7 +44,7 @@ def schedule_thumbnail(lectureid): ...@@ -44,7 +44,7 @@ def schedule_thumbnail(lectureid):
JOIN formats ON (videos.video_format = formats.id) JOIN formats ON (videos.video_format = formats.id)
WHERE videos.lecture_id = ? WHERE videos.lecture_id = ?
ORDER BY formats.prio DESC''', lectureid) ORDER BY formats.prio DESC''', lectureid)
return schedule_job('thumbnail', {'lectureid': str(lectureid), 'path': videos[0]['path']}) return schedule_job('thumbnail', {'src': videos[0]['path'], 'filename': 'l_%i.jpg'%lectureid})
@app.route('/internal/jobs/add/thumbnail', methods=['GET', 'POST']) @app.route('/internal/jobs/add/thumbnail', methods=['GET', 'POST'])
@mod_required @mod_required
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{% for source in sources %} {% for source in sources %}
<li class="list-group-item{% if source.clientid %} list-group-item-danger{% endif %}"> <li class="list-group-item{% if source.clientid %} list-group-item-danger{% endif %}">
<div class="row"> <div class="row">
<div style="background-image: url('{{ config.VIDEOPREFIX }}/hls/preview/{{ source.id }}.jpg')" class="col-sm-2 col-xs-12 thumbnailimg"> <div style="background-image: url('{{ config.VIDEOPREFIX }}/thumbnail/s_{{ source.id }}.jpg')" class="col-sm-2 col-xs-12 thumbnailimg">
{% if source.clientid %} {% if source.clientid %}
<a href="#" data-toggle="modal" data-target="#preview-player" data-srcname="{{ source.name }}" data-srcid="{{ source.id }}"> <a href="#" data-toggle="modal" data-target="#preview-player" data-srcname="{{ source.name }}" data-srcid="{{ source.id }}">
<span class="glyphicon glyphicon-play-circle playpreviewbtn"></span> <span class="glyphicon glyphicon-play-circle playpreviewbtn"></span>
......
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