diff --git a/pandora/item/models.py b/pandora/item/models.py index 04ec81dd..0caa0a4f 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1614,8 +1614,15 @@ class Item(models.Model): cmd += ['-l', timeline] if frame: cmd += ['-f', frame] - p = subprocess.Popen(cmd, close_fds=True) - p.wait() + 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.wait() # remove cached versions icon = os.path.abspath(os.path.join(settings.MEDIA_ROOT, icon)) for f in glob(icon.replace('.jpg', '*.jpg')): diff --git a/pandora/settings.py b/pandora/settings.py index b2596015..69a76e0b 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -264,6 +264,7 @@ SCRIPT_ROOT = normpath(join(PROJECT_ROOT, '..', 'scripts')) #change script to customize ITEM_POSTER = join(SCRIPT_ROOT, 'poster.py') ITEM_ICON = join(SCRIPT_ROOT, 'item_icon.py') +ITEM_ICON_DATA = False LIST_ICON = join(SCRIPT_ROOT, 'list_icon.py') COLLECTION_ICON = join(SCRIPT_ROOT, 'list_icon.py') diff --git a/static/js/editor.js b/static/js/editor.js index bbe87b25..90558d63 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -4,6 +4,7 @@ pandora.ui.editor = function(data) { var ui = pandora.user.ui, rightsLevel = data.rightslevel, + canEdit = pandora.hasCapability('canEditMetadata') || data.editable, that = Ox.VideoAnnotationPanel({ annotationsCalendarSize: ui.annotationsCalendarSize, @@ -44,7 +45,7 @@ pandora.ui.editor = function(data) { itemName: pandora.site.itemName, layers: data.annotations.map(function(layer) { return Ox.extend({ - editable: layer.canAddAnnotations[pandora.user.level] + editable: layer.canAddAnnotations[pandora.user.level] || canEdit }, layer, { autocomplete: layer.type == 'entity' ? function(key, value, callback) { diff --git a/static/js/importMediaDialog.js b/static/js/importMediaDialog.js deleted file mode 100644 index 419aeb4e..00000000 --- a/static/js/importMediaDialog.js +++ /dev/null @@ -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($('').css({ - position: 'absolute', - width: '248px' - }).attr('src', info.thumbnail)); - $info.append($('
').addClass('OxText').css({ - height: '192px', - overflow: 'hidden', - position: 'absolute', - left: '264px', - textOverflow: 'ellipsis', - width: '248px' - }).html( - '' + info.title - + '

' + (info.description || '') - )); - that.enableButton('import'); - } else { - $info.html(help); - } - }); - that.enableButton('close'); - } - } - - return that; - -}; diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index 9ff8a94e..30ead365 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -361,11 +361,23 @@ pandora.ui.mainMenu = function() { } } else if (ui.section == 'documents') { var items = pandora.clipboard.paste('document'); + /* items.length && pandora.doHistory('paste', items, ui._collection, function() { - //fixme: - //pandora.UI.set({listSelection: items}); - //pandora.reloadList(); + pandora.UI.set({listSelection: items}); + 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') { var clips = pandora.clipboard.paste('clip'); clips.length && pandora.doHistory('paste', clips, ui.edit, function(result) {