From df89abe6c2a1b3525b2a6421a5347ee7fa628698 Mon Sep 17 00:00:00 2001 From: rlx Date: Tue, 9 Aug 2016 15:46:23 +0200 Subject: [PATCH] fix import video dialog --- static/js/importMediaDialog.js | 35 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/static/js/importMediaDialog.js b/static/js/importMediaDialog.js index 7b8823f0..4ea21e3a 100644 --- a/static/js/importMediaDialog.js +++ b/static/js/importMediaDialog.js @@ -90,21 +90,28 @@ pandora.ui.importMediaDialog = function(options) { 'title', 'uploader', 'url' ]; var values = Ox.map(pandora.site.importMetadata, function(value, key) { - var type = Ox.getObjectById(pandora.site.itemKeys, key).type; - infoKeys.forEach(function(infoKey) { - var infoValue = info[infoKey]; - if (key == 'year' && infoKey == 'date') { - infoValue = infoValue.substr(0, 4); + 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]; } - if (infoKey == 'tags' && !Ox.isArray(type)) { - infoValue = infoValue.join(', '); - } - value = value.replace( - new RegExp('\{' + infoKey + '\}', 'g'), infoValue - ); - }); - if (Ox.isArray(type)) { - value = [value]; } return value; });