forked from 0x2620/pandora
fix import video dialog
This commit is contained in:
parent
c3a4b227b7
commit
df89abe6c2
1 changed files with 21 additions and 14 deletions
|
@ -90,22 +90,29 @@ 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;
|
||||
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' && !Ox.isArray(type)) {
|
||||
if (infoKey == 'tags') {
|
||||
infoValue = infoValue.join(', ');
|
||||
}
|
||||
value = value.replace(
|
||||
new RegExp('\{' + infoKey + '\}', 'g'), infoValue
|
||||
);
|
||||
});
|
||||
if (Ox.isArray(type)) {
|
||||
// For example: director -> uploader
|
||||
if (isArray) {
|
||||
value = [value];
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
pandora.api.add({title: values.title || info.title}, function(result) {
|
||||
|
|
Loading…
Reference in a new issue