Compare commits
No commits in common. "166b566fde617716cd514cbd087ba6dde84f2f7c" and "86bb19b9b605752c201d79b82bdcac2d9fc237f3" have entirely different histories.
166b566fde
...
86bb19b9b6
5 changed files with 225 additions and 27 deletions
|
|
@ -1614,13 +1614,6 @@ class Item(models.Model):
|
||||||
cmd += ['-l', timeline]
|
cmd += ['-l', timeline]
|
||||||
if frame:
|
if frame:
|
||||||
cmd += ['-f', frame]
|
cmd += ['-f', frame]
|
||||||
if settings.ITEM_POSTER_DATA:
|
|
||||||
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 = subprocess.Popen(cmd, close_fds=True)
|
||||||
p.wait()
|
p.wait()
|
||||||
# remove cached versions
|
# remove cached versions
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,6 @@ 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,7 +4,6 @@ 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,
|
||||||
|
|
@ -45,7 +44,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] || canEdit
|
editable: layer.canAddAnnotations[pandora.user.level]
|
||||||
}, layer, {
|
}, layer, {
|
||||||
autocomplete: layer.type == 'entity'
|
autocomplete: layer.type == 'entity'
|
||||||
? function(key, value, callback) {
|
? function(key, value, callback) {
|
||||||
|
|
|
||||||
219
static/js/importMediaDialog.js
Normal file
219
static/js/importMediaDialog.js
Normal file
|
|
@ -0,0 +1,219 @@
|
||||||
|
'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,23 +361,11 @@ 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() {
|
||||||
pandora.UI.set({listSelection: items});
|
//fixme:
|
||||||
pandora.reloadList();
|
//pandora.UI.set({listSelection: items});
|
||||||
pandora.UI.set({collectionSelection: items});
|
//pandora.reloadList();
|
||||||
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