From fea06642c7dea4ec1d452ec449901fecb8b37f45 Mon Sep 17 00:00:00 2001
From: Julian Rother <julianr@fsmpi.rwth-aachen.de>
Date: Wed, 13 Dec 2017 17:57:13 +0100
Subject: [PATCH] Implemented autovisible

---
 sorter.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sorter.py b/sorter.py
index 4499533..22f4efc 100644
--- a/sorter.py
+++ b/sorter.py
@@ -39,11 +39,12 @@ def update_video_metadata(jobid, jobtype, data, state, status):
 			status['hash'], status['filesize'], data['video_id'])
 
 def insert_video(lectureid, dbfilepath, fileformatid, hash="", filesize=-1):
+	visible = query('SELECT courses.autovisible FROM courses JOIN lectures ON lectures.course_id = courses.id WHERE lectures.id = ?', lectureid)[0]['autovisible']
 	video_id = modify('''INSERT INTO videos_data 
 		(lecture_id, visible, path, video_format, title, comment, internal, file_modified, time_created, time_updated, created_by, hash, file_size)
 		VALUES 
-		(?, 0, ?, ?, "", "", "", ?, ?, ?, ?, ?, ?)''',
-		lectureid, dbfilepath, fileformatid, datetime.now(), datetime.now(), datetime.now(), -1, hash, filesize)
+		(?, ?, ?, ?, "", "", "", ?, ?, ?, ?, ?, ?)''',
+		lectureid, autovisible, dbfilepath, fileformatid, datetime.now(), datetime.now(), datetime.now(), -1, hash, filesize)
 	query('INSERT INTO sortlog (lecture_id,video_id,path,`when`) VALUES (?,?,?,?)', lectureid, video_id, dbfilepath, datetime.now())
 	schedule_thumbnail(lectureid)
 	schedule_job('probe', {'path': dbfilepath, 'lecture_id': lectureid, 'video_id': video_id, 'import-chapters': True})
@@ -70,11 +71,12 @@ def insert_transcoded_video(jobid, jobtype, data, state, status):
 		return
 	if 'video_id' in data:
 		return
+	visible = query('SELECT courses.autovisible FROM courses JOIN lectures ON lectures.course_id = courses.id WHERE lectures.id = ?', data['lecture_id'])[0]['autovisible']
 	video_id = modify('''INSERT INTO videos_data 
 		(lecture_id, visible, path, video_format, title, comment, internal, file_modified, time_created, time_updated, created_by, hash, file_size, source)
 		VALUES 
-		(?, 0, ?, ?, "", "", "", ?, ?, ?, ?, ?, ?, ?)''',
-		data['lecture_id'], data['output']['path'], data['format_id'],
+		(?, ?, ?, ?, "", "", "", ?, ?, ?, ?, ?, ?, ?)''',
+		data['lecture_id'], visible, data['output']['path'], data['format_id'],
 		datetime.now(), datetime.now(), datetime.now(), -1, status['hash'],
 		status['filesize'], data['source_id'])
 	schedule_thumbnail(data['lecture_id'])
-- 
GitLab