From 784bbbae73b109f1d8db410a6d5dfb84e0805416 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 3 Mar 2017 12:16:34 +0100 Subject: [PATCH] map imdb keyword to topic --- static/js/metadataDialog.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/static/js/metadataDialog.js b/static/js/metadataDialog.js index 3a60881b..ea316f2d 100644 --- a/static/js/metadataDialog.js +++ b/static/js/metadataDialog.js @@ -9,6 +9,9 @@ pandora.ui.metadataDialog = function(data) { 'producer', 'writer', 'cinematographer', 'editor', 'composer', 'actor', 'genre', 'keyword', 'summary' ], + mapKeys = { + 'keyword': 'topic' + }, updateKeys, dialogHeight = Math.round((window.innerHeight - 48) * 0.9), dialogWidth = Math.round(window.innerWidth * 0.9), @@ -156,7 +159,7 @@ pandora.ui.metadataDialog = function(data) { : key == 'runtime' ? Math.round(value / 60) + ' min' : key == 'productionCompany' ? value.join('; ') : Ox.isArray( - Ox.getObjectById(pandora.site.itemKeys, key).type + getItemKey(key).type ) ? value.join(', ') : value; } @@ -165,6 +168,14 @@ pandora.ui.metadataDialog = function(data) { return dialogWidth - 32 - Ox.UI.SCROLLBAR_SIZE; } + function getItemKey(key) { + return Ox.getObjectById(pandora.site.itemKeys, getKey(key)); + } + + function getKey(key) { + return mapKeys[key] || key; + } + function getMetadata() { pandora.api.getMetadata({ id: data.imdbId, @@ -279,7 +290,7 @@ pandora.ui.metadataDialog = function(data) { function getTitle(key) { return Ox._( key == 'alternativeTitles' ? 'Alternative Titles' - : Ox.getObjectById(pandora.site.itemKeys, key).title + : getItemKey(key).title ); } @@ -350,8 +361,8 @@ pandora.ui.metadataDialog = function(data) { var edit = {id: data.id}, type; updateKeys.forEach(function(key) { type = key == 'alternativeTitles' ? [] - : Ox.getObjectById(pandora.site.itemKeys, key).type; - edit[key] = imdb[key] || ( + : getItemKey(key).type; + edit[getKey(key)] = imdb[key] || ( Ox.isArray(type) ? [] : '' ); });