diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 3ad0cdcc..9185d612 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -20,7 +20,6 @@ from person.models import get_name_sort import extract - class File(models.Model): AV_INFO = ( 'duration', 'video', 'audio', 'oshash', 'size', @@ -139,7 +138,6 @@ class File(models.Model): if self.framerate: self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration) - def get_path_info(self): data = {} for key in self.PATH_INFO: @@ -388,7 +386,15 @@ class File(models.Model): def all_paths(self): 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): self.delete_files() super(File, self).delete(*args, **kwargs) diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 9c62aff0..e3a795c5 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -247,7 +247,7 @@ def firefogg_upload(request): f.save() #FIXME: this fails badly if rabbitmq goes down try: - t = tasks.process_stream.delay(f.id) + t = f.process_stream() response['resultUrl'] = t.task_id except: pass @@ -300,7 +300,7 @@ def direct_upload(request): file.save() #try/execpt so it does not fail if rabitmq is down try: - t = tasks.extract_stream.delay(file.id) + t = file.extract_stream() response['resultUrl'] = t.task_id except: pass