Unverified Commit 25900280 authored by Andreas Valder's avatar Andreas Valder
Browse files

clean up comments in sorter

parent edfacd0a
......@@ -74,6 +74,7 @@ def insert_transcoded_video(jobid, jobtype, data, state, status):
insert_video(data['lecture_id'], data['output']['path'], data['format_id'], status['hash'], status['filesize'], status['duration'], data['source_id'] )
def parseVideoFileName(splitFileName):
# filenames: <handle>-<sorter>-<format>.mp4
data = {'keywords': []}
for fileNameChunk in splitFileName:
fileNameChunk = fileNameChunk.replace('.mp4','')
......@@ -95,7 +96,6 @@ def parseVideoFileName(splitFileName):
def matchDatetimeOnLecture(lectures, date, time):
matches = []
# first try date and time (if one of them is set)
if date or time:
print(1)
for lecture in lectures:
......@@ -129,8 +129,6 @@ def matchFileNameOnFormat(splitFileName):
return 0
def sort_file(filename, course=None, lectures=None):
# filenames: <handle>-<sorter>-<format>.mp4
# "sorter" musst be found with fuzzy matching. "sorter" musst be one or more of the following types: (inside the loop)
# '_' and ' ' are handled like '-'
splitFileName = filename.replace('_','-').replace(' ','-').split('-')
if not course:
......@@ -143,16 +141,18 @@ def sort_file(filename, course=None, lectures=None):
course = courses[0]
if not lectures:
lectures = query('SELECT * from lectures where course_id = ?', course['id'])
# parse all data from the file name
data = parseVideoFileName(splitFileName)
# try to match the file on a single lecture
matches = matchDatetimeOnLecture(lectures, data.get('date'), data.get('time'))
# if we can't match exactly based on date and time, we have to match keywords
if ((len(matches) != 1) and (len(data['keywords']) > 0)):
#only test lectures with the correct date/time, if we have any. Else test for matches in all lectures of this course
if len(matches) == 0:
matches = matchKeywordsOnLecture(lectures, data['keywords'])
else:
if not len(matches) == 0:
# only test lectures with the correct date/time, if we have any
matches = matchKeywordsOnLecture(matches, data['keywords'])
else:
# Else test for matches in all lectures of this course
matches = matchKeywordsOnLecture(lectures, data['keywords'])
# now we should have found exactly one match
fmt = matchFileNameOnFormat(splitFileName)
return matches, fmt
......
Supports Markdown
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