forked from 0x2620/pandora
add task functions to File
This commit is contained in:
parent
3f4b1b3d63
commit
7dde9eb8ae
2 changed files with 10 additions and 4 deletions
|
@ -20,7 +20,6 @@ from person.models import get_name_sort
|
||||||
|
|
||||||
import extract
|
import extract
|
||||||
|
|
||||||
|
|
||||||
class File(models.Model):
|
class File(models.Model):
|
||||||
AV_INFO = (
|
AV_INFO = (
|
||||||
'duration', 'video', 'audio', 'oshash', 'size',
|
'duration', 'video', 'audio', 'oshash', 'size',
|
||||||
|
@ -139,7 +138,6 @@ class File(models.Model):
|
||||||
if self.framerate:
|
if self.framerate:
|
||||||
self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration)
|
self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration)
|
||||||
|
|
||||||
|
|
||||||
def get_path_info(self):
|
def get_path_info(self):
|
||||||
data = {}
|
data = {}
|
||||||
for key in self.PATH_INFO:
|
for key in self.PATH_INFO:
|
||||||
|
@ -389,6 +387,14 @@ class File(models.Model):
|
||||||
def all_paths(self):
|
def all_paths(self):
|
||||||
return [self.path] + [i.path for i in self.instances.all()]
|
return [self.path] + [i.path for i in self.instances.all()]
|
||||||
|
|
||||||
|
def extract_stream(self):
|
||||||
|
import tasks
|
||||||
|
return tasks.extract_stream.delay(self.id)
|
||||||
|
|
||||||
|
def process_stream(self):
|
||||||
|
import tasks
|
||||||
|
return tasks.process_stream.delay(self.id)
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
self.delete_files()
|
self.delete_files()
|
||||||
super(File, self).delete(*args, **kwargs)
|
super(File, self).delete(*args, **kwargs)
|
||||||
|
|
|
@ -247,7 +247,7 @@ def firefogg_upload(request):
|
||||||
f.save()
|
f.save()
|
||||||
#FIXME: this fails badly if rabbitmq goes down
|
#FIXME: this fails badly if rabbitmq goes down
|
||||||
try:
|
try:
|
||||||
t = tasks.process_stream.delay(f.id)
|
t = f.process_stream()
|
||||||
response['resultUrl'] = t.task_id
|
response['resultUrl'] = t.task_id
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -300,7 +300,7 @@ def direct_upload(request):
|
||||||
file.save()
|
file.save()
|
||||||
#try/execpt so it does not fail if rabitmq is down
|
#try/execpt so it does not fail if rabitmq is down
|
||||||
try:
|
try:
|
||||||
t = tasks.extract_stream.delay(file.id)
|
t = file.extract_stream()
|
||||||
response['resultUrl'] = t.task_id
|
response['resultUrl'] = t.task_id
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue