diff --git a/livestreams.py b/livestreams.py index 944917322dc7b988c9adf305fa68502807bbdffd..60028f862304533f24b15ccc04daa53555a77ce0 100644 --- a/livestreams.py +++ b/livestreams.py @@ -2,12 +2,12 @@ from server import * @sched_func(30) def livestream_thumbnail(): - livestreams = query('''SELECT streams.handle AS livehandle, streams.lecture_id, "formats" AS sep, formats.* + livestreams = query('''SELECT streams.lecture_id FROM streams JOIN lectures ON lectures.id = streams.lecture_id - JOIN formats ON formats.keywords = "hls" - WHERE streams.active AND (? OR streams.visible) - ''', ismod()) + WHERE streams.active) + ''') + for v in genlive(livestreams): - sorter.schedule_thumbnail(v['lecture_id']) + sorter.schedule_thumbnail(v['lecture_id'], v['path']) diff --git a/sorter.py b/sorter.py index 472955be7b5a981ec8ea20bd5d1c27f470be0555..c880ababdb2db21d260c610bd110ce80441d8ac1 100644 --- a/sorter.py +++ b/sorter.py @@ -35,7 +35,7 @@ def insert_video(lectureid,dbfilepath,filepath,fileformatid): query('INSERT INTO sortlog (lecture_id,video_id,path,`when`) VALUES (?,?,?,?)', lectureid, video_id, dbfilepath, datetime.now()) schedule_thumbnail(lectureid) -def schedule_thumbnail(lectureid): +def schedule_thumbnail(lectureid, filePath=None): videos = query(''' SELECT videos.path FROM videos @@ -44,6 +44,8 @@ def schedule_thumbnail(lectureid): ORDER BY formats.prio DESC''', lectureid ) if videos: path = videos[0]['path'] + elif filePath: + path = filePath else: return data = '{"lectureid": "'+str(lectureid)+'", "path": "'+path+'"}'