diff --git a/src/components/libraryoptionseditor/libraryoptionseditor.js b/src/components/libraryoptionseditor/libraryoptionseditor.js
index e364a957b9..bcb3a4edf8 100644
--- a/src/components/libraryoptionseditor/libraryoptionseditor.js
+++ b/src/components/libraryoptionseditor/libraryoptionseditor.js
@@ -323,6 +323,41 @@ function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType
return html;
}
+function getSimilarItemProvidersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
+ let html = '';
+ let plugins = availableTypeOptions.SimilarItemProviders;
+
+ plugins = getOrderedPlugins(plugins, libraryOptionsForType.SimilarItemProviderOrder || []);
+ if (!plugins.length) return html;
+
+ html += '
';
+ html += '
' + globalize.translate('HeaderTypeSimilarItemProviders', globalize.translate('TypeOptionPlural' + availableTypeOptions.Type)) + '
';
+ html += '
';
+
+ plugins.forEach((plugin, index) => {
+ html += '
';
+ const isChecked = libraryOptionsForType.SimilarItemProviders ? libraryOptionsForType.SimilarItemProviders.includes(plugin.Name) : plugin.DefaultEnabled;
+ const checkedHtml = isChecked ? ' checked="checked"' : '';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += escapeHtml(plugin.Name);
+ html += '
';
+ html += '';
+ if (index > 0) {
+ html += '
';
+ } else if (plugins.length > 1) {
+ html += '
';
+ }
+ html += '
';
+ });
+
+ html += '
';
+ html += '
' + globalize.translate('LabelSimilarItemProvidersHelp') + '
';
+ html += '
';
+ return html;
+}
+
function renderImageFetchers(page, availableOptions, libraryOptions) {
let html = '';
const elem = page.querySelector('.imageFetchers');
@@ -340,6 +375,21 @@ function renderImageFetchers(page, availableOptions, libraryOptions) {
return true;
}
+function renderSimilarItemProviders(page, availableOptions, libraryOptions) {
+ let html = '';
+ const elem = page.querySelector('.similarItemProviders');
+ for (const availableTypeOptions of availableOptions.TypeOptions) {
+ html += getSimilarItemProvidersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
+ }
+ elem.innerHTML = html;
+ if (html) {
+ elem.classList.remove('hide');
+ } else {
+ elem.classList.add('hide');
+ }
+ return true;
+}
+
function populateMetadataSettings(parent, contentType) {
const isNewLibrary = parent.classList.contains('newlibrary');
return ApiClient.getJSON(ApiClient.getUrl('Libraries/AvailableOptions', {
@@ -355,6 +405,7 @@ function populateMetadataSettings(parent, contentType) {
renderLyricFetchers(parent, availableOptions, {});
renderMediaSegmentProviders(parent, availableOptions, {});
renderImageFetchers(parent, availableOptions, {});
+ renderSimilarItemProviders(parent, availableOptions, {});
availableOptions.SubtitleFetchers.length ? parent.querySelector('.subtitleDownloadSettings').classList.remove('hide') : parent.querySelector('.subtitleDownloadSettings').classList.add('hide');
}).catch(() => {
return Promise.resolve();
@@ -432,6 +483,7 @@ function bindEvents(parent) {
parent.querySelector('.lyricFetchers').addEventListener('click', onSortableContainerClick);
parent.querySelector('.mediaSegmentProviders').addEventListener('click', onSortableContainerClick);
parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick);
+ parent.querySelector('.similarItemProviders').addEventListener('click', onSortableContainerClick);
parent.querySelector('#chkEnableEmbeddedTitles').addEventListener('change', (e) => {
parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.toggle('hide', !e.currentTarget.checked);
@@ -605,6 +657,30 @@ function setImageFetchersIntoOptions(parent, options) {
}
}
+function setSimilarItemProvidersIntoOptions(parent, options) {
+ const sections = parent.querySelectorAll('.similarItemProvider');
+ for (const section of sections) {
+ const type = section.getAttribute('data-type');
+ let typeOptions = getTypeOptions(options, type);
+ if (!typeOptions) {
+ typeOptions = {
+ Type: type
+ };
+ options.TypeOptions.push(typeOptions);
+ }
+
+ typeOptions.SimilarItemProviders = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkSimilarItemProvider'), elem => {
+ return elem.checked;
+ }), elem => {
+ return elem.getAttribute('data-pluginname');
+ });
+
+ typeOptions.SimilarItemProviderOrder = Array.prototype.map.call(section.querySelectorAll('.similarItemProviderItem'), elem => {
+ return elem.getAttribute('data-pluginname');
+ });
+ }
+}
+
function setImageOptionsIntoOptions(options) {
const originalTypeOptions = currentLibraryOptions?.TypeOptions || [];
for (const originalTypeOption of originalTypeOptions) {
@@ -674,6 +750,7 @@ export function getLibraryOptions(parent) {
setMediaSegmentProvidersIntoOptions(parent, options);
setMetadataFetchersIntoOptions(parent, options);
setImageFetchersIntoOptions(parent, options);
+ setSimilarItemProvidersIntoOptions(parent, options);
setImageOptionsIntoOptions(options);
return options;
@@ -731,6 +808,7 @@ export function setLibraryOptions(parent, options) {
renderMetadataReaders(parent, getOrderedPlugins(parent.availableOptions.MetadataReaders, options.LocalMetadataReaderOrder || []));
renderMetadataFetchers(parent, parent.availableOptions, options);
renderImageFetchers(parent, parent.availableOptions, options);
+ renderSimilarItemProviders(parent, parent.availableOptions, options);
renderSubtitleFetchers(parent, parent.availableOptions, options);
renderLyricFetchers(parent, parent.availableOptions, options);
renderMediaSegmentProviders(parent, parent.availableOptions, options);
diff --git a/src/components/libraryoptionseditor/libraryoptionseditor.template.html b/src/components/libraryoptionseditor/libraryoptionseditor.template.html
index f487bc482b..384559f092 100644
--- a/src/components/libraryoptionseditor/libraryoptionseditor.template.html
+++ b/src/components/libraryoptionseditor/libraryoptionseditor.template.html
@@ -96,6 +96,9 @@
+
+
+