path cleanup, add volumes

This commit is contained in:
j 2010-09-10 11:58:59 +02:00
parent 8aa1f119ea
commit cde1451f9b
2 changed files with 47 additions and 5 deletions

View file

@ -250,7 +250,7 @@ class Movie(models.Model):
def frame(self, position, width=128): def frame(self, position, width=128):
stream = self.streams.filter(profile=settings.VIDEO_PROFILE+'.webm')[0] stream = self.streams.filter(profile=settings.VIDEO_PROFILE+'.webm')[0]
path = os.path.join(settings.MEDIA_ROOT, 'frame', self.movieId, "%d"%width, "%s.jpg"%position) path = os.path.join(settings.MEDIA_ROOT, movieid_path(self.movieId), 'frame', "%d"%width, "%s.jpg"%position)
if not os.path.exists(path): if not os.path.exists(path):
extract.frame(stream.video.path, path, position, width) extract.frame(stream.video.path, path, position, width)
return path return path

View file

@ -1,5 +1,6 @@
if(typeof(app.afterLaunch) == "undefined") if(typeof(app.afterLaunch) == "undefined")
app.afterLaunch = []; app.afterLaunch = [];
app.afterLaunch.push(function() { app.afterLaunch.push(function() {
if (typeof(OxFF) == 'undefined') if (typeof(OxFF) == 'undefined')
return; return;
@ -55,7 +56,6 @@ app.afterLaunch.push(function() {
if(!cb) if(!cb)
return null; return null;
return function(result) { return function(result) {
Ox.print("you called upload", result);
var data = JSON.parse(result); var data = JSON.parse(result);
cb(data) cb(data)
} }
@ -81,16 +81,20 @@ app.afterLaunch.push(function() {
} }
}, },
loadVolumes: function() { loadVolumes: function() {
var _this = this;
Ox.print("load volumes"); Ox.print("load volumes");
var $section = new Ox.CollapsePanel({ var $section = new Ox.CollapsePanel({
id: 'volumes', id: 'volumes',
size: 'small', size: 'small',
title: 'Volumes' title: 'Volumes'
}); });
app.$ui.sections.push($section); app.$ui.sections.push($section);
app.local.volumes(function(data) { app.local.volumes(function(data) {
Ox.print("got volumes", data); Ox.print("got volumes", data);
var volumes = 0;
$.each(data, function(name, info) { $.each(data, function(name, info) {
volumes ++;
Ox.print("add volume", name, info); Ox.print("add volume", name, info);
var status = info.available?"online":"offline"; var status = info.available?"online":"offline";
var $line = $('<div>').css({ height: '20px' }).append( var $line = $('<div>').css({ height: '20px' }).append(
@ -112,7 +116,30 @@ app.afterLaunch.push(function() {
}); });
$section.$content.append($line); $section.$content.append($line);
}); });
add_button = new Ox.Button({
id: 'add_volume',
title: 'add',
width: 32
}).bindEvent('click', function(event, data) {
if(_this.api.setLocation("Volume "+(volumes+1))) _this.loadVolumes();
});
var update_button = new Ox.Button({
id: 'update_archive',
title: 'update',
width: 48
}).bindEvent('click', function(event, data) {
update_button.options({disabled: true});
_this.api.update(function() {
update_button.options({disabled: false});
})
});
app.$ui.lists.replaceWith(app.constructLists()); app.$ui.lists.replaceWith(app.constructLists());
$section.find('.OxBar').append($('<div>')
.css({'text-align': 'right', 'margin': '2px'})
.append(update_button.$element)
.append(add_button.$element)
);
}); });
}, },
uploadVideos: function(ids, done, progress, total) { uploadVideos: function(ids, done, progress, total) {
@ -164,8 +191,12 @@ app.afterLaunch.push(function() {
} }
); );
}, },
cancel: function(oshash) {
Ox.print('this function needs to be implemented: cancel ', oshash);
},
constructFileList: function(name) { constructFileList: function(name) {
var $list = new Ox.TextList({ var _this = this,
$list = new Ox.TextList({
columns: [ columns: [
{ {
align: "left", align: "left",
@ -231,14 +262,25 @@ app.afterLaunch.push(function() {
width: 48 width: 48
}).bindEvent('click', function(fid) { return function(event, data) { }).bindEvent('click', function(fid) { return function(event, data) {
Ox.print(videos[fid]); Ox.print(videos[fid]);
$($('#'+fid).find('.OxCell')[1]).html(function(fid) {
var button = new Ox.Button({
title: 'Cancel',
width: 48
}).bindEvent('click', function(event, data) {
$.each(videos[fid], function(i, oshash) {
_this.cancel(oshash);
});
});
return button.$element;
}(fid));
//$($('#'+fid).find('.OxCell')[2]).html('extracting data...'); //$($('#'+fid).find('.OxCell')[2]).html('extracting data...');
app.local.uploadVideos( app.local.uploadVideos(
videos[fid], videos[fid],
function(data) { function(data) {
$($('#'+fid).find('.OxCell')[2]).html('done'); $($('#'+fid).find('.OxCell')[2]).html('done');
}, },
function(data) { function(data) {
$($('#'+fid).find('.OxCell')[2]).html(data.status +': '+ data.progress); $($('#'+fid).find('.OxCell')[2]).html(parseInt(data.progress*100));
} }
); );
}}(i)); }}(i));