Compare commits
4 commits
86bb19b9b6
...
166b566fde
| Author | SHA1 | Date | |
|---|---|---|---|
| 166b566fde | |||
| 157cc7478b | |||
| 02b89c06dd | |||
| 49ef611bdb |
5 changed files with 27 additions and 225 deletions
|
|
@ -1614,8 +1614,15 @@ class Item(models.Model):
|
||||||
cmd += ['-l', timeline]
|
cmd += ['-l', timeline]
|
||||||
if frame:
|
if frame:
|
||||||
cmd += ['-f', frame]
|
cmd += ['-f', frame]
|
||||||
p = subprocess.Popen(cmd, close_fds=True)
|
if settings.ITEM_POSTER_DATA:
|
||||||
p.wait()
|
cmd += '-d', '-'
|
||||||
|
data = self.json()
|
||||||
|
data = utils.normalize_dict('NFC', data)
|
||||||
|
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, close_fds=True)
|
||||||
|
p.communicate(json.dumps(data, default=to_json).encode('utf-8'))
|
||||||
|
else:
|
||||||
|
p = subprocess.Popen(cmd, close_fds=True)
|
||||||
|
p.wait()
|
||||||
# remove cached versions
|
# remove cached versions
|
||||||
icon = os.path.abspath(os.path.join(settings.MEDIA_ROOT, icon))
|
icon = os.path.abspath(os.path.join(settings.MEDIA_ROOT, icon))
|
||||||
for f in glob(icon.replace('.jpg', '*.jpg')):
|
for f in glob(icon.replace('.jpg', '*.jpg')):
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,7 @@ SCRIPT_ROOT = normpath(join(PROJECT_ROOT, '..', 'scripts'))
|
||||||
#change script to customize
|
#change script to customize
|
||||||
ITEM_POSTER = join(SCRIPT_ROOT, 'poster.py')
|
ITEM_POSTER = join(SCRIPT_ROOT, 'poster.py')
|
||||||
ITEM_ICON = join(SCRIPT_ROOT, 'item_icon.py')
|
ITEM_ICON = join(SCRIPT_ROOT, 'item_icon.py')
|
||||||
|
ITEM_ICON_DATA = False
|
||||||
LIST_ICON = join(SCRIPT_ROOT, 'list_icon.py')
|
LIST_ICON = join(SCRIPT_ROOT, 'list_icon.py')
|
||||||
COLLECTION_ICON = join(SCRIPT_ROOT, 'list_icon.py')
|
COLLECTION_ICON = join(SCRIPT_ROOT, 'list_icon.py')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ pandora.ui.editor = function(data) {
|
||||||
|
|
||||||
var ui = pandora.user.ui,
|
var ui = pandora.user.ui,
|
||||||
rightsLevel = data.rightslevel,
|
rightsLevel = data.rightslevel,
|
||||||
|
canEdit = pandora.hasCapability('canEditMetadata') || data.editable,
|
||||||
|
|
||||||
that = Ox.VideoAnnotationPanel({
|
that = Ox.VideoAnnotationPanel({
|
||||||
annotationsCalendarSize: ui.annotationsCalendarSize,
|
annotationsCalendarSize: ui.annotationsCalendarSize,
|
||||||
|
|
@ -44,7 +45,7 @@ pandora.ui.editor = function(data) {
|
||||||
itemName: pandora.site.itemName,
|
itemName: pandora.site.itemName,
|
||||||
layers: data.annotations.map(function(layer) {
|
layers: data.annotations.map(function(layer) {
|
||||||
return Ox.extend({
|
return Ox.extend({
|
||||||
editable: layer.canAddAnnotations[pandora.user.level]
|
editable: layer.canAddAnnotations[pandora.user.level] || canEdit
|
||||||
}, layer, {
|
}, layer, {
|
||||||
autocomplete: layer.type == 'entity'
|
autocomplete: layer.type == 'entity'
|
||||||
? function(key, value, callback) {
|
? function(key, value, callback) {
|
||||||
|
|
|
||||||
|
|
@ -1,219 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
pandora.ui.importMediaDialog = function(options) {
|
|
||||||
|
|
||||||
var help = Ox._('You can import videos from external sites, like YouTube or Vimeo.'),
|
|
||||||
|
|
||||||
$content = Ox.Element().css({margin: '16px'}),
|
|
||||||
|
|
||||||
$button = Ox.Button({
|
|
||||||
overlap: 'left',
|
|
||||||
title: Ox._('Preview'),
|
|
||||||
width: 128
|
|
||||||
})
|
|
||||||
.css({
|
|
||||||
marginLeft: '-20px',
|
|
||||||
paddingLeft: '20px',
|
|
||||||
position: 'absolute',
|
|
||||||
right: '16px',
|
|
||||||
top: '16px'
|
|
||||||
})
|
|
||||||
.bindEvent({
|
|
||||||
click: submitURL
|
|
||||||
})
|
|
||||||
.appendTo($content),
|
|
||||||
|
|
||||||
$input = Ox.Input({
|
|
||||||
label: Ox._('URL'),
|
|
||||||
labelWidth: 64,
|
|
||||||
width: 384
|
|
||||||
})
|
|
||||||
.css({
|
|
||||||
left: '16px',
|
|
||||||
position: 'absolute',
|
|
||||||
top: '16px'
|
|
||||||
})
|
|
||||||
.bindEvent({
|
|
||||||
change: submitURL
|
|
||||||
})
|
|
||||||
.appendTo($content),
|
|
||||||
|
|
||||||
$info = Ox.Element()
|
|
||||||
.css({
|
|
||||||
left: '16px',
|
|
||||||
position: 'absolute',
|
|
||||||
top: '48px'
|
|
||||||
})
|
|
||||||
.html(help)
|
|
||||||
.appendTo($content),
|
|
||||||
|
|
||||||
$loading = Ox.LoadingScreen({
|
|
||||||
width: 512,
|
|
||||||
height: 224
|
|
||||||
}),
|
|
||||||
|
|
||||||
that = Ox.Dialog({
|
|
||||||
buttons: [
|
|
||||||
Ox.Button({
|
|
||||||
id: 'close',
|
|
||||||
title: Ox._('Close')
|
|
||||||
})
|
|
||||||
.bindEvent({
|
|
||||||
click: function() {
|
|
||||||
that.close();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
Ox.Button({
|
|
||||||
disabled: true,
|
|
||||||
id: 'import',
|
|
||||||
title: Ox._('Import Video')
|
|
||||||
}).bindEvent({
|
|
||||||
click: importMedia
|
|
||||||
})
|
|
||||||
],
|
|
||||||
content: $content,
|
|
||||||
fixedSize: true,
|
|
||||||
height: 288,
|
|
||||||
keys: {
|
|
||||||
escape: 'close'
|
|
||||||
},
|
|
||||||
removeOnClose: true,
|
|
||||||
title: Ox._('Import Video'),
|
|
||||||
width: 544
|
|
||||||
});
|
|
||||||
|
|
||||||
function getMediaUrlInfo(url, callback) {
|
|
||||||
pandora.api.getMediaUrlInfo({url: url}, function(result) {
|
|
||||||
// FIXME: support playlists / multiple items
|
|
||||||
var info = result.data.items[0];
|
|
||||||
var infoKeys = [
|
|
||||||
'date', 'description', 'id', 'tags',
|
|
||||||
'title', 'uploader', 'url'
|
|
||||||
];
|
|
||||||
var values = Ox.map(pandora.site.importMetadata, function(value, key) {
|
|
||||||
var isArray = Ox.isArray(
|
|
||||||
Ox.getObjectById(pandora.site.itemKeys, key).type
|
|
||||||
);
|
|
||||||
if (isArray && value == '{tags}') {
|
|
||||||
value = info.tags;
|
|
||||||
} else {
|
|
||||||
infoKeys.forEach(function(infoKey) {
|
|
||||||
var infoValue = info[infoKey] || '';
|
|
||||||
if (key == 'year' && infoKey == 'date') {
|
|
||||||
infoValue = infoValue.substr(0, 4);
|
|
||||||
}
|
|
||||||
if (infoKey == 'tags') {
|
|
||||||
infoValue = infoValue.join(', ');
|
|
||||||
}
|
|
||||||
value = value.replace(
|
|
||||||
new RegExp('\{' + infoKey + '\}', 'g'), infoValue
|
|
||||||
);
|
|
||||||
});
|
|
||||||
// For example: director -> uploader
|
|
||||||
if (isArray) {
|
|
||||||
value = [value];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
});
|
|
||||||
callback(values, info)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function addMedia(url, callback) {
|
|
||||||
getMediaUrlInfo(url, function(values, info) {
|
|
||||||
pandora.api.add({title: values.title || info.title}, function(result) {
|
|
||||||
var edit = Ox.extend(
|
|
||||||
Ox.filter(values, function(value, key) {
|
|
||||||
return key != 'title';
|
|
||||||
}),
|
|
||||||
{'id': result.data.id}
|
|
||||||
);
|
|
||||||
pandora.api.edit(edit, function(result) {
|
|
||||||
pandora.api.addMediaUrl({
|
|
||||||
url: info.url,
|
|
||||||
referer: info.referer,
|
|
||||||
item: edit.id
|
|
||||||
}, function(result) {
|
|
||||||
if (result.data.taskId) {
|
|
||||||
pandora.wait(result.data.taskId, function(result) {
|
|
||||||
callback(edit.id);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
callback(edit.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function getInfo(url, callback) {
|
|
||||||
pandora.api.getMediaUrlInfo({url: url}, function(result) {
|
|
||||||
callback(result.data.items);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function importMedia() {
|
|
||||||
var url = $input.value();
|
|
||||||
$input.options({disabled: true});
|
|
||||||
$button.options({disabled: true});
|
|
||||||
$info.empty().append($loading.start());
|
|
||||||
that.disableButton('close');
|
|
||||||
that.disableButton('import');
|
|
||||||
addMedia(url, function(item) {
|
|
||||||
if (item) {
|
|
||||||
that.close();
|
|
||||||
Ox.Request.clearCache();
|
|
||||||
pandora.URL.push('/' + item + '/media');
|
|
||||||
} else {
|
|
||||||
$input.options({disabled: false});
|
|
||||||
$button.options({disabled: false});
|
|
||||||
$info.empty().html(Ox._('Import failed. Please try again'));
|
|
||||||
that.enableButton('close');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitURL() {
|
|
||||||
var value = $input.value();
|
|
||||||
if (value) {
|
|
||||||
$input.options({disabled: true});
|
|
||||||
$button.options({disabled: true});
|
|
||||||
$info.empty().append($loading.start());
|
|
||||||
that.disableButton('close');
|
|
||||||
getInfo(value, function(items) {
|
|
||||||
$input.options({disabled: false});
|
|
||||||
$button.options({disabled: false});
|
|
||||||
$loading.stop();
|
|
||||||
$info.empty();
|
|
||||||
if (items.length) {
|
|
||||||
// FIXME: support playlists / multiple items
|
|
||||||
var info = items[0];
|
|
||||||
info.thumbnail && $info.append($('<img>').css({
|
|
||||||
position: 'absolute',
|
|
||||||
width: '248px'
|
|
||||||
}).attr('src', info.thumbnail));
|
|
||||||
$info.append($('<div>').addClass('OxText').css({
|
|
||||||
height: '192px',
|
|
||||||
overflow: 'hidden',
|
|
||||||
position: 'absolute',
|
|
||||||
left: '264px',
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
width: '248px'
|
|
||||||
}).html(
|
|
||||||
'<span style="font-weight: bold">' + info.title
|
|
||||||
+ '</span><br/><br/>' + (info.description || '')
|
|
||||||
));
|
|
||||||
that.enableButton('import');
|
|
||||||
} else {
|
|
||||||
$info.html(help);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
that.enableButton('close');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return that;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
@ -361,11 +361,23 @@ pandora.ui.mainMenu = function() {
|
||||||
}
|
}
|
||||||
} else if (ui.section == 'documents') {
|
} else if (ui.section == 'documents') {
|
||||||
var items = pandora.clipboard.paste('document');
|
var items = pandora.clipboard.paste('document');
|
||||||
|
/*
|
||||||
items.length && pandora.doHistory('paste', items, ui._collection, function() {
|
items.length && pandora.doHistory('paste', items, ui._collection, function() {
|
||||||
//fixme:
|
pandora.UI.set({listSelection: items});
|
||||||
//pandora.UI.set({listSelection: items});
|
pandora.reloadList();
|
||||||
//pandora.reloadList();
|
pandora.UI.set({collectionSelection: items});
|
||||||
|
pandora.reloadList();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
if (items.length) {
|
||||||
|
pandora.api.addCollectionItems({
|
||||||
|
collection: ui._collection,
|
||||||
|
items: items
|
||||||
|
}, function() {
|
||||||
|
pandora.UI.set({collectionSelection: items});
|
||||||
|
pandora.reloadList();
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (ui.section == 'edits') {
|
} else if (ui.section == 'edits') {
|
||||||
var clips = pandora.clipboard.paste('clip');
|
var clips = pandora.clipboard.paste('clip');
|
||||||
clips.length && pandora.doHistory('paste', clips, ui.edit, function(result) {
|
clips.length && pandora.doHistory('paste', clips, ui.edit, function(result) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue