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
Vincent Wehrwein
website
Commits
ec3fe948
Unverified
Commit
ec3fe948
authored
6 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
changed function naming
parent
7e1d089e
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
+9
-9
9 additions, 9 deletions
sorter.py
with
9 additions
and
9 deletions
sorter.py
+
9
−
9
View file @
ec3fe948
...
...
@@ -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
parse
VideoF
ile
N
ame
(
splitFileName
):
def
parse
_f
ile
_n
ame
(
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
matchDatetimeOnLectur
e
(
lectures
,
date
,
time
):
def
filter_lectures_by_datetim
e
(
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
matchF
ile
N
ame
OnFormat
(
splitFileName
):
def
filter_formats_by_f
ile
n
ame
(
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
=
parse
VideoF
ile
N
ame
(
splitFileName
)
data
=
parse
_f
ile
_n
ame
(
splitFileName
)
# try to match the file on a single lecture
matches
=
matchDatetimeOnLectur
e
(
lectures
,
data
.
get
(
'
date
'
),
data
.
get
(
'
time
'
))
matches
=
filter_lectures_by_datetim
e
(
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
=
matchF
ile
N
ame
OnFormat
(
splitFileName
)
fmt
=
filter_formats_by_f
ile
n
ame
(
splitFileName
)
return
matches
,
fmt
def
log_sort_error
(
course_id
,
path
,
matches
):
...
...
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