diff --git a/pandora/item/management/commands/rebuild_timelines.py b/pandora/item/management/commands/rebuild_timelines.py index 69f0a3efc..46b3500f1 100644 --- a/pandora/item/management/commands/rebuild_timelines.py +++ b/pandora/item/management/commands/rebuild_timelines.py @@ -4,13 +4,14 @@ import os from os.path import join, dirname, basename, splitext, exists import time +from glob import glob from django.core.management.base import BaseCommand, CommandError from django.conf import settings import monkey_patch.models from ... import models - +from ... import tasks class Command(BaseCommand): """ @@ -21,14 +22,12 @@ class Command(BaseCommand): def handle(self, **options): offset = 0 - chunk = 50 + chunk = 100 count = pos = models.Item.objects.count() while offset <= count: for i in models.Item.objects.all().order_by('id')[offset:offset+chunk]: - print pos, i.itemId - for s in i.streams(): - s.make_timeline() - i.update_timeline() - pos -= 1 + if not os.path.exists(os.path.join(i.timeline_prefix, 'cuts.json')) or \ + not glob('%s/timelinekeyframes16p0.jpg'%i.timeline_prefix): + print i.itemId + tasks.rebuild_timeline.delay(i.itemId) offset += chunk - time.sleep(30) #keep load down diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index df50eef2e..1cd5ca119 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -64,6 +64,13 @@ def update_timeline(itemId): item = models.Item.objects.get(itemId=itemId) item.update_timeline() +@task(queue="encoding") +def rebuild_timeline(itemId): + i = models.Item.objects.get(itemId=itemId) + for s in i.streams(): + s.make_timeline() + i.update_timeline() + @task(queue="encoding") def load_subtitles(itemId): item = models.Item.objects.get(itemId=itemId) diff --git a/pandora/item/timelines.py b/pandora/item/timelines.py index 5346c5982..014ecb509 100644 --- a/pandora/item/timelines.py +++ b/pandora/item/timelines.py @@ -82,7 +82,7 @@ def join_tiles(source_paths, target_path): target_path, small_mode, small_tile_h, small_tile_i ) data['target_images']['small'].save(image_file) - print image_file + #print image_file if mode == 'antialias': # render full tile resized = data['target_images']['large'].resize((