2014-07-21 18:29:06 -07:00
|
|
|
|
(function (window, $) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
function loadAdvancedConfig(page, config) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-05 21:21:23 -07:00
|
|
|
|
$('#chkSaveMetadataHidden', page).checked(config.SaveMetadataHidden).checkboxradio("refresh");
|
|
|
|
|
|
2014-09-22 14:56:54 -07:00
|
|
|
|
$('#chkFindTrailers', page).checked(config.FindInternetTrailers).checkboxradio("refresh");
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
$('#chkEnableTmdbPersonUpdates', page).checked(config.EnableTmdbUpdates).checkboxradio("refresh");
|
|
|
|
|
$('#chkEnableTvdbUpdates', page).checked(config.EnableTvDbUpdates).checkboxradio("refresh");
|
|
|
|
|
$('#chkEnableFanartUpdates', page).checked(config.EnableFanArtUpdates).checkboxradio("refresh");
|
|
|
|
|
$('#txtMetadataPath', page).val(config.MetadataPath || '');
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
$('#chkPeopleActors', page).checked(config.PeopleMetadataOptions.DownloadActorMetadata).checkboxradio("refresh");
|
|
|
|
|
$('#chkPeopleComposers', page).checked(config.PeopleMetadataOptions.DownloadComposerMetadata).checkboxradio("refresh");
|
|
|
|
|
$('#chkPeopleDirectors', page).checked(config.PeopleMetadataOptions.DownloadDirectorMetadata).checkboxradio("refresh");
|
|
|
|
|
$('#chkPeopleProducers', page).checked(config.PeopleMetadataOptions.DownloadProducerMetadata).checkboxradio("refresh");
|
|
|
|
|
$('#chkPeopleWriters', page).checked(config.PeopleMetadataOptions.DownloadWriterMetadata).checkboxradio("refresh");
|
|
|
|
|
$('#chkPeopleOthers', page).checked(config.PeopleMetadataOptions.DownloadOtherPeopleMetadata).checkboxradio("refresh");
|
|
|
|
|
$('#chkPeopleGuestStars', page).checked(config.PeopleMetadataOptions.DownloadGuestStarMetadata).checkboxradio("refresh");
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-10-09 15:22:04 -07:00
|
|
|
|
function loadMetadataConfig(page, config) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#selectDateAdded', page).val((config.UseFileCreationTimeForDateAdded ? '1' : '0')).selectmenu("refresh");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
function loadChapters(page, config, providers) {
|
|
|
|
|
|
|
|
|
|
if (providers.length) {
|
|
|
|
|
$('.noChapterProviders', page).hide();
|
|
|
|
|
$('.chapterDownloadSettings', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.noChapterProviders', page).show();
|
|
|
|
|
$('.chapterDownloadSettings', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#chkChaptersMovies', page).checked(config.EnableMovieChapterImageExtraction).checkboxradio("refresh");
|
|
|
|
|
$('#chkChaptersEpisodes', page).checked(config.EnableEpisodeChapterImageExtraction).checkboxradio("refresh");
|
|
|
|
|
$('#chkChaptersOtherVideos', page).checked(config.EnableOtherVideoChapterImageExtraction).checkboxradio("refresh");
|
|
|
|
|
|
|
|
|
|
$('#chkDownloadChapterMovies', page).checked(config.DownloadMovieChapters).checkboxradio("refresh");
|
|
|
|
|
$('#chkDownloadChapterEpisodes', page).checked(config.DownloadEpisodeChapters).checkboxradio("refresh");
|
|
|
|
|
|
2014-09-08 18:15:31 -07:00
|
|
|
|
$('#chkExtractChaptersDuringLibraryScan', page).checked(config.ExtractDuringLibraryScan).checkboxradio("refresh");
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
renderChapterFetchers(page, config, providers);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderChapterFetchers(page, config, plugins) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (!plugins.length) {
|
|
|
|
|
$('.chapterFetchers', page).html(html).hide().trigger('create');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var i, length, plugin, id;
|
|
|
|
|
|
|
|
|
|
html += '<div class="ui-controlgroup-label" style="margin-bottom:0;padding-left:2px;">';
|
|
|
|
|
html += Globalize.translate('LabelChapterDownloaders');
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div style="display:inline-block;width: 75%;vertical-align:top;">';
|
|
|
|
|
html += '<div data-role="controlgroup" class="chapterFetcherGroup">';
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = plugins.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
plugin = plugins[i];
|
|
|
|
|
|
|
|
|
|
id = 'chkChapterFetcher' + i;
|
|
|
|
|
|
|
|
|
|
var isChecked = config.DisabledFetchers.indexOf(plugin.Name) == -1 ? ' checked="checked"' : '';
|
|
|
|
|
|
|
|
|
|
html += '<input class="chkChapterFetcher" type="checkbox" name="' + id + '" id="' + id + '" data-pluginname="' + plugin.Name + '" data-mini="true"' + isChecked + '>';
|
|
|
|
|
html += '<label for="' + id + '">' + plugin.Name + '</label>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
if (plugins.length > 1) {
|
|
|
|
|
html += '<div style="display:inline-block;vertical-align:top;margin-left:5px;">';
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = plugins.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
html += '<div style="margin:6px 0;">';
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
html += '<button data-inline="true" disabled="disabled" class="btnUp" data-pluginindex="' + i + '" type="button" data-icon="arrow-u" data-mini="true" data-iconpos="notext" style="margin: 0 1px;">Up</button>';
|
|
|
|
|
html += '<button data-inline="true" class="btnDown" data-pluginindex="' + i + '" type="button" data-icon="arrow-d" data-mini="true" data-iconpos="notext" style="margin: 0 1px;">Down</button>';
|
|
|
|
|
} else if (i == (plugins.length - 1)) {
|
|
|
|
|
html += '<button data-inline="true" class="btnUp" data-pluginindex="' + i + '" type="button" data-icon="arrow-u" data-mini="true" data-iconpos="notext" style="margin: 0 1px;">Up</button>';
|
|
|
|
|
html += '<button data-inline="true" disabled="disabled" class="btnDown" data-pluginindex="' + i + '" type="button" data-icon="arrow-d" data-mini="true" data-iconpos="notext" style="margin: 0 1px;">Down</button>';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += '<button data-inline="true" class="btnUp" data-pluginindex="' + i + '" type="button" data-icon="arrow-u" data-mini="true" data-iconpos="notext" style="margin: 0 1px;">Up</button>';
|
|
|
|
|
html += '<button data-inline="true" class="btnDown" data-pluginindex="' + i + '" type="button" data-icon="arrow-d" data-mini="true" data-iconpos="notext" style="margin: 0 1px;">Down</button>';
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="fieldDescription">' + Globalize.translate('LabelChapterDownloadersHelp') + '</div>';
|
|
|
|
|
|
|
|
|
|
var elem = $('.chapterFetchers', page).html(html).show().trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnDown', elem).on('click', function () {
|
|
|
|
|
var index = parseInt(this.getAttribute('data-pluginindex'));
|
|
|
|
|
|
|
|
|
|
var elemToMove = $('.chapterFetcherGroup .ui-checkbox', page)[index];
|
|
|
|
|
|
|
|
|
|
var insertAfter = $(elemToMove).next('.ui-checkbox')[0];
|
|
|
|
|
|
|
|
|
|
elemToMove.parentNode.removeChild(elemToMove);
|
|
|
|
|
$(elemToMove).insertAfter(insertAfter);
|
|
|
|
|
|
|
|
|
|
$('.chapterFetcherGroup', page).controlgroup('destroy').controlgroup();
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
$('.btnUp', elem).on('click', function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
var index = parseInt(this.getAttribute('data-pluginindex'));
|
|
|
|
|
|
|
|
|
|
var elemToMove = $('.chapterFetcherGroup .ui-checkbox', page)[index];
|
|
|
|
|
|
|
|
|
|
var insertBefore = $(elemToMove).prev('.ui-checkbox')[0];
|
|
|
|
|
|
|
|
|
|
elemToMove.parentNode.removeChild(elemToMove);
|
|
|
|
|
$(elemToMove).insertBefore(insertBefore);
|
|
|
|
|
|
|
|
|
|
$('.chapterFetcherGroup', page).controlgroup('destroy').controlgroup();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
});
|
2014-07-21 18:29:06 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
$(document).on('pageinit', "#advancedMetadataConfigurationPage", function () {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('#btnSelectMetadataPath', page).on("click.selectDirectory", function () {
|
|
|
|
|
|
|
|
|
|
var picker = new DirectoryBrowser(page);
|
|
|
|
|
|
|
|
|
|
picker.show({
|
|
|
|
|
|
|
|
|
|
callback: function (path) {
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
$('#txtMetadataPath', page).val(path);
|
|
|
|
|
}
|
|
|
|
|
picker.close();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
header: Globalize.translate('HeaderSelectMetadataPath'),
|
|
|
|
|
|
|
|
|
|
instruction: Globalize.translate('HeaderSelectMetadataPathHelp')
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
}).on('pageshow', "#advancedMetadataConfigurationPage", function () {
|
2013-12-17 21:39:44 -07:00
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
var page = this;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
ApiClient.getServerConfiguration().done(function (configuration) {
|
|
|
|
|
|
|
|
|
|
loadAdvancedConfig(page, configuration);
|
|
|
|
|
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-10-09 15:22:04 -07:00
|
|
|
|
ApiClient.getNamedConfiguration("metadata").done(function (metadata) {
|
|
|
|
|
|
|
|
|
|
loadMetadataConfig(page, metadata);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
var promise1 = ApiClient.getNamedConfiguration("chapters");
|
|
|
|
|
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Providers/Chapters"));
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
$.when(promise1, promise2).done(function (response1, response2) {
|
|
|
|
|
|
|
|
|
|
loadChapters(page, response1[0], response2[0]);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function saveAdvancedConfig(form) {
|
2013-04-16 21:58:32 -07:00
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
ApiClient.getServerConfiguration().done(function (config) {
|
|
|
|
|
|
2014-09-05 21:21:23 -07:00
|
|
|
|
config.SaveMetadataHidden = $('#chkSaveMetadataHidden', form).checked();
|
|
|
|
|
|
2014-09-22 14:56:54 -07:00
|
|
|
|
config.FindInternetTrailers = $('#chkFindTrailers', form).checked();
|
2013-12-17 21:39:44 -07:00
|
|
|
|
config.EnableTvDbUpdates = $('#chkEnableTvdbUpdates', form).checked();
|
|
|
|
|
config.EnableTmdbUpdates = $('#chkEnableTmdbPersonUpdates', form).checked();
|
2014-01-30 21:50:09 -07:00
|
|
|
|
config.EnableFanArtUpdates = $('#chkEnableFanartUpdates', form).checked();
|
2014-07-19 21:46:29 -07:00
|
|
|
|
config.MetadataPath = $('#txtMetadataPath', form).val();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
config.PeopleMetadataOptions.DownloadActorMetadata = $('#chkPeopleActors', form).checked();
|
|
|
|
|
config.PeopleMetadataOptions.DownloadComposerMetadata = $('#chkPeopleComposers', form).checked();
|
|
|
|
|
config.PeopleMetadataOptions.DownloadDirectorMetadata = $('#chkPeopleDirectors', form).checked();
|
|
|
|
|
config.PeopleMetadataOptions.DownloadGuestStarMetadata = $('#chkPeopleGuestStars', form).checked();
|
|
|
|
|
config.PeopleMetadataOptions.DownloadProducerMetadata = $('#chkPeopleProducers', form).checked();
|
|
|
|
|
config.PeopleMetadataOptions.DownloadWriterMetadata = $('#chkPeopleWriters', form).checked();
|
|
|
|
|
config.PeopleMetadataOptions.DownloadOtherPeopleMetadata = $('#chkPeopleOthers', form).checked();
|
|
|
|
|
|
2013-04-16 21:58:32 -07:00
|
|
|
|
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
});
|
2014-07-21 18:29:06 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-10-09 15:22:04 -07:00
|
|
|
|
function saveMetadata(form) {
|
|
|
|
|
|
|
|
|
|
ApiClient.getNamedConfiguration("metadata").done(function (config) {
|
|
|
|
|
|
|
|
|
|
config.UseFileCreationTimeForDateAdded = $('#selectDateAdded', form).val() == '1';
|
|
|
|
|
|
|
|
|
|
ApiClient.updateNamedConfiguration("metadata", config);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
function saveChapters(form) {
|
|
|
|
|
|
|
|
|
|
ApiClient.getNamedConfiguration("chapters").done(function (config) {
|
|
|
|
|
|
|
|
|
|
config.EnableMovieChapterImageExtraction = $('#chkChaptersMovies', form).checked();
|
|
|
|
|
config.EnableEpisodeChapterImageExtraction = $('#chkChaptersEpisodes', form).checked();
|
|
|
|
|
config.EnableOtherVideoChapterImageExtraction = $('#chkChaptersOtherVideos', form).checked();
|
|
|
|
|
|
|
|
|
|
config.DownloadMovieChapters = $('#chkDownloadChapterMovies', form).checked();
|
|
|
|
|
config.DownloadEpisodeChapters = $('#chkDownloadChapterEpisodes', form).checked();
|
2014-09-08 18:15:31 -07:00
|
|
|
|
config.ExtractDuringLibraryScan = $('#chkExtractChaptersDuringLibraryScan', form).checked();
|
2014-07-21 18:29:06 -07:00
|
|
|
|
|
|
|
|
|
config.DisabledFetchers = $('.chkChapterFetcher:not(:checked)', form).get().map(function (c) {
|
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
config.FetcherOrder = $('.chkChapterFetcher', form).get().map(function (c) {
|
|
|
|
|
|
|
|
|
|
return c.getAttribute('data-pluginname');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ApiClient.updateNamedConfiguration("chapters", config);
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 18:29:06 -07:00
|
|
|
|
window.AdvancedMetadataConfigurationPage = {
|
|
|
|
|
|
|
|
|
|
onSubmit: function () {
|
|
|
|
|
var form = this;
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
saveAdvancedConfig(form);
|
|
|
|
|
saveChapters(form);
|
2014-10-09 15:22:04 -07:00
|
|
|
|
saveMetadata(form);
|
2014-07-21 18:29:06 -07:00
|
|
|
|
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(window, jQuery);
|
|
|
|
|
|