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
080cdbc5
Commit
080cdbc5
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
extended sorter to work with old folder strukture
parent
1adfa144
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
config.py.example
+1
-1
1 addition, 1 deletion
config.py.example
sorter.py
+101
-90
101 additions, 90 deletions
sorter.py
with
102 additions
and
91 deletions
config.py.example
+
1
−
1
View file @
080cdbc5
# Defaults for development ,do not use in production!
# Defaults for development ,do not use in production!
DEBUG = False
DEBUG = False
VIDEOPREFIX = 'https://videoag.fsmpi.rwth-aachen.de'
VIDEOPREFIX = 'https://videoag.fsmpi.rwth-aachen.de'
VIDEOMOUNT = 'files/
'
VIDEOMOUNT =
[
'files/
protected/','files/pub/','files/vpnonline/']
#SECRET_KEY = 'something random'
#SECRET_KEY = 'something random'
DB_SCHEMA = 'db_schema.sql'
DB_SCHEMA = 'db_schema.sql'
...
...
This diff is collapsed.
Click to expand it.
sorter.py
+
101
−
90
View file @
080cdbc5
...
@@ -19,22 +19,32 @@ def sort_log():
...
@@ -19,22 +19,32 @@ def sort_log():
'''
))
'''
))
@app.route
(
'
/sort/now
'
)
@app.route
(
'
/sort/now
'
)
@sched_func
(
60
)
@mod_required
@mod_required
def
sort_now
():
def
sort_now
():
return
sort_wraper
()
@sched_func
(
60
)
def
sort_auto
():
pass
# return sort_wraper()
def
sort_wraper
():
courses
=
query
(
'
SELECT * FROM courses
'
)
courses
=
query
(
'
SELECT * FROM courses
'
)
formats
=
query
(
'
SELECT * FROM formats ORDER BY prio
'
)
formats
=
query
(
'
SELECT * FROM formats ORDER BY prio
'
)
for
c
in
courses
:
for
c
in
courses
:
for
basepath
in
config
[
'
VIDEOMOUNT
'
]:
existingvideos
=
query
(
'
SELECT videos.path FROM videos JOIN lectures ON (videos.lecture_id = lectures.id) WHERE lectures.course_id = ?
'
,
c
[
'
id
'
])
existingvideos
=
query
(
'
SELECT videos.path FROM videos JOIN lectures ON (videos.lecture_id = lectures.id) WHERE lectures.course_id = ?
'
,
c
[
'
id
'
])
lectures
=
query
(
'
SELECT * from lectures where course_id = ?
'
,
c
[
'
id
'
])
lectures
=
query
(
'
SELECT * from lectures where course_id = ?
'
,
c
[
'
id
'
])
coursepath
=
config
[
'
VIDEOMOUNT
'
]
+
c
[
'
handle
'
]
coursepath
=
basepath
+
c
[
'
handle
'
]
try
:
try
:
files
=
os
.
listdir
(
coursepath
)
files
=
os
.
listdir
(
coursepath
)
except
FileNotFoundError
:
except
FileNotFoundError
:
files
=
[]
files
=
[]
for
f
in
files
:
for
f
in
files
:
try
:
# if the video is in the table "videos" already, skip it
# if the video is in the table "videos" already, skip it
exists
=
False
exists
=
False
for
e
in
existingvideos
:
for
e
in
existingvideos
:
...
@@ -45,7 +55,6 @@ def sort_now():
...
@@ -45,7 +55,6 @@ def sort_now():
break
break
if
exists
:
if
exists
:
continue
continue
filepath
=
coursepath
+
'
/
'
+
f
filepath
=
coursepath
+
'
/
'
+
f
# filenames: <handle>-<sorter>-<format>.mp4
# filenames: <handle>-<sorter>-<format>.mp4
# sorter musst be found with fuzzy matching. musst be one or more of the following: (inside the loop)
# sorter musst be found with fuzzy matching. musst be one or more of the following: (inside the loop)
...
@@ -109,7 +118,7 @@ def sort_now():
...
@@ -109,7 +118,7 @@ def sort_now():
if
not
'
format
'
in
data
:
if
not
'
format
'
in
data
:
data
[
'
format
'
]
=
0
data
[
'
format
'
]
=
0
modify
(
'
BEGIN
'
)
modify
(
'
BEGIN
'
)
video_id
=
modify
(
'
INSERT INTO videos_data (lecture_id,visible,path,video_format,title,comment,internal,file_modified,time_created,time_updated,created_by,hash,file_size) VALUES (?,0,?,?,
""
,
""
,
""
,?,?,?,?,
""
,?)
'
,
matches
[
0
][
'
id
'
],
c
[
'
handle
'
]
+
'
/
'
+
f
,
data
[
'
format
'
],
datetime
.
now
(),
datetime
.
now
(),
datetime
.
now
(),
session
[
'
user
'
][
'
givenName
'
]
,
os
.
stat
(
coursepath
+
'
/
'
+
f
).
st_size
)
video_id
=
modify
(
'
INSERT INTO videos_data (lecture_id,visible,path,video_format,title,comment,internal,file_modified,time_created,time_updated,created_by,hash,file_size) VALUES (?,0,?,?,
""
,
""
,
""
,?,?,?,?,
""
,?)
'
,
matches
[
0
][
'
id
'
],
c
[
'
handle
'
]
+
'
/
'
+
f
,
data
[
'
format
'
],
datetime
.
now
(),
datetime
.
now
(),
datetime
.
now
(),
-
1
,
os
.
stat
(
coursepath
+
'
/
'
+
f
).
st_size
)
query
(
'
INSERT INTO sortlog (lecture_id,video_id,path,`when`) VALUES (?,?,?,?)
'
,
matches
[
0
][
'
id
'
],
video_id
,
c
[
'
handle
'
]
+
'
/
'
+
f
,
datetime
.
now
())
query
(
'
INSERT INTO sortlog (lecture_id,video_id,path,`when`) VALUES (?,?,?,?)
'
,
matches
[
0
][
'
id
'
],
video_id
,
c
[
'
handle
'
]
+
'
/
'
+
f
,
datetime
.
now
())
modify
(
'
COMMIT
'
)
modify
(
'
COMMIT
'
)
# for debuging only
# for debuging only
...
@@ -118,6 +127,8 @@ def sort_now():
...
@@ -118,6 +127,8 @@ def sort_now():
# for m in matches:
# for m in matches:
# d.append(m['id'])
# d.append(m['id'])
# print('failed',{"data":data,"path":f,"results":d})
# print('failed',{"data":data,"path":f,"results":d})
except
Exception
:
pass
if
'
ref
'
in
request
.
values
:
if
'
ref
'
in
request
.
values
:
...
...
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