Commit 682e73a1 authored by Kevin Gutierrez's avatar Kevin Gutierrez
Browse files

Check if video is stored locally or not before saving transcodes

parent 30f53a9f
......@@ -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),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment