merge
This commit is contained in:
commit
3ac27ac27a
11 changed files with 253 additions and 210 deletions
|
@ -10,7 +10,7 @@
|
|||
|
||||
<Location />
|
||||
XSendFile on
|
||||
XSendFileAllowAbove on
|
||||
XSendFilePath __PREFIX__
|
||||
</Location>
|
||||
|
||||
Alias /.bzr __PREFIX__/.bzr
|
||||
|
|
|
@ -118,13 +118,7 @@ class Annotation(models.Model):
|
|||
if not self.clip and not self.layer.private or \
|
||||
(self.clip and not self.layer.private and \
|
||||
self.start != self.clip.start or self.end != self.clip.end):
|
||||
|
||||
self.clip, created = Clip.objects.get_or_create(item=self.item,
|
||||
start=self.start,
|
||||
end=self.end)
|
||||
if created:
|
||||
clip = Clip.objects.get(pk=self.clip.pk)
|
||||
clip.save()
|
||||
self.clip, created = Clip.get_or_create(self.item, self.start, self.end)
|
||||
|
||||
super(Annotation, self).save(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -288,7 +288,8 @@ def average_color(prefix, start=0, end=0):
|
|||
if end:
|
||||
start = int(start * 25)
|
||||
end = int(end * 25)
|
||||
for image in sorted(glob("%s.%d.*.png" % (prefix, height))):
|
||||
timelines = sorted(filter(lambda t: t!= '%s%sp.png'%(prefix,height), glob("%s%sp*.png"%(prefix, height))))
|
||||
for image in timelines:
|
||||
start_offset = 0
|
||||
timeline = Image.open(image)
|
||||
frames += timeline.size[0]
|
||||
|
@ -334,7 +335,8 @@ def cuts(prefix):
|
|||
height = 64
|
||||
width = 1500
|
||||
pixels = []
|
||||
for image in sorted(glob("%s.%d.*.png" % (prefix, height))):
|
||||
timelines = sorted(filter(lambda t: t!= '%s%sp.png'%(prefix,height), glob("%s%sp*.png"%(prefix, height))))
|
||||
for image in timelines:
|
||||
timeline = Image.open(image)
|
||||
frames += timeline.size[0]
|
||||
pixels.append(timeline.load())
|
||||
|
@ -418,7 +420,7 @@ def timeline_strip(item, cuts, info, prefix):
|
|||
if len(line_image) > frame:
|
||||
timeline_image.paste(line_image[frame], (x, 0))
|
||||
if x == timeline_width - 1:
|
||||
timeline_file = '%sstrip.64.%04d.png' % (prefix, i)
|
||||
timeline_file = '%sStrip64p%04d.png' % (prefix, i)
|
||||
if _debug:
|
||||
print 'writing', timeline_file
|
||||
timeline_image.save(timeline_file)
|
||||
|
|
|
@ -75,7 +75,6 @@ class File(models.Model):
|
|||
|
||||
def set_state(self):
|
||||
self.path = self.create_path()
|
||||
self.sort_path= utils.sort_string(self.path)
|
||||
|
||||
if not os.path.splitext(self.path)[-1] in (
|
||||
'.srt', '.rar', '.sub', '.idx', '.txt', '.jpg', '.png', '.nfo') \
|
||||
|
@ -135,6 +134,7 @@ class File(models.Model):
|
|||
self.is_subtitle = False
|
||||
|
||||
self.type = self.get_type()
|
||||
if self.instances.count()>0:
|
||||
info = ox.parse_movie_path(self.path)
|
||||
self.language = info['language']
|
||||
self.part = self.get_part()
|
||||
|
@ -145,6 +145,7 @@ class File(models.Model):
|
|||
def save(self, *args, **kwargs):
|
||||
if self.auto:
|
||||
self.set_state()
|
||||
self.sort_path= utils.sort_string(self.path)
|
||||
if self.is_subtitle:
|
||||
self.available = self.data and True or False
|
||||
else:
|
||||
|
@ -441,6 +442,9 @@ class Stream(models.Model):
|
|||
duration = models.FloatField(default=0)
|
||||
aspect_ratio = models.FloatField(default=0)
|
||||
|
||||
cuts = fields.TupleField(default=[])
|
||||
color = fields.TupleField(default=[])
|
||||
|
||||
@property
|
||||
def timeline_prefix(self):
|
||||
return os.path.join(settings.MEDIA_ROOT, self.path(), 'timeline')
|
||||
|
@ -483,6 +487,9 @@ class Stream(models.Model):
|
|||
def make_timeline(self):
|
||||
if self.available and not self.source:
|
||||
extract.timeline(self.video.path, self.timeline_prefix)
|
||||
self.cuts = tuple(extract.cuts(self.timeline_prefix))
|
||||
self.color = tuple(extract.average_color(self.timeline_prefix))
|
||||
self.save()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.video and not self.info:
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
from celery.decorators import task
|
||||
import ox
|
||||
|
||||
from item.models import get_item
|
||||
from django.conf import settings
|
||||
|
||||
from item.models import get_item, Item
|
||||
import item.tasks
|
||||
|
||||
import models
|
||||
|
||||
|
||||
_INSTANCE_KEYS = ('mtime', 'path')
|
||||
|
||||
def get_or_create_item(volume, info, user):
|
||||
item_info = ox.parse_movie_info(info['path'])
|
||||
item_info = ox.parse_movie_path(info['path'])
|
||||
return get_item(item_info, user)
|
||||
|
||||
def get_or_create_file(volume, f, user, item=None):
|
||||
|
@ -67,17 +69,23 @@ def update_files(user, volume, files):
|
|||
user = models.User.objects.get(username=user)
|
||||
volume, created = models.Volume.objects.get_or_create(user=user, name=volume)
|
||||
all_files = []
|
||||
for f in files:
|
||||
#ignore extras etc,
|
||||
#imdb stlye is L/Last, First/Title (Year)/Title.. 4
|
||||
#otherwise T/Title (Year)/Title... 3
|
||||
folder_depth = settings.USE_IMDB and 4 or 3
|
||||
for f in files:
|
||||
if len(f['path'].split('/')) == folder_depth:
|
||||
all_files.append(f['oshash'])
|
||||
update_or_create_instance(volume, f)
|
||||
|
||||
#remove deleted files
|
||||
models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files).delete()
|
||||
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
|
||||
ids = [i['itemId'] for i in Item.objects.filter(
|
||||
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
|
||||
removed.delete()
|
||||
for i in ids:
|
||||
i = Item.objects.get(itemId=i)
|
||||
i.update_selected()
|
||||
|
||||
@task(queue="encoding")
|
||||
def process_stream(fileId):
|
||||
|
|
|
@ -8,6 +8,7 @@ from django.conf import settings
|
|||
from archive import extract
|
||||
import managers
|
||||
|
||||
|
||||
class Clip(models.Model):
|
||||
'''
|
||||
CREATE INDEX clip_clip_title_idx ON clip_clip (title ASC NULLS LAST);
|
||||
|
@ -20,7 +21,7 @@ class Clip(models.Model):
|
|||
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
public_id = models.CharField(max_length=128, unique=True, null=True)
|
||||
public_id = models.CharField(max_length=128, unique=True)
|
||||
|
||||
item = models.ForeignKey('item.Item', related_name='clips')
|
||||
|
||||
|
@ -52,7 +53,7 @@ class Clip(models.Model):
|
|||
self.title = self.item.sort.title
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.public_id = u"%s/%s-%s" %(self.item.itemId, self.start, self.end)
|
||||
self.public_id = u"%s/%s-%s" %(self.item.itemId, float(self.start), float(self.end))
|
||||
if self.duration != self.end - self.start:
|
||||
self.update_calculated_values()
|
||||
super(Clip, self).save(*args, **kwargs)
|
||||
|
@ -90,6 +91,21 @@ class Clip(models.Model):
|
|||
j[key] = self.item.get(key)
|
||||
return j
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s/%s-%s" %(self.item, self.start, self.end)
|
||||
@classmethod
|
||||
def get_or_create(cls, item, start, end):
|
||||
start = float(start)
|
||||
end = float(end)
|
||||
public_id = u"%s/%s-%s" %(item.itemId, start, end)
|
||||
qs = cls.objects.filter(public_id=public_id)
|
||||
if qs.count() == 0:
|
||||
clip = Clip(item=item, start=start, end=end, public_id=public_id)
|
||||
clip.save()
|
||||
created = True
|
||||
else:
|
||||
clip = qs[0]
|
||||
created = False
|
||||
return clip, created
|
||||
|
||||
def __unicode__(self):
|
||||
return self.public_id
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ class Item(models.Model):
|
|||
layers = {}
|
||||
for l in Layer.objects.all():
|
||||
ll = layers.setdefault(l.name, [])
|
||||
qs = Annotation.objects.filter(layer=l, item=self).select_related()
|
||||
qs = Annotation.objects.filter(layer=l, item=self)
|
||||
if l.name == 'subtitles':
|
||||
qs = qs.exclude(value='')
|
||||
if l.private:
|
||||
|
@ -850,8 +850,22 @@ class Item(models.Model):
|
|||
def update_timeline(self, force=False):
|
||||
streams = self.streams()
|
||||
self.make_timeline()
|
||||
self.data['cuts'] = extract.cuts(self.timeline_prefix)
|
||||
self.data['color'] = extract.average_color(self.timeline_prefix)
|
||||
if streams.count() == 1:
|
||||
self.data['color'] = streams[0].color
|
||||
self.data['cuts'] = streams[0].cuts
|
||||
else:
|
||||
#self.data['color'] = extract.average_color(self.timeline_prefix)
|
||||
#self.data['cuts'] = extract.cuts(self.timeline_prefix)
|
||||
self.data['cuts'] = []
|
||||
offset = 0
|
||||
color = [0, 0, 0]
|
||||
n = streams.count()
|
||||
for s in streams:
|
||||
for c in s.cuts:
|
||||
self.data['cuts'].append(c+offset)
|
||||
color = map(lambda a,b: (a+b)/n, color,ox.image.getRGB(s.color))
|
||||
offset += s.duration
|
||||
self.data['color'] = ox.image.getHSL(color)
|
||||
#extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8])
|
||||
self.select_frame()
|
||||
self.make_local_poster()
|
||||
|
|
|
@ -8,8 +8,12 @@ import Image
|
|||
|
||||
import ox
|
||||
|
||||
def getTiles(timeline_prefix, height=64):
|
||||
files = glob('%s%sp*.png' % (timeline_prefix, height))
|
||||
return sorted(filter(lambda f: f!='%s%sp.png' % (timeline_prefix, height), files))
|
||||
|
||||
def loadTimeline(timeline_prefix, height=64):
|
||||
files = sorted(glob('%s%sp*.png' % (timeline_prefix, height)))
|
||||
files = getTiles(timeline_prefix, height)
|
||||
f = Image.open(files[0])
|
||||
width = f.size[0]
|
||||
f = Image.open(files[-1])
|
||||
|
@ -23,7 +27,7 @@ def loadTimeline(timeline_prefix, height=64):
|
|||
return timeline
|
||||
|
||||
def makeTiles(timeline_prefix, height=16, width=3600):
|
||||
files = glob('%s64p*.png' % timeline_prefix)
|
||||
files = getTiles(timeline_prefix, 64)
|
||||
fps = 25
|
||||
part_step = 60
|
||||
output_width = width
|
||||
|
@ -53,7 +57,7 @@ def makeTimelineOverview(timeline_prefix, width, inpoint=0, outpoint=0, duration
|
|||
|
||||
timeline_file = '%s%sp.png' % (timeline_prefix, height)
|
||||
if outpoint > 0:
|
||||
timeline_file = '%s.overview.%s.%d-%d.png' % (timeline_prefix, height, inpoint, outpoint)
|
||||
timeline_file = '%s%sp.%d-%d.png' % (timeline_prefix, height, inpoint, outpoint)
|
||||
|
||||
timeline = loadTimeline(timeline_prefix)
|
||||
duration = timeline.size[0]
|
||||
|
@ -70,14 +74,17 @@ def makeTimelineOverview(timeline_prefix, width, inpoint=0, outpoint=0, duration
|
|||
timeline = timeline.crop((inpoint, 0, outpoint, timeline.size[1])).resize((width, height), Image.ANTIALIAS)
|
||||
timeline.save(timeline_file)
|
||||
|
||||
|
||||
def join_timelines(timelines, prefix):
|
||||
height = 64
|
||||
width = 1500
|
||||
|
||||
ox.makedirs(os.path.dirname(prefix))
|
||||
for f in glob('%s*'%prefix):
|
||||
os.unlink(f)
|
||||
|
||||
tiles = []
|
||||
for timeline in timelines:
|
||||
tiles += sorted(glob('%s%sp*.png'%(timeline, height)))
|
||||
tiles += getTiles(timeline, height)
|
||||
|
||||
timeline = Image.new("RGB", (2 * width, height))
|
||||
|
||||
|
@ -99,7 +106,6 @@ def join_timelines(timelines, prefix):
|
|||
timeline_name = '%s%sp%04d.png' % (prefix, height, i)
|
||||
timeline.crop((0, 0, pos, height)).save(timeline_name)
|
||||
|
||||
ox.makedirs(os.path.dirname(prefix))
|
||||
makeTiles(prefix, 16, 3600)
|
||||
makeTimelineOverview(prefix, 1920, height=16)
|
||||
makeTimelineOverview(prefix, 1920, height=64)
|
||||
|
|
|
@ -59,7 +59,7 @@ def addPlace(request):
|
|||
value = tuple(value)
|
||||
setattr(place, key, value)
|
||||
place.save()
|
||||
#tasks.update_matches.delay(place.id)
|
||||
tasks.update_matches.delay(place.id)
|
||||
response = json_response(place.json())
|
||||
else:
|
||||
response = json_response(status=403,
|
||||
|
|
|
@ -64,7 +64,6 @@ def get_ui(user_ui, user=None):
|
|||
ui = updateUI(ui, user_ui)
|
||||
if not 'lists' in ui:
|
||||
ui['lists'] = {}
|
||||
ui['lists'][''] = copy.deepcopy(config['user']['ui']['lists'][''])
|
||||
|
||||
def add(lists, section):
|
||||
ids = []
|
||||
|
|
|
@ -6,7 +6,8 @@ pandora.ui.item = function() {
|
|||
|
||||
pandora.api.get({
|
||||
id: pandora.user.ui.item,
|
||||
keys: []
|
||||
keys: ['video', 'timeline'].indexOf(pandora.user.ui.itemView)>-1 ?
|
||||
[ 'cuts', 'duration', 'layers', 'parts', 'rendered', 'size', 'title', 'videoRatio'] : []
|
||||
}, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) {
|
||||
|
||||
if (result.status.code == 200) {
|
||||
|
@ -102,14 +103,13 @@ pandora.ui.item = function() {
|
|||
);
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'video') {
|
||||
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) {
|
||||
// fixme: duplicated
|
||||
var clipsQuery = pandora.getClipsQuery(),
|
||||
isClipsQuery = !!clipsQuery.conditions.length,
|
||||
layers = [],
|
||||
video = {};
|
||||
pandora.site.layers.forEach(function(layer, i) {
|
||||
layers[i] = Ox.extend({}, layer, {items: r.data.layers[layer.id]});
|
||||
layers[i] = Ox.extend({}, layer, {items: result.data.layers[layer.id]});
|
||||
});
|
||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||
|
@ -134,8 +134,8 @@ pandora.ui.item = function() {
|
|||
scaleToFill: pandora.user.ui.videoScale == 'fill',
|
||||
showAnnotations: pandora.user.ui.showAnnotations,
|
||||
showControls: pandora.user.ui.showControls,
|
||||
subtitles: r.data.layers.subtitles ?
|
||||
r.data.layers.subtitles.map(function(subtitle) {
|
||||
subtitles: result.data.layers.subtitles ?
|
||||
result.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
tooltips: true,
|
||||
|
@ -169,16 +169,14 @@ pandora.ui.item = function() {
|
|||
pandora.$ui.player.options({showAnnotations: data.value});
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'timeline') {
|
||||
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) {
|
||||
var clipsQuery = pandora.getClipsQuery(),
|
||||
isClipsQuery = !!clipsQuery.conditions.length,
|
||||
layers = [],
|
||||
video = {};
|
||||
pandora.site.layers.forEach(function(layer) {
|
||||
layers.push(Ox.extend({items: r.data.layers[layer.id]}, layer));
|
||||
layers.push(Ox.extend({items: result.data.layers[layer.id]}, layer));
|
||||
});
|
||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||
|
@ -211,8 +209,8 @@ pandora.ui.item = function() {
|
|||
showAnnotations: pandora.user.ui.showAnnotations,
|
||||
showLargeTimeline: true,
|
||||
// fixme: layers have value, subtitles has text?
|
||||
subtitles: r.data.layers.subtitles ?
|
||||
r.data.layers.subtitles.map(function(subtitle) {
|
||||
subtitles: result.data.layers.subtitles ?
|
||||
result.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
tooltips: true,
|
||||
|
@ -285,7 +283,6 @@ pandora.ui.item = function() {
|
|||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
} else if (pandora.user.ui.itemView == 'map') {
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio));
|
||||
|
||||
|
|
Loading…
Reference in a new issue