fix import video dialog

This commit is contained in:
rlx 2016-08-09 15:46:23 +02:00
parent c3a4b227b7
commit df89abe6c2

View file

@ -90,21 +90,28 @@ pandora.ui.importMediaDialog = function(options) {
'title', 'uploader', 'url' 'title', 'uploader', 'url'
]; ];
var values = Ox.map(pandora.site.importMetadata, function(value, key) { var values = Ox.map(pandora.site.importMetadata, function(value, key) {
var type = Ox.getObjectById(pandora.site.itemKeys, key).type; var isArray = Ox.isArray(
infoKeys.forEach(function(infoKey) { Ox.getObjectById(pandora.site.itemKeys, key).type
var infoValue = info[infoKey]; );
if (key == 'year' && infoKey == 'date') { if (isArray && value == '{tags}') {
infoValue = infoValue.substr(0, 4); 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; return value;
}); });