forked from 0x2620/pandora
extract sequences from all parts
This commit is contained in:
parent
e21484af1c
commit
cde92a1624
2 changed files with 21 additions and 15 deletions
|
@ -50,13 +50,12 @@ def get_hash(image, mode, debug=False):
|
||||||
if h.endswith('L'): h = h[:-1]
|
if h.endswith('L'): h = h[:-1]
|
||||||
return '0' * (16-len(h)) + h
|
return '0' * (16-len(h)) + h
|
||||||
|
|
||||||
def get_sequences(path):
|
def get_sequences(path, position=0):
|
||||||
modes = ['color', 'shape']
|
modes = ['color', 'shape']
|
||||||
sequences = {}
|
sequences = {}
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
sequences[mode] = []
|
sequences[mode] = []
|
||||||
fps = 25
|
fps = 25
|
||||||
position = 0
|
|
||||||
file_names = filter(lambda x: 'timelinedata8p' in x, os.listdir(path))
|
file_names = filter(lambda x: 'timelinedata8p' in x, os.listdir(path))
|
||||||
file_names = sorted(file_names, key=lambda x: int(x[14:-4]))
|
file_names = sorted(file_names, key=lambda x: int(x[14:-4]))
|
||||||
file_names = map(lambda x: path + x, file_names)
|
file_names = map(lambda x: path + x, file_names)
|
||||||
|
@ -75,5 +74,5 @@ def get_sequences(path):
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
if sequences[mode]:
|
if sequences[mode]:
|
||||||
sequences[mode][-1]['out'] = position
|
sequences[mode][-1]['out'] = position
|
||||||
return sequences
|
return sequences, position
|
||||||
|
|
||||||
|
|
|
@ -14,18 +14,25 @@ from celery.task import task, periodic_task
|
||||||
import models
|
import models
|
||||||
import extract
|
import extract
|
||||||
|
|
||||||
@task(ignore_results=True, queue='default')
|
@task(ignore_results=True, queue='encoding')
|
||||||
def get_sequences(itemId):
|
def get_sequences(itemId):
|
||||||
i = models.Item.objects.get(itemId=itemId)
|
i = models.Item.objects.get(itemId=itemId)
|
||||||
models.Sequence.objects.filter(item=i).delete()
|
models.Sequence.objects.filter(item=i).delete()
|
||||||
data = extract.get_sequences(i.timeline_prefix)
|
position = 0
|
||||||
with transaction.commit_on_success():
|
for stream in i.streams():
|
||||||
for mode in data:
|
data, position = extract.get_sequences(stream.timeline_prefix, position)
|
||||||
for seq in data[mode]:
|
with transaction.commit_on_success():
|
||||||
s = models.Sequence()
|
for mode in data:
|
||||||
s.item = i
|
for seq in data[mode]:
|
||||||
s.mode = mode
|
s = models.Sequence()
|
||||||
s.start = seq['in']
|
s.item = i
|
||||||
s.end = seq['out']
|
s.mode = mode
|
||||||
s.hash = seq['hash']
|
s.start = seq['in']
|
||||||
s.save()
|
s.end = seq['out']
|
||||||
|
s.hash = seq['hash']
|
||||||
|
s.save()
|
||||||
|
|
||||||
|
@task(ignore_results=True, queue='encoding')
|
||||||
|
def update_sequence_ids(itemId):
|
||||||
|
for s in models.Sequence.objects.filter(item__itemId=itemId):
|
||||||
|
s.save()
|
||||||
|
|
Loading…
Reference in a new issue