Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Wagtail Videos
Commits
682e73a1
Commit
682e73a1
authored
Oct 06, 2023
by
Kevin Gutierrez
Browse files
Check if video is stored locally or not before saving transcodes
parent
30f53a9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
wagtailvideos/models.py
View file @
682e73a1
...
...
@@ -255,10 +255,36 @@ class TranscodingThread(threading.Thread):
super
(
TranscodingThread
,
self
).
__init__
(
**
kwargs
)
self
.
transcode
=
transcode
def
get_file_url
(
self
,
file
):
input_file
=
None
# Check if it is a local file
try
:
input_file
=
file
.
path
except
NotImplementedError
:
input_file
=
None
if
input_file
:
return
input_file
# Check if it is a file stored with django-storages
try
:
input_file
=
file
.
url
except
NotImplementedError
:
input_file
=
None
return
input_file
def
run
(
self
):
video
=
self
.
transcode
.
video
media_format
=
self
.
transcode
.
media_format
input_file
=
video
.
file
.
path
input_file
=
self
.
get_file_url
(
video
.
file
)
if
not
input_file
:
raise
ValueError
(
"Invalid input_file value {0} for file {1}"
.
format
(
input_file
,
video
.
file
)
)
output_dir
=
tempfile
.
mkdtemp
()
transcode_name
=
"{0}.{1}"
.
format
(
video
.
filename
(
include_ext
=
False
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment