diff --git a/pandora/item/models.py b/pandora/item/models.py
index 0caa0a4f..04ec81dd 100644
--- a/pandora/item/models.py
+++ b/pandora/item/models.py
@@ -1614,15 +1614,8 @@ class Item(models.Model):
cmd += ['-l', timeline]
if 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.wait()
+ 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 69a76e0b..b2596015 100644
--- a/pandora/settings.py
+++ b/pandora/settings.py
@@ -264,7 +264,6 @@ 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 90558d63..bbe87b25 100644
--- a/static/js/editor.js
+++ b/static/js/editor.js
@@ -4,7 +4,6 @@ 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,
@@ -45,7 +44,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] || canEdit
+ editable: layer.canAddAnnotations[pandora.user.level]
}, layer, {
autocomplete: layer.type == 'entity'
? function(key, value, callback) {
diff --git a/static/js/importMediaDialog.js b/static/js/importMediaDialog.js
new file mode 100644
index 00000000..419aeb4e
--- /dev/null
+++ b/static/js/importMediaDialog.js
@@ -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($('').css({
+ position: 'absolute',
+ width: '248px'
+ }).attr('src', info.thumbnail));
+ $info.append($('