From af671dc779d5198c0c8e399642daed033ea3406b Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 19 Aug 2011 18:54:42 +0200 Subject: [PATCH] stream processing --- pandora/archive/tasks.py | 9 +++++++++ pandora/archive/views.py | 4 ++-- pandora/item/models.py | 2 +- pandora/item/tasks.py | 16 +++------------- pandora/padma.json | 2 +- update.sh | 1 + 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pandora/archive/tasks.py b/pandora/archive/tasks.py index 341dd1565..67259873e 100644 --- a/pandora/archive/tasks.py +++ b/pandora/archive/tasks.py @@ -89,3 +89,12 @@ def update_files(user, volume, files): #FIXME: can this have any bad consequences? i.e. on the selction of used item files. models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files).delete() +@task(queue="encoding") +def process_stream(fileId): + file = models.Stream.objects.get(id=fileId) + streams = file.streams.filter(source=None) + if streams.count() >0: + stream = streams[0] + stream.make_timeline() + stream.extract_derivatives() + return True diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 1532ec8f1..ce202ab59 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -191,7 +191,7 @@ def firefogg_upload(request): f.save() #FIXME: this fails badly if rabbitmq goes down try: - t = item.tasks.update_streams.delay(f.item.itemId) + t = tasks.process_stream.delay(f.id) response['resultUrl'] = t.task_id except: pass @@ -270,7 +270,7 @@ def moveFiles(request): else: c.rendered = False c.save() - item.tasks.update_streams.delay(itemId) + item.tasks.update_timeline.delay(itemId) response = json_response(text='updated') response['data']['itemId'] = i.itemId return render_to_json_response(response) diff --git a/pandora/item/models.py b/pandora/item/models.py index 375afbdb0..73dfba2be 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -791,7 +791,7 @@ class Item(models.Model): def streams(self): return [video.streams.filter(source=None)[0] for video in self.main_videos()] - def update_streams(self, force=False): + def update_timeline(self, force=False): streams = self.streams() self.make_timeline() self.data['cuts'] = extract.cuts(self.timeline_prefix) diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index 8ade9700c..06a47d332 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -25,20 +25,10 @@ def update_external(itemId): item = models.Item.objects.get(itemId=itemId) item.update_external() - -@task(queue="encoding") -def update_streams(itemId): - ''' - create stream, extract timeline and create derivatives - ''' +@task(queue="default") +def update_timeline(itemId): item = models.Item.objects.get(itemId=itemId) - videos = item.main_videos() - for video in videos: - for f in video.streams.filter(source=None): - f.extract_derivatives() - #if item.files.filter(is_main=True, is_video=True, available=False).count() == 0: - # item.update_streams() - return True + item.update_timeline() def load_subtitles(itemId): item = models.Item.objects.get(itemId=itemId) diff --git a/pandora/padma.json b/pandora/padma.json index 165890ccc..4d19c792e 100644 --- a/pandora/padma.json +++ b/pandora/padma.json @@ -305,7 +305,7 @@ {"id": "player", "title": "Player"}, {"id": "timeline", "title": "Timeline"}, {"id": "map", "title": "Map"}, - {"id": "calendar", "title": "Calendar"}, + {"id": "calendar", "title": "Calendar"} ], "layers": [ { diff --git a/update.sh b/update.sh index 32a7c0a95..56d21ec34 100755 --- a/update.sh +++ b/update.sh @@ -3,5 +3,6 @@ base=`pwd` bzr pull http://code.0x2620.org/pandora/ cd static/oxjs bzr pull http://code.0x2620.org/oxjs/ +./tools/build/build.py cd $base test -e src/python-ox && cd src/python-ox && bzr pull http://code.0x2620.org/python-ox/