fix get_sequences

This commit is contained in:
j 2013-03-06 16:57:46 +01:00
parent be717933e4
commit d7a96c72a1
2 changed files with 5 additions and 4 deletions

View file

@ -26,7 +26,7 @@ class Sequence(models.Model):
sort = models.ForeignKey(ItemSort, null=True, related_name='sequences') sort = models.ForeignKey(ItemSort, null=True, related_name='sequences')
hash = models.BigIntegerField(db_index=True, default=-9223372036854775808) hash = models.BigIntegerField(db_index=True, default=-9223372036854775808)
start = models.FloatField(default=-1, db_index=True) start = models.FloatField(default=-1)
end = models.FloatField(default=-1) end = models.FloatField(default=-1)
duration = models.FloatField(default=0) duration = models.FloatField(default=0)

View file

@ -4,12 +4,13 @@ from django.db import connection, transaction
from celery.task import task from celery.task import task
import models import models
import item.models
import extract import extract
@task(ignore_results=True, queue='encoding') @task(ignore_results=True, queue='encoding')
def get_sequences(itemId): def get_sequences(itemId):
i = models.Item.objects.get(itemId=itemId) i = item.models.Item.objects.get(itemId=itemId)
models.Sequence.objects.filter(item=i).delete() models.Sequence.objects.filter(sort=i.sort).delete()
position = 0 position = 0
for stream in i.streams(): for stream in i.streams():
data, position = extract.get_sequences(stream.timeline_prefix, position) data, position = extract.get_sequences(stream.timeline_prefix, position)
@ -19,7 +20,7 @@ def get_sequences(itemId):
for s in data[mode]: for s in data[mode]:
sequence = { sequence = {
'sort_id': i.sort.pk, 'sort_id': i.sort.pk,
'mode': mode, 'mode': models.Sequence.MODE[mode],
'start': float('%0.03f' % s['in']), 'start': float('%0.03f' % s['in']),
'end': float('%0.03f' % s['out']), 'end': float('%0.03f' % s['out']),
'hash': models.parse_hash(s['hash']) 'hash': models.parse_hash(s['hash'])