This commit is contained in:
j 2011-10-20 21:33:57 +02:00
commit a434b83d69
9 changed files with 236 additions and 190 deletions

View file

@ -135,6 +135,7 @@ class File(models.Model):
self.is_subtitle = False self.is_subtitle = False
self.type = self.get_type() self.type = self.get_type()
if self.instances.count()>0:
info = ox.parse_movie_path(self.path) info = ox.parse_movie_path(self.path)
self.language = info['language'] self.language = info['language']
self.part = self.get_part() self.part = self.get_part()

View file

@ -3,16 +3,18 @@
from celery.decorators import task from celery.decorators import task
import ox import ox
from item.models import get_item
from django.conf import settings from django.conf import settings
from item.models import get_item
import item.tasks
import models import models
_INSTANCE_KEYS = ('mtime', 'path') _INSTANCE_KEYS = ('mtime', 'path')
def get_or_create_item(volume, info, user): 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) return get_item(item_info, user)
def get_or_create_file(volume, f, user, item=None): 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) user = models.User.objects.get(username=user)
volume, created = models.Volume.objects.get_or_create(user=user, name=volume) volume, created = models.Volume.objects.get_or_create(user=user, name=volume)
all_files = [] all_files = []
for f in files:
#ignore extras etc, #ignore extras etc,
#imdb stlye is L/Last, First/Title (Year)/Title.. 4 #imdb stlye is L/Last, First/Title (Year)/Title.. 4
#otherwise T/Title (Year)/Title... 3 #otherwise T/Title (Year)/Title... 3
folder_depth = settings.USE_IMDB and 4 or 3 folder_depth = settings.USE_IMDB and 4 or 3
for f in files:
if len(f['path'].split('/')) == folder_depth: if len(f['path'].split('/')) == folder_depth:
all_files.append(f['oshash']) all_files.append(f['oshash'])
update_or_create_instance(volume, f) update_or_create_instance(volume, f)
#remove deleted files #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.models.objects.filter(
files__instances__in=removed.filter(selected=True)).distinct().values('itemId')]
removed.delete()
for i in ids:
i = Item.models.objects.get(itemId=i)
i.update_selected()
@task(queue="encoding") @task(queue="encoding")
def process_stream(fileId): def process_stream(fileId):

View file

@ -53,7 +53,7 @@ class Clip(models.Model):
self.title = self.item.sort.title self.title = self.item.sort.title
def save(self, *args, **kwargs): 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: if self.duration != self.end - self.start:
self.update_calculated_values() self.update_calculated_values()
super(Clip, self).save(*args, **kwargs) super(Clip, self).save(*args, **kwargs)
@ -93,11 +93,13 @@ class Clip(models.Model):
@classmethod @classmethod
def get_or_create(cls, item, start, end): def get_or_create(cls, item, start, end):
start = float(start)
end = float(end)
public_id = u"%s/%s-%s" %(item.itemId, start, end) public_id = u"%s/%s-%s" %(item.itemId, start, end)
qs = cls.objects.filter(public_id=public_id) qs = cls.objects.filter(public_id=public_id)
if qs.count() == 0: if qs.count() == 0:
clip = Clip(item=item, start=start, end=end, public_id=public_id) clip = Clip(item=item, start=start, end=end, public_id=public_id)
clips.save() clip.save()
created = True created = True
else: else:
clip = qs[0] clip = qs[0]

View file

@ -174,7 +174,25 @@ Ox.load({
pandora.$ui.info.resizeInfo(); pandora.$ui.info.resizeInfo();
if (!pandora.user.ui.item) { if (!pandora.user.ui.item) {
pandora.resizeGroups(pandora.$ui.rightPanel.width()); pandora.resizeGroups(pandora.$ui.rightPanel.width());
if (pandora.user.ui.listView == 'map') { if (pandora.user.ui.listView == 'clips') {
var clipsItems = pandora.getClipsItems();
previousClipsItems = pandora.getClipsItems(pandora.$ui.list.options('width'));
pandora.$ui.list.options({
width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE
});
if (clipsItems != previousClipsItems) {
Ox.Request.clearCache(); // fixme
pandora.$ui.list.reloadList(true);
}
} else if (pandora.user.ui.listView == 'timelines') {
pandora.$ui.list.options({
width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE
});
} else if (pandora.user.ui.listView == 'map') {
pandora.$ui.map.resizeMap(); pandora.$ui.map.resizeMap();
} else if (pandora.user.ui.listView == 'calendar') { } else if (pandora.user.ui.listView == 'calendar') {
pandora.$ui.calendar.resizeCalendar(); pandora.$ui.calendar.resizeCalendar();

View file

@ -6,7 +6,8 @@ pandora.ui.item = function() {
pandora.api.get({ pandora.api.get({
id: pandora.user.ui.item, id: pandora.user.ui.item,
keys: [] keys: ['video', 'timeline'].indexOf(pandora.user.ui.itemView)>-1 ?
['rendered', 'cuts', 'videoRatio', 'duration', 'layers', 'parts', 'size'] : []
}, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) { }, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) {
if (result.status.code == 200) { if (result.status.code == 200) {
@ -102,14 +103,13 @@ pandora.ui.item = function() {
); );
} else if (pandora.user.ui.itemView == 'video') { } else if (pandora.user.ui.itemView == 'video') {
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) {
// fixme: duplicated // fixme: duplicated
var clipsQuery = pandora.getClipsQuery(), var clipsQuery = pandora.getClipsQuery(),
isClipsQuery = !!clipsQuery.conditions.length, isClipsQuery = !!clipsQuery.conditions.length,
layers = [], layers = [],
video = {}; video = {};
pandora.site.layers.forEach(function(layer, i) { 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) { pandora.site.video.resolutions.forEach(function(resolution) {
video[resolution] = Ox.range(result.data.parts).map(function(i) { video[resolution] = Ox.range(result.data.parts).map(function(i) {
@ -134,8 +134,8 @@ pandora.ui.item = function() {
scaleToFill: pandora.user.ui.videoScale == 'fill', scaleToFill: pandora.user.ui.videoScale == 'fill',
showAnnotations: pandora.user.ui.showAnnotations, showAnnotations: pandora.user.ui.showAnnotations,
showControls: pandora.user.ui.showControls, showControls: pandora.user.ui.showControls,
subtitles: r.data.layers.subtitles ? subtitles: result.data.layers.subtitles ?
r.data.layers.subtitles.map(function(subtitle) { result.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value}; return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}) : [], }) : [],
tooltips: true, tooltips: true,
@ -169,16 +169,14 @@ pandora.ui.item = function() {
pandora.$ui.player.options({showAnnotations: data.value}); pandora.$ui.player.options({showAnnotations: data.value});
} }
})); }));
});
} else if (pandora.user.ui.itemView == 'timeline') { } else if (pandora.user.ui.itemView == 'timeline') {
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) {
var clipsQuery = pandora.getClipsQuery(), var clipsQuery = pandora.getClipsQuery(),
isClipsQuery = !!clipsQuery.conditions.length, isClipsQuery = !!clipsQuery.conditions.length,
layers = [], layers = [],
video = {}; video = {};
pandora.site.layers.forEach(function(layer) { 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) { pandora.site.video.resolutions.forEach(function(resolution) {
video[resolution] = Ox.range(result.data.parts).map(function(i) { video[resolution] = Ox.range(result.data.parts).map(function(i) {
@ -211,8 +209,8 @@ pandora.ui.item = function() {
showAnnotations: pandora.user.ui.showAnnotations, showAnnotations: pandora.user.ui.showAnnotations,
showLargeTimeline: true, showLargeTimeline: true,
// fixme: layers have value, subtitles has text? // fixme: layers have value, subtitles has text?
subtitles: r.data.layers.subtitles ? subtitles: result.data.layers.subtitles ?
r.data.layers.subtitles.map(function(subtitle) { result.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value}; return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}) : [], }) : [],
tooltips: true, tooltips: true,
@ -285,7 +283,6 @@ pandora.ui.item = function() {
}); });
}); });
*/ */
});
} else if (pandora.user.ui.itemView == 'map') { } else if (pandora.user.ui.itemView == 'map') {
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio)); pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio));

View file

@ -39,7 +39,9 @@ pandora.ui.itemClips = function(options) {
.addClass('OxInfoIcon') .addClass('OxInfoIcon')
.css({ .css({
float: 'left', float: 'left',
margin: '2px' margin: i == 0 ? '2px 2px 2px -2px'
: i == self.options.clips.length - 1 ? '2px -2px 2px 2px'
: '2px'
}) })
.data({'in': clip['in'], out: clip.out}); .data({'in': clip['in'], out: clip.out});
$item.$element.find('.OxTarget').addClass('OxSpecialTarget'); $item.$element.find('.OxTarget').addClass('OxSpecialTarget');

View file

@ -233,7 +233,7 @@ pandora.ui.list = function() {
query: pandora.user.ui.find, query: pandora.user.ui.find,
clips: { clips: {
query: pandora.getClipsQuery(), query: pandora.getClipsQuery(),
items: 5, items: pandora.getClipsItems(),
keys: [] keys: []
} }
}), callback); }), callback);
@ -242,7 +242,10 @@ pandora.ui.list = function() {
selected: pandora.user.ui.listSelection, selected: pandora.user.ui.listSelection,
size: 192, size: 192,
sort: pandora.user.ui.listSort, sort: pandora.user.ui.listSort,
unique: 'id' unique: 'id',
width: window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE
}) })
.bindEvent({ .bindEvent({
key_left: function() { key_left: function() {

View file

@ -25,7 +25,15 @@ pandora.ui.rightPanel = function() {
if (!pandora.user.ui.item) { if (!pandora.user.ui.item) {
pandora.resizeGroups(); pandora.resizeGroups();
pandora.$ui.list.size(); pandora.$ui.list.size();
if (pandora.user.ui.listView == 'timelines') { if (pandora.user.ui.listView == 'clips') {
var clipsItems = pandora.getClipsItems();
previousClipsItems = pandora.getClipsItems(pandora.$ui.list.options('width'));
pandora.$ui.list.options({width: data.size});
if (clipsItems != previousClipsItems) {
Ox.Request.clearCache(); // fixme
pandora.$ui.list.reloadList(true);
}
} else if (pandora.user.ui.listView == 'timelines') {
pandora.$ui.list.options({width: data.size}); pandora.$ui.list.options({width: data.size});
} else if (pandora.user.ui.listView == 'map') { } else if (pandora.user.ui.listView == 'map') {
pandora.$ui.map.resizeMap(); pandora.$ui.map.resizeMap();

View file

@ -416,6 +416,13 @@ pandora.exitFullscreen = function() {
pandora.user.ui.showBrowser && pandora.$ui.contentPanel.size(0, 112 + Ox.UI.SCROLLBAR_SIZE); pandora.user.ui.showBrowser && pandora.$ui.contentPanel.size(0, 112 + Ox.UI.SCROLLBAR_SIZE);
}; };
pandora.getClipsItems = function(width) {
width = width || window.innerWidth
- pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 1
- Ox.UI.SCROLLBAR_SIZE;
return Math.floor((width - 8) / (128 + 8)) - 1;
};
pandora.getClipsQuery = function() { pandora.getClipsQuery = function() {
function addClipsConditions(conditions) { function addClipsConditions(conditions) {
conditions.forEach(function(condition) { conditions.forEach(function(condition) {