forked from 0x2620/pandora
fix import script
This commit is contained in:
parent
3417eb9281
commit
4c1dc2afe2
2 changed files with 27 additions and 26 deletions
|
@ -3,33 +3,11 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
import os
|
||||
from glob import glob
|
||||
|
||||
from celery.task import task
|
||||
import monkey_patch.models
|
||||
from ... import models
|
||||
from ...tasks import update_stream
|
||||
|
||||
from ... import models, extract
|
||||
|
||||
|
||||
@task(queue="encoding")
|
||||
def update_stream(id):
|
||||
s = models.Stream.objects.get(pk=id)
|
||||
if not glob("%s*"%s.timeline_prefix):
|
||||
s.make_timeline()
|
||||
if not s.color:
|
||||
s.cuts = tuple(extract.cuts(s.timeline_prefix))
|
||||
s.color = tuple(extract.average_color(s.timeline_prefix))
|
||||
s.save()
|
||||
|
||||
s.file.selected = True
|
||||
s.file.save()
|
||||
s.file.item.update_timeline()
|
||||
#make sure all derivatives exist
|
||||
s.extract_derivatives()
|
||||
|
||||
#update clips
|
||||
for c in s.file.item.clips.all():
|
||||
c.update_calculated_values()
|
||||
c.save()
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from glob import glob
|
||||
|
||||
from celery.task import task
|
||||
import ox
|
||||
|
||||
|
@ -9,7 +11,7 @@ from item.models import get_item, Item
|
|||
import item.tasks
|
||||
|
||||
import models
|
||||
|
||||
import extract
|
||||
|
||||
_INSTANCE_KEYS = ('mtime', 'path')
|
||||
|
||||
|
@ -99,3 +101,24 @@ def process_stream(fileId):
|
|||
if not file.item.rendered:
|
||||
file.item.update_timeline()
|
||||
return True
|
||||
|
||||
@task(queue="encoding")
|
||||
def update_stream(id):
|
||||
s = models.Stream.objects.get(pk=id)
|
||||
if not glob("%s*"%s.timeline_prefix):
|
||||
s.make_timeline()
|
||||
if not s.color:
|
||||
s.cuts = tuple(extract.cuts(s.timeline_prefix))
|
||||
s.color = tuple(extract.average_color(s.timeline_prefix))
|
||||
s.save()
|
||||
|
||||
s.file.selected = True
|
||||
s.file.save()
|
||||
s.file.item.update_timeline()
|
||||
#make sure all derivatives exist
|
||||
s.extract_derivatives()
|
||||
|
||||
#update clips
|
||||
for c in s.file.item.clips.all():
|
||||
c.update_calculated_values()
|
||||
c.save()
|
||||
|
|
Loading…
Reference in a new issue