keep originalTitle if config has originalTitle

This commit is contained in:
j 2018-09-12 17:03:41 +02:00
parent 2662a66aca
commit e0d6e7f162

View file

@ -29,7 +29,7 @@ pandora.ui.metadataDialog = function(data) {
that = data.imdbId ? updateDialog() : idDialog(); that = data.imdbId ? updateDialog() : idDialog();
keys = keys.filter(function(key) { keys = keys.filter(function(key) {
return key == 'alternativeTitles' || getItemKey(key); return Ox.contains(['alternativeTitles', 'filmingLocations'], key) || getItemKey(key);
}); });
data.imdbId && getMetadata(); data.imdbId && getMetadata();
@ -184,7 +184,7 @@ pandora.ui.metadataDialog = function(data) {
function getMetadata() { function getMetadata() {
pandora.api.getMetadata({ pandora.api.getMetadata({
id: data.imdbId, id: data.imdbId,
keys: keys.concat(['originalTitle']) keys: Ox.unique(keys.concat(['originalTitle']))
}, function(result) { }, function(result) {
var $bar = Ox.Bar({size: 24}), var $bar = Ox.Bar({size: 24}),
$data = Ox.Element() $data = Ox.Element()
@ -218,10 +218,12 @@ pandora.ui.metadataDialog = function(data) {
.appendTo($bar); .appendTo($bar);
if (result.data) { if (result.data) {
imdb = Ox.clone(result.data, true); imdb = Ox.clone(result.data, true);
if (!Ox.contains(keys, 'originalTitle')) {
if (imdb.originalTitle) { if (imdb.originalTitle) {
imdb.alternativeTitles = [[imdb.title, []]].concat(imdb.alternativeTitles || []); imdb.alternativeTitles = [[imdb.title, []]].concat(imdb.alternativeTitles || []);
imdb.title = imdb.originalTitle; imdb.title = imdb.originalTitle;
} }
}
keys.forEach(function(key, index) { keys.forEach(function(key, index) {
var isEqual = Ox.isEqual(data[getKey(key)], imdb[key]) || ( var isEqual = Ox.isEqual(data[getKey(key)], imdb[key]) || (
isEmpty(data[getKey(key)]) && isEmpty(imdb[key]) isEmpty(data[getKey(key)]) && isEmpty(imdb[key])