Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jannik Hellenkamp
website
Commits
25900280
Unverified
Commit
25900280
authored
6 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
clean up comments in sorter
parent
edfacd0a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sorter.py
+7
-7
7 additions, 7 deletions
sorter.py
with
7 additions
and
7 deletions
sorter.py
+
7
−
7
View file @
25900280
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment