Commit 6b00abd1 authored by Julian Rother's avatar Julian Rother

Added interface to manually add remux and reencode jobs

parent 2ae7b0d7
......@@ -10,7 +10,17 @@ def set_metadata(dest, course, lecture):
dest['metadata'] = metadata
dest['chapters'] = chapters
def schedule_remux(lectureid):
@app.route('/internal/jobs/add/remux', methods=['GET', 'POST'])
@mod_required
@csrf_protect
def schedule_remux(lectureid=None, videoid=None):
ret = None
if not lectureid:
lectureid = request.values.get('lectureid')
videoid = request.values.get('videoid')
if not lectureid:
lectureid = query('SELECT lecture_id FROM videos WHERE id = ?', videoid)[0]['lecture_id']
ret = redirect(request.values.get('ref', url_for('jobs_overview')))
lecture = query('SELECT * FROM lectures WHERE id = ?', lectureid)[0]
course = query('SELECT * FROM courses WHERE id = ?', lecture['course_id'])[0]
videos = query('''SELECT videos.*, sources.path AS srcpath, sources.hash AS srchash, formats.options AS fmtopts
......@@ -21,6 +31,8 @@ def schedule_remux(lectureid):
for video in videos:
if not video['source']:
continue
if videoid and video['id'] != videoid:
continue
data = {'path': video['path'], 'srcpath': video['srcpath'], 'srchash': video['srchash']}
fmt = json.loads(video['fmtopts'])
if 'format' in fmt:
......@@ -28,6 +40,7 @@ def schedule_remux(lectureid):
data['options'] = fmt.get('options', {})
set_metadata(data, course, lecture)
schedule_job('remux', data)
return ret
def schedule_transcode(source, fmt_id=None, video=None):
if video:
......@@ -49,7 +62,7 @@ def schedule_transcode(source, fmt_id=None, video=None):
basename = os.path.basename(source['path']).rsplit('.', 1)[0]
data['output']['path'] = 'pub/'+course['handle']+'/'+basename+fmt['suffix']
if video:
old_source = query('SELECT * FROM sources WHERE id = ?', video['source'])
old_source = query('SELECT * FROM sources WHERE id = ?', video['source'])[0]
data['output']['path'] = video['path']
data['video_id'] = video['id']
data['srcpath'] = old_source['path']
......@@ -60,6 +73,19 @@ def schedule_transcode(source, fmt_id=None, video=None):
data['source_id'] = source['id']
schedule_job('transcode', data, queue="background")
@app.route('/internal/jobs/add/reencode', methods=['GET', 'POST'])
@mod_required
@csrf_protect
@handle_errors('jobs_overview', 'Video nicht gefunden!', 404, IndexError)
def schedule_reencode():
video = query('SELECT * FROM videos WHERE id = ?', request.values['videoid'])[0]
if not video['source']:
flash('Manuell erstellte Videos können nicht neukodiert werden!')
else:
source = query('''SELECT sources.* FROM sources WHERE sources.id = ? ORDER BY time_created''', video['source'])[-1]
schedule_transcode(source, video=video)
return redirect(request.values.get('ref', url_for('jobs_overview')))
@job_handler('probe-raw')
def update_lecture_videos(jobid, jobtype, data, state, status):
if 'lecture_id' not in data:
......
......@@ -51,6 +51,7 @@ def insert_video(lectureid, dbfilepath, fileformatid, hash="", filesize=-1):
@app.route('/internal/jobs/add/thumbnail', methods=['GET', 'POST'])
@mod_required
@csrf_protect
@handle_errors('jobs_overview', 'Zu dieser Veranstaltung existieren keine Videos!', 404, IndexError)
def schedule_thumbnail(lectureid=None):
ret = None
......
......@@ -12,15 +12,38 @@
</div>
<div class="modal-body">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#add_thtumbnail" aria-controls="thumbnail" role="tab" data-toggle="tab">Thumbnail</a></li>
<li role="presentation" class="active"><a href="#add_thumbnail" aria-controls="thumbnail" role="tab" data-toggle="tab">Thumbnail</a></li>
<li role="presentation"><a href="#add_remux" aria-controls="remux" role="tab" data-toggle="tab">Remux</a></li>
<li role="presentation"><a href="#add_reencode" aria-controls="remux" role="tab" data-toggle="tab">Reencode</a></li>
</ul>
<div class="tab-content" style="margin-top: 10px;">
<div role="tabpanel" class="tab-pane active" id="add_thumbnail">
<form class="form-inline" action="{{url_for('schedule_thumbnail', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Lecture ID" name="lectureid">
<button type="submit" class="btn btn-primary">Hinzufügen</button>
<button type="submit" class="btn btn-primary">Thumbnail erzeugen</button>
</div>
</form>
</div>
<div role="tabpanel" class="tab-pane" id="add_remux">
<form class="form-inline" action="{{url_for('schedule_remux', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Lecture ID" name="lectureid">
<button type="submit" class="btn btn-primary">Videos remuxen</button>
</div>
</form><br>
<form class="form-inline" action="{{url_for('schedule_remux', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Video ID" name="videoid">
<button type="submit" class="btn btn-primary">Einzelnes Video remuxen</button>
</div>
</form>
</div>
<div role="tabpanel" class="tab-pane" id="add_reencode">
<form class="form-inline" action="{{url_for('schedule_reencode', ref=request.url)}}" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Video ID" name="videoid">
<button type="submit" class="btn btn-primary">Video neukodieren</button>
</div>
</form>
</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