Skip to content
Snippets Groups Projects
Unverified Commit ec3fe948 authored by Andreas Valder's avatar Andreas Valder
Browse files

changed function naming

parent 7e1d089e
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,7 @@ def insert_transcoded_video(jobid, jobtype, data, state, status):
return
insert_video(data['lecture_id'], data['output']['path'], data['format_id'], status['hash'], status['filesize'], status['duration'], data['source_id'] )
def parseVideoFileName(splitFileName):
def parse_file_name(splitFileName):
# filenames: <handle>-<sorter>-<format>.mp4
data = {'keywords': []}
for fileNameChunk in splitFileName:
......@@ -94,7 +94,7 @@ def parseVideoFileName(splitFileName):
data['keywords'].append(fileNameChunk)
return data
def matchDatetimeOnLecture(lectures, date, time):
def filter_lectures_by_datetime(lectures, date, time):
matches = []
if date or time:
for lecture in lectures:
......@@ -107,7 +107,7 @@ def matchDatetimeOnLecture(lectures, date, time):
matches.append(lecture)
return matches
def matchKeywordsOnLecture(lectures, keywords):
def filter_lectures_by_keywords(lectures, keywords):
for field in ['title','speaker','comment','internal']:
for lecture in lectures:
for keyword in keywords:
......@@ -117,7 +117,7 @@ def matchKeywordsOnLecture(lectures, keywords):
return [lecture]
return []
def matchFileNameOnFormat(splitFileName):
def filter_formats_by_filename(splitFileName):
# default format is "unknown", with id 0
formats = query('SELECT * FROM formats ORDER BY prio DESC')
for videoformat in formats:
......@@ -141,19 +141,19 @@ def sort_file(filename, course=None, lectures=None):
if not lectures:
lectures = query('SELECT * from lectures where course_id = ?', course['id'])
# parse all data from the file name
data = parseVideoFileName(splitFileName)
data = parse_file_name(splitFileName)
# try to match the file on a single lecture
matches = matchDatetimeOnLecture(lectures, data.get('date'), data.get('time'))
matches = filter_lectures_by_datetime(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)):
if not len(matches) == 0:
# only test lectures with the correct date/time, if we have any
matches = matchKeywordsOnLecture(matches, data['keywords'])
matches = filter_lectures_by_keywords(matches, data['keywords'])
else:
# Else test for matches in all lectures of this course
matches = matchKeywordsOnLecture(lectures, data['keywords'])
matches = filter_lectures_by_keywords(lectures, data['keywords'])
# now we should have found exactly one match
fmt = matchFileNameOnFormat(splitFileName)
fmt = filter_formats_by_filename(splitFileName)
return matches, fmt
def log_sort_error(course_id, path, matches):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment