diff --git a/livestreams.py b/livestreams.py index 52b8f0c7fe4be15e0614eb5924bc44d104819a21..e542e24f7b740a40460d332b24e7216f099d339f 100644 --- a/livestreams.py +++ b/livestreams.py @@ -8,7 +8,7 @@ import string def livestream_thumbnail(): livestreams = query('SELECT streams.lecture_id, streams.handle AS livehandle FROM streams WHERE streams.active') 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/<server>', methods=['GET', 'POST']) @@ -113,6 +113,12 @@ def streamdrop(id): return redirect(request.values['ref']) 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']) def streamauth(server): internal = False @@ -126,6 +132,7 @@ def streamauth(server): if not sources: 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']) + live_source_thumbnail() ret = Response('Redirect', 301, {'Location': '%i'%sources[0]['id']}) ret.autocorrect_location_header = False return ret diff --git a/sorter.py b/sorter.py index e100c240cbfc21964ee88257bdfc95e0b15e51c0..c8c2f9e572c2b0025c1a01c8de61f3201a10af43 100644 --- a/sorter.py +++ b/sorter.py @@ -44,7 +44,7 @@ def schedule_thumbnail(lectureid): JOIN formats ON (videos.video_format = formats.id) WHERE videos.lecture_id = ? 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']) @mod_required diff --git a/templates/streaming.html b/templates/streaming.html index 647f92f6df5697d3c0c8d5fdcf1a7d51ee1406a8..3c65b620901c09ad9951bd0c02e39df9250fa051 100644 --- a/templates/streaming.html +++ b/templates/streaming.html @@ -19,7 +19,7 @@ {% for source in sources %} <li class="list-group-item{% if source.clientid %} list-group-item-danger{% endif %}"> <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 %} <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>