forked from 0x2620/pandora
include outer cuts (before, after)
This commit is contained in:
parent
b1834520bd
commit
0a7b6c0452
3 changed files with 26 additions and 2 deletions
|
@ -8,6 +8,7 @@ import ox
|
|||
from archive import extract
|
||||
|
||||
from . import managers
|
||||
from .utils import add_cuts
|
||||
|
||||
|
||||
def get_layers(item, interval=None, user=None):
|
||||
|
@ -155,7 +156,7 @@ class MetaClip(object):
|
|||
if value:
|
||||
data[key] = value
|
||||
data['duration'] = data['out'] - data['in']
|
||||
data['cuts'] = tuple([c for c in self.item.get('cuts', []) if c > self.start and c < self.end])
|
||||
add_cuts(data, self.item, self.start, self.end)
|
||||
data['layers'] = self.get_layers(user)
|
||||
data['streams'] = [s.file.oshash for s in self.item.streams()]
|
||||
return data
|
||||
|
|
22
pandora/clip/utils.py
Normal file
22
pandora/clip/utils.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
def add_cuts(data, item, start, end):
|
||||
cuts = []
|
||||
last = False
|
||||
outer = []
|
||||
first = 0
|
||||
for cut in item.get('cuts', []):
|
||||
if cut > start and cut < end:
|
||||
if not cuts:
|
||||
outer.append(first)
|
||||
cuts.append(cut)
|
||||
last = True
|
||||
elif cut <= start:
|
||||
first = cut
|
||||
elif cut >= end:
|
||||
if not len(outer):
|
||||
outer.append(first)
|
||||
if len(outer) == 1:
|
||||
outer.append(cut)
|
||||
data['cuts'] = tuple(cuts)
|
||||
data['outerCuts'] = tuple(outer)
|
|
@ -24,6 +24,7 @@ import clip.models
|
|||
from archive import extract
|
||||
from user.utils import update_groups
|
||||
from user.models import Group
|
||||
from clip.utils import add_cuts
|
||||
|
||||
from . import managers
|
||||
|
||||
|
@ -507,7 +508,7 @@ class Clip(models.Model):
|
|||
if value:
|
||||
data[key] = value
|
||||
data['duration'] = data['out'] - data['in']
|
||||
data['cuts'] = tuple([c for c in self.item.get('cuts', []) if c > self.start and c < self.end])
|
||||
add_cuts(data, self.item, self.start, self.end)
|
||||
data['layers'] = self.get_layers(user)
|
||||
data['streams'] = [s.file.oshash for s in self.item.streams()]
|
||||
return data
|
||||
|
|
Loading…
Reference in a new issue