';
- html += '
' + globalize.translate('HeaderTypeImageFetchers', globalize.translate('TypeOptionPlural' + availableTypeOptions.Type)) + ' ';
- const supportedImageTypes = availableTypeOptions.SupportedImageTypes || [];
- if (supportedImageTypes.length > 1 || supportedImageTypes.length === 1 && supportedImageTypes[0] !== 'Primary') {
- html += '
' + globalize.translate('HeaderFetcherSettings') + ' ';
+ let plugins = availableOptions.SubtitleFetchers;
+ plugins = getOrderedPlugins(plugins, libraryOptions.SubtitleFetcherOrder || []);
+ if (!plugins.length) return html;
+
+ html += `
${globalize.translate('LabelSubtitleDownloaders')} `;
+ html += '
';
+ for (let i = 0; i < plugins.length; i++) {
+ const plugin = plugins[i];
+ html += `
`;
+ const isChecked = libraryOptions.DisabledSubtitleFetchers ? !libraryOptions.DisabledSubtitleFetchers.includes(plugin.Name) : plugin.DefaultEnabled;
+ const checkedHtml = isChecked ? ' checked="checked"' : '';
+ html += `
`;
+ html += '
';
+ html += '
';
+ html += escapeHtml(plugin.Name);
+ html += ' ';
+ html += '';
+ if (i > 0) {
+ html += `
`;
+ } else if (plugins.length > 1) {
+ html += `
`;
}
html += '
';
- html += '
';
- for (let i = 0; i < plugins.length; i++) {
- const plugin = plugins[i];
- html += '
';
- const isChecked = libraryOptionsForType.ImageFetchers ? libraryOptionsForType.ImageFetchers.includes(plugin.Name) : plugin.DefaultEnabled;
- const checkedHtml = isChecked ? ' checked="checked"' : '';
- html += '
';
- html += '
';
- html += '
';
- html += escapeHtml(plugin.Name);
- html += ' ';
- html += '';
- if (i > 0) {
- html += '
';
- } else if (plugins.length > 1) {
- html += '
';
- }
- html += '
';
+ }
+ html += '
';
+ html += `
${globalize.translate('SubtitleDownloadersHelp')}
`;
+ elem.innerHTML = html;
+}
+
+function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
+ let html = '';
+ let plugins = availableTypeOptions.ImageFetchers;
+
+ plugins = getOrderedPlugins(plugins, libraryOptionsForType.ImageFetcherOrder || []);
+ if (!plugins.length) return html;
+
+ html += '
';
+ html += '
';
+ html += '
' + globalize.translate('HeaderTypeImageFetchers', globalize.translate('TypeOptionPlural' + availableTypeOptions.Type)) + ' ';
+ const supportedImageTypes = availableTypeOptions.SupportedImageTypes || [];
+ if (supportedImageTypes.length > 1 || supportedImageTypes.length === 1 && supportedImageTypes[0] !== 'Primary') {
+ html += '' + globalize.translate('HeaderFetcherSettings') + ' ';
+ }
+ html += '';
+ html += '
';
+ for (let i = 0; i < plugins.length; i++) {
+ const plugin = plugins[i];
+ html += '
';
+ const isChecked = libraryOptionsForType.ImageFetchers ? libraryOptionsForType.ImageFetchers.includes(plugin.Name) : plugin.DefaultEnabled;
+ const checkedHtml = isChecked ? ' checked="checked"' : '';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += escapeHtml(plugin.Name);
+ html += ' ';
+ html += '';
+ if (i > 0) {
+ html += '
';
+ } else if (plugins.length > 1) {
+ html += '
';
}
html += '
';
- html += '
' + globalize.translate('LabelImageFetchersHelp') + '
';
- html += '
';
- return html;
}
+ html += '
';
+ html += '
' + globalize.translate('LabelImageFetchersHelp') + '
';
+ html += '
';
+ return html;
+}
- function renderImageFetchers(page, availableOptions, libraryOptions) {
- let html = '';
- const elem = page.querySelector('.imageFetchers');
- for (let i = 0; i < availableOptions.TypeOptions.length; i++) {
- const availableTypeOptions = availableOptions.TypeOptions[i];
- html += getImageFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
+function renderImageFetchers(page, availableOptions, libraryOptions) {
+ let html = '';
+ const elem = page.querySelector('.imageFetchers');
+ for (let i = 0; i < availableOptions.TypeOptions.length; i++) {
+ const availableTypeOptions = availableOptions.TypeOptions[i];
+ html += getImageFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
+ }
+ elem.innerHTML = html;
+ if (html) {
+ elem.classList.remove('hide');
+ page.querySelector('.chkSaveLocalContainer').classList.remove('hide');
+ } else {
+ elem.classList.add('hide');
+ page.querySelector('.chkSaveLocalContainer').classList.add('hide');
+ }
+ return true;
+}
+
+function populateMetadataSettings(parent, contentType) {
+ const isNewLibrary = parent.classList.contains('newlibrary');
+ return ApiClient.getJSON(ApiClient.getUrl('Libraries/AvailableOptions', {
+ LibraryContentType: contentType,
+ IsNewLibrary: isNewLibrary
+ })).then(availableOptions => {
+ currentAvailableOptions = availableOptions;
+ parent.availableOptions = availableOptions;
+ renderMetadataSavers(parent, availableOptions.MetadataSavers);
+ renderMetadataReaders(parent, availableOptions.MetadataReaders);
+ renderMetadataFetchers(parent, availableOptions, {});
+ renderSubtitleFetchers(parent, availableOptions, {});
+ renderImageFetchers(parent, availableOptions, {});
+ availableOptions.SubtitleFetchers.length ? parent.querySelector('.subtitleDownloadSettings').classList.remove('hide') : parent.querySelector('.subtitleDownloadSettings').classList.add('hide');
+ }).catch(() => {
+ return Promise.resolve();
+ });
+}
+
+function adjustSortableListElement(elem) {
+ const btnSortable = elem.querySelector('.btnSortable');
+ const inner = btnSortable.querySelector('.material-icons');
+ if (elem.previousSibling) {
+ btnSortable.title = globalize.translate('Up');
+ btnSortable.classList.add('btnSortableMoveUp');
+ btnSortable.classList.remove('btnSortableMoveDown');
+ inner.classList.remove('keyboard_arrow_down');
+ inner.classList.add('keyboard_arrow_up');
+ } else {
+ btnSortable.title = globalize.translate('Down');
+ btnSortable.classList.remove('btnSortableMoveUp');
+ btnSortable.classList.add('btnSortableMoveDown');
+ inner.classList.remove('keyboard_arrow_up');
+ inner.classList.add('keyboard_arrow_down');
+ }
+}
+
+function showImageOptionsForType(type) {
+ import('../imageOptionsEditor/imageOptionsEditor').then(({ default: ImageOptionsEditor }) => {
+ let typeOptions = getTypeOptions(currentLibraryOptions, type);
+ if (!typeOptions) {
+ typeOptions = {
+ Type: type
+ };
+ currentLibraryOptions.TypeOptions.push(typeOptions);
}
- elem.innerHTML = html;
- if (html) {
- elem.classList.remove('hide');
- page.querySelector('.chkSaveLocalContainer').classList.remove('hide');
- } else {
- elem.classList.add('hide');
- page.querySelector('.chkSaveLocalContainer').classList.add('hide');
- }
- return true;
- }
+ const availableOptions = getTypeOptions(currentAvailableOptions || {}, type);
+ const imageOptionsEditor = new ImageOptionsEditor();
+ imageOptionsEditor.show(type, typeOptions, availableOptions);
+ });
+}
- function populateMetadataSettings(parent, contentType) {
- const isNewLibrary = parent.classList.contains('newlibrary');
- return ApiClient.getJSON(ApiClient.getUrl('Libraries/AvailableOptions', {
- LibraryContentType: contentType,
- IsNewLibrary: isNewLibrary
- })).then(availableOptions => {
- currentAvailableOptions = availableOptions;
- parent.availableOptions = availableOptions;
- renderMetadataSavers(parent, availableOptions.MetadataSavers);
- renderMetadataReaders(parent, availableOptions.MetadataReaders);
- renderMetadataFetchers(parent, availableOptions, {});
- renderSubtitleFetchers(parent, availableOptions, {});
- renderImageFetchers(parent, availableOptions, {});
- availableOptions.SubtitleFetchers.length ? parent.querySelector('.subtitleDownloadSettings').classList.remove('hide') : parent.querySelector('.subtitleDownloadSettings').classList.add('hide');
- }).catch(() => {
- return Promise.resolve();
- });
+function onImageFetchersContainerClick(e) {
+ const btnImageOptionsForType = dom.parentWithClass(e.target, 'btnImageOptionsForType');
+ if (btnImageOptionsForType) {
+ showImageOptionsForType(dom.parentWithClass(btnImageOptionsForType, 'imageFetcher').getAttribute('data-type'));
+ return;
}
+ onSortableContainerClick.call(this, e);
+}
- function adjustSortableListElement(elem) {
- const btnSortable = elem.querySelector('.btnSortable');
- const inner = btnSortable.querySelector('.material-icons');
- if (elem.previousSibling) {
- btnSortable.title = globalize.translate('Up');
- btnSortable.classList.add('btnSortableMoveUp');
- btnSortable.classList.remove('btnSortableMoveDown');
- inner.classList.remove('keyboard_arrow_down');
- inner.classList.add('keyboard_arrow_up');
- } else {
- btnSortable.title = globalize.translate('Down');
- btnSortable.classList.remove('btnSortableMoveUp');
- btnSortable.classList.add('btnSortableMoveDown');
- inner.classList.remove('keyboard_arrow_up');
- inner.classList.add('keyboard_arrow_down');
- }
- }
-
- function showImageOptionsForType(type) {
- import('../imageOptionsEditor/imageOptionsEditor').then(({ default: ImageOptionsEditor }) => {
- let typeOptions = getTypeOptions(currentLibraryOptions, type);
- if (!typeOptions) {
- typeOptions = {
- Type: type
- };
- currentLibraryOptions.TypeOptions.push(typeOptions);
+function onSortableContainerClick(e) {
+ const btnSortable = dom.parentWithClass(e.target, 'btnSortable');
+ if (btnSortable) {
+ const li = dom.parentWithClass(btnSortable, 'sortableOption');
+ const list = dom.parentWithClass(li, 'paperList');
+ if (btnSortable.classList.contains('btnSortableMoveDown')) {
+ const next = li.nextSibling;
+ if (next) {
+ li.parentNode.removeChild(li);
+ next.parentNode.insertBefore(li, next.nextSibling);
}
- const availableOptions = getTypeOptions(currentAvailableOptions || {}, type);
- const imageOptionsEditor = new ImageOptionsEditor();
- imageOptionsEditor.show(type, typeOptions, availableOptions);
- });
- }
-
- function onImageFetchersContainerClick(e) {
- const btnImageOptionsForType = dom.parentWithClass(e.target, 'btnImageOptionsForType');
- if (btnImageOptionsForType) {
- showImageOptionsForType(dom.parentWithClass(btnImageOptionsForType, 'imageFetcher').getAttribute('data-type'));
- return;
- }
- onSortableContainerClick.call(this, e);
- }
-
- function onSortableContainerClick(e) {
- const btnSortable = dom.parentWithClass(e.target, 'btnSortable');
- if (btnSortable) {
- const li = dom.parentWithClass(btnSortable, 'sortableOption');
- const list = dom.parentWithClass(li, 'paperList');
- if (btnSortable.classList.contains('btnSortableMoveDown')) {
- const next = li.nextSibling;
- if (next) {
- li.parentNode.removeChild(li);
- next.parentNode.insertBefore(li, next.nextSibling);
- }
- } else {
- const prev = li.previousSibling;
- if (prev) {
- li.parentNode.removeChild(li);
- prev.parentNode.insertBefore(li, prev);
- }
- }
- Array.prototype.forEach.call(list.querySelectorAll('.sortableOption'), adjustSortableListElement);
- }
- }
-
- function bindEvents(parent) {
- parent.querySelector('.metadataReaders').addEventListener('click', onSortableContainerClick);
- parent.querySelector('.subtitleFetchers').addEventListener('click', onSortableContainerClick);
- parent.querySelector('.metadataFetchers').addEventListener('click', onSortableContainerClick);
- parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick);
-
- parent.querySelector('#chkEnableEmbeddedTitles').addEventListener('change', (e) => {
- parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.toggle('hide', !e.currentTarget.checked);
- });
- }
-
- export async function embed(parent, contentType, libraryOptions) {
- currentLibraryOptions = {
- TypeOptions: []
- };
- currentAvailableOptions = null;
- const isNewLibrary = libraryOptions === null;
- isNewLibrary && parent.classList.add('newlibrary');
-
- parent.innerHTML = globalize.translateHtml(template);
- populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
- const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];
- Promise.all(promises).then(function() {
- return setContentType(parent, contentType).then(function() {
- libraryOptions && setLibraryOptions(parent, libraryOptions);
- bindEvents(parent);
- });
- });
- }
-
- export function setContentType(parent, contentType) {
- if (contentType === 'homevideos' || contentType === 'photos') {
- parent.querySelector('.chkEnablePhotosContainer').classList.remove('hide');
} else {
- parent.querySelector('.chkEnablePhotosContainer').classList.add('hide');
- }
-
- if (contentType !== 'tvshows' && contentType !== 'movies' && contentType !== 'homevideos' && contentType !== 'musicvideos' && contentType !== 'mixed') {
- parent.querySelector('.chapterSettingsSection').classList.add('hide');
- } else {
- parent.querySelector('.chapterSettingsSection').classList.remove('hide');
- }
-
- if (contentType === 'tvshows') {
- parent.querySelector('.chkAutomaticallyGroupSeriesContainer').classList.remove('hide');
- parent.querySelector('.fldSeasonZeroDisplayName').classList.remove('hide');
- parent.querySelector('#txtSeasonZeroName').setAttribute('required', 'required');
- } else {
- parent.querySelector('.chkAutomaticallyGroupSeriesContainer').classList.add('hide');
- parent.querySelector('.fldSeasonZeroDisplayName').classList.add('hide');
- parent.querySelector('#txtSeasonZeroName').removeAttribute('required');
- }
-
- if (contentType === 'books' || contentType === 'boxsets' || contentType === 'playlists' || contentType === 'music') {
- parent.querySelector('.chkEnableEmbeddedTitlesContainer').classList.add('hide');
- parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.add('hide');
- } else {
- parent.querySelector('.chkEnableEmbeddedTitlesContainer').classList.remove('hide');
- if (parent.querySelector('#chkEnableEmbeddedTitles').checked) {
- parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.remove('hide');
+ const prev = li.previousSibling;
+ if (prev) {
+ li.parentNode.removeChild(li);
+ prev.parentNode.insertBefore(li, prev);
}
}
-
- if (contentType === 'tvshows') {
- parent.querySelector('.chkEnableEmbeddedEpisodeInfosContainer').classList.remove('hide');
- } else {
- parent.querySelector('.chkEnableEmbeddedEpisodeInfosContainer').classList.add('hide');
- }
-
- if (contentType === 'tvshows' || contentType === 'movies' || contentType === 'musicvideos' || contentType === 'mixed') {
- parent.querySelector('.fldAllowEmbeddedSubtitlesContainer').classList.remove('hide');
- } else {
- parent.querySelector('.fldAllowEmbeddedSubtitlesContainer').classList.add('hide');
- }
-
- parent.querySelector('.chkAutomaticallyAddToCollectionContainer').classList.toggle('hide', contentType !== 'movies' && contentType !== 'mixed');
-
- return populateMetadataSettings(parent, contentType);
+ Array.prototype.forEach.call(list.querySelectorAll('.sortableOption'), adjustSortableListElement);
}
+}
- function setSubtitleFetchersIntoOptions(parent, options) {
- options.DisabledSubtitleFetchers = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleFetcher'), elem => {
- return !elem.checked;
- }), elem => {
- return elem.getAttribute('data-pluginname');
+function bindEvents(parent) {
+ parent.querySelector('.metadataReaders').addEventListener('click', onSortableContainerClick);
+ parent.querySelector('.subtitleFetchers').addEventListener('click', onSortableContainerClick);
+ parent.querySelector('.metadataFetchers').addEventListener('click', onSortableContainerClick);
+ parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick);
+
+ parent.querySelector('#chkEnableEmbeddedTitles').addEventListener('change', (e) => {
+ parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.toggle('hide', !e.currentTarget.checked);
+ });
+}
+
+export async function embed(parent, contentType, libraryOptions) {
+ currentLibraryOptions = {
+ TypeOptions: []
+ };
+ currentAvailableOptions = null;
+ const isNewLibrary = libraryOptions === null;
+ isNewLibrary && parent.classList.add('newlibrary');
+
+ parent.innerHTML = globalize.translateHtml(template);
+ populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
+ const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];
+ Promise.all(promises).then(function() {
+ return setContentType(parent, contentType).then(function() {
+ libraryOptions && setLibraryOptions(parent, libraryOptions);
+ bindEvents(parent);
});
+ });
+}
- options.SubtitleFetcherOrder = Array.prototype.map.call(parent.querySelectorAll('.subtitleFetcherItem'), elem => {
- return elem.getAttribute('data-pluginname');
- });
+export function setContentType(parent, contentType) {
+ if (contentType === 'homevideos' || contentType === 'photos') {
+ parent.querySelector('.chkEnablePhotosContainer').classList.remove('hide');
+ } else {
+ parent.querySelector('.chkEnablePhotosContainer').classList.add('hide');
}
- function setMetadataFetchersIntoOptions(parent, options) {
- const sections = parent.querySelectorAll('.metadataFetcher');
- for (let i = 0; i < sections.length; i++) {
- const section = sections[i];
- const type = section.getAttribute('data-type');
- let typeOptions = getTypeOptions(options, type);
- if (!typeOptions) {
- typeOptions = {
- Type: type
- };
- options.TypeOptions.push(typeOptions);
- }
- typeOptions.MetadataFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkMetadataFetcher'), elem => {
- return elem.checked;
- }), elem => {
- return elem.getAttribute('data-pluginname');
- });
+ if (contentType !== 'tvshows' && contentType !== 'movies' && contentType !== 'homevideos' && contentType !== 'musicvideos' && contentType !== 'mixed') {
+ parent.querySelector('.chapterSettingsSection').classList.add('hide');
+ } else {
+ parent.querySelector('.chapterSettingsSection').classList.remove('hide');
+ }
- typeOptions.MetadataFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.metadataFetcherItem'), elem => {
- return elem.getAttribute('data-pluginname');
- });
+ if (contentType === 'tvshows') {
+ parent.querySelector('.chkAutomaticallyGroupSeriesContainer').classList.remove('hide');
+ parent.querySelector('.fldSeasonZeroDisplayName').classList.remove('hide');
+ parent.querySelector('#txtSeasonZeroName').setAttribute('required', 'required');
+ } else {
+ parent.querySelector('.chkAutomaticallyGroupSeriesContainer').classList.add('hide');
+ parent.querySelector('.fldSeasonZeroDisplayName').classList.add('hide');
+ parent.querySelector('#txtSeasonZeroName').removeAttribute('required');
+ }
+
+ if (contentType === 'books' || contentType === 'boxsets' || contentType === 'playlists' || contentType === 'music') {
+ parent.querySelector('.chkEnableEmbeddedTitlesContainer').classList.add('hide');
+ parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.add('hide');
+ } else {
+ parent.querySelector('.chkEnableEmbeddedTitlesContainer').classList.remove('hide');
+ if (parent.querySelector('#chkEnableEmbeddedTitles').checked) {
+ parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.remove('hide');
}
}
- function setImageFetchersIntoOptions(parent, options) {
- const sections = parent.querySelectorAll('.imageFetcher');
- for (let i = 0; i < sections.length; i++) {
- const section = sections[i];
- const type = section.getAttribute('data-type');
- let typeOptions = getTypeOptions(options, type);
- if (!typeOptions) {
- typeOptions = {
- Type: type
- };
- options.TypeOptions.push(typeOptions);
- }
-
- typeOptions.ImageFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkImageFetcher'), elem => {
- return elem.checked;
- }), elem => {
- return elem.getAttribute('data-pluginname');
- });
-
- typeOptions.ImageFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.imageFetcherItem'), elem => {
- return elem.getAttribute('data-pluginname');
- });
- }
+ if (contentType === 'tvshows') {
+ parent.querySelector('.chkEnableEmbeddedEpisodeInfosContainer').classList.remove('hide');
+ } else {
+ parent.querySelector('.chkEnableEmbeddedEpisodeInfosContainer').classList.add('hide');
}
- function setImageOptionsIntoOptions(options) {
- const originalTypeOptions = (currentLibraryOptions || {}).TypeOptions || [];
- for (let i = 0; i < originalTypeOptions.length; i++) {
- const originalTypeOption = originalTypeOptions[i];
- let typeOptions = getTypeOptions(options, originalTypeOption.Type);
-
- if (!typeOptions) {
- typeOptions = {
- Type: originalTypeOption.Type
- };
- options.TypeOptions.push(typeOptions);
- }
- originalTypeOption.ImageOptions && (typeOptions.ImageOptions = originalTypeOption.ImageOptions);
- }
+ if (contentType === 'tvshows' || contentType === 'movies' || contentType === 'musicvideos' || contentType === 'mixed') {
+ parent.querySelector('.fldAllowEmbeddedSubtitlesContainer').classList.remove('hide');
+ } else {
+ parent.querySelector('.fldAllowEmbeddedSubtitlesContainer').classList.add('hide');
}
- export function getLibraryOptions(parent) {
- const options = {
- EnableArchiveMediaFiles: false,
- EnablePhotos: parent.querySelector('.chkEnablePhotos').checked,
- EnableRealtimeMonitor: parent.querySelector('.chkEnableRealtimeMonitor').checked,
- ExtractChapterImagesDuringLibraryScan: parent.querySelector('.chkExtractChaptersDuringLibraryScan').checked,
- EnableChapterImageExtraction: parent.querySelector('.chkExtractChapterImages').checked,
- EnableInternetProviders: true,
- SaveLocalMetadata: parent.querySelector('#chkSaveLocal').checked,
- EnableAutomaticSeriesGrouping: parent.querySelector('.chkAutomaticallyGroupSeries').checked,
- PreferredMetadataLanguage: parent.querySelector('#selectLanguage').value,
- MetadataCountryCode: parent.querySelector('#selectCountry').value,
- SeasonZeroDisplayName: parent.querySelector('#txtSeasonZeroName').value,
- AutomaticRefreshIntervalDays: parseInt(parent.querySelector('#selectAutoRefreshInterval').value, 10),
- EnableEmbeddedTitles: parent.querySelector('#chkEnableEmbeddedTitles').checked,
- EnableEmbeddedExtrasTitles: parent.querySelector('#chkEnableEmbeddedExtrasTitles').checked,
- EnableEmbeddedEpisodeInfos: parent.querySelector('#chkEnableEmbeddedEpisodeInfos').checked,
- AllowEmbeddedSubtitles: parent.querySelector('#selectAllowEmbeddedSubtitles').value,
- SkipSubtitlesIfEmbeddedSubtitlesPresent: parent.querySelector('#chkSkipIfGraphicalSubsPresent').checked,
- SkipSubtitlesIfAudioTrackMatches: parent.querySelector('#chkSkipIfAudioTrackPresent').checked,
- SaveSubtitlesWithMedia: parent.querySelector('#chkSaveSubtitlesLocally').checked,
- RequirePerfectSubtitleMatch: parent.querySelector('#chkRequirePerfectMatch').checked,
- AutomaticallyAddToCollection: parent.querySelector('#chkAutomaticallyAddToCollection').checked,
- MetadataSavers: Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkMetadataSaver'), elem => {
- return elem.checked;
- }), elem => {
- return elem.getAttribute('data-pluginname');
- }),
- TypeOptions: []
- };
+ parent.querySelector('.chkAutomaticallyAddToCollectionContainer').classList.toggle('hide', contentType !== 'movies' && contentType !== 'mixed');
- options.LocalMetadataReaderOrder = Array.prototype.map.call(parent.querySelectorAll('.localReaderOption'), elem => {
- return elem.getAttribute('data-pluginname');
- });
- options.SubtitleDownloadLanguages = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleLanguage'), elem => {
+ return populateMetadataSettings(parent, contentType);
+}
+
+function setSubtitleFetchersIntoOptions(parent, options) {
+ options.DisabledSubtitleFetchers = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleFetcher'), elem => {
+ return !elem.checked;
+ }), elem => {
+ return elem.getAttribute('data-pluginname');
+ });
+
+ options.SubtitleFetcherOrder = Array.prototype.map.call(parent.querySelectorAll('.subtitleFetcherItem'), elem => {
+ return elem.getAttribute('data-pluginname');
+ });
+}
+
+function setMetadataFetchersIntoOptions(parent, options) {
+ const sections = parent.querySelectorAll('.metadataFetcher');
+ for (let i = 0; i < sections.length; i++) {
+ const section = sections[i];
+ const type = section.getAttribute('data-type');
+ let typeOptions = getTypeOptions(options, type);
+ if (!typeOptions) {
+ typeOptions = {
+ Type: type
+ };
+ options.TypeOptions.push(typeOptions);
+ }
+ typeOptions.MetadataFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkMetadataFetcher'), elem => {
return elem.checked;
}), elem => {
- return elem.getAttribute('data-lang');
+ return elem.getAttribute('data-pluginname');
});
- setSubtitleFetchersIntoOptions(parent, options);
- setMetadataFetchersIntoOptions(parent, options);
- setImageFetchersIntoOptions(parent, options);
- setImageOptionsIntoOptions(options);
- return options;
+ typeOptions.MetadataFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.metadataFetcherItem'), elem => {
+ return elem.getAttribute('data-pluginname');
+ });
}
+}
- function getOrderedPlugins(plugins, configuredOrder) {
- plugins = plugins.slice(0);
- plugins.sort((a, b) => {
- a = configuredOrder.indexOf(a.Name);
- b = configuredOrder.indexOf(b.Name);
- return a - b;
+function setImageFetchersIntoOptions(parent, options) {
+ const sections = parent.querySelectorAll('.imageFetcher');
+ for (let i = 0; i < sections.length; i++) {
+ const section = sections[i];
+ const type = section.getAttribute('data-type');
+ let typeOptions = getTypeOptions(options, type);
+ if (!typeOptions) {
+ typeOptions = {
+ Type: type
+ };
+ options.TypeOptions.push(typeOptions);
+ }
+
+ typeOptions.ImageFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkImageFetcher'), elem => {
+ return elem.checked;
+ }), elem => {
+ return elem.getAttribute('data-pluginname');
+ });
+
+ typeOptions.ImageFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.imageFetcherItem'), elem => {
+ return elem.getAttribute('data-pluginname');
});
- return plugins;
}
+}
- export function setLibraryOptions(parent, options) {
- currentLibraryOptions = options;
- currentAvailableOptions = parent.availableOptions;
- parent.querySelector('#selectLanguage').value = options.PreferredMetadataLanguage || '';
- parent.querySelector('#selectCountry').value = options.MetadataCountryCode || '';
- parent.querySelector('#selectAutoRefreshInterval').value = options.AutomaticRefreshIntervalDays || '0';
- parent.querySelector('#txtSeasonZeroName').value = options.SeasonZeroDisplayName || 'Specials';
- parent.querySelector('.chkEnablePhotos').checked = options.EnablePhotos;
- parent.querySelector('.chkEnableRealtimeMonitor').checked = options.EnableRealtimeMonitor;
- parent.querySelector('.chkExtractChaptersDuringLibraryScan').checked = options.ExtractChapterImagesDuringLibraryScan;
- parent.querySelector('.chkExtractChapterImages').checked = options.EnableChapterImageExtraction;
- parent.querySelector('#chkSaveLocal').checked = options.SaveLocalMetadata;
- parent.querySelector('.chkAutomaticallyGroupSeries').checked = options.EnableAutomaticSeriesGrouping;
- parent.querySelector('#chkEnableEmbeddedTitles').checked = options.EnableEmbeddedTitles;
- parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.toggle('hide', !options.EnableEmbeddedTitles);
- parent.querySelector('#chkEnableEmbeddedExtrasTitles').checked = options.EnableEmbeddedExtrasTitles;
- parent.querySelector('#chkEnableEmbeddedEpisodeInfos').value = options.EnableEmbeddedEpisodeInfos;
- parent.querySelector('#selectAllowEmbeddedSubtitles').value = options.AllowEmbeddedSubtitles;
- parent.querySelector('#chkSkipIfGraphicalSubsPresent').checked = options.SkipSubtitlesIfEmbeddedSubtitlesPresent;
- parent.querySelector('#chkSaveSubtitlesLocally').checked = options.SaveSubtitlesWithMedia;
- parent.querySelector('#chkSkipIfAudioTrackPresent').checked = options.SkipSubtitlesIfAudioTrackMatches;
- parent.querySelector('#chkRequirePerfectMatch').checked = options.RequirePerfectSubtitleMatch;
- parent.querySelector('#chkAutomaticallyAddToCollection').checked = options.AutomaticallyAddToCollection;
- Array.prototype.forEach.call(parent.querySelectorAll('.chkMetadataSaver'), elem => {
- elem.checked = options.MetadataSavers ? options.MetadataSavers.includes(elem.getAttribute('data-pluginname')) : elem.getAttribute('data-defaultenabled') === 'true';
- });
- Array.prototype.forEach.call(parent.querySelectorAll('.chkSubtitleLanguage'), elem => {
- elem.checked = !!options.SubtitleDownloadLanguages && options.SubtitleDownloadLanguages.includes(elem.getAttribute('data-lang'));
- });
- renderMetadataReaders(parent, getOrderedPlugins(parent.availableOptions.MetadataReaders, options.LocalMetadataReaderOrder || []));
- renderMetadataFetchers(parent, parent.availableOptions, options);
- renderImageFetchers(parent, parent.availableOptions, options);
- renderSubtitleFetchers(parent, parent.availableOptions, options);
+function setImageOptionsIntoOptions(options) {
+ const originalTypeOptions = (currentLibraryOptions || {}).TypeOptions || [];
+ for (let i = 0; i < originalTypeOptions.length; i++) {
+ const originalTypeOption = originalTypeOptions[i];
+ let typeOptions = getTypeOptions(options, originalTypeOption.Type);
+
+ if (!typeOptions) {
+ typeOptions = {
+ Type: originalTypeOption.Type
+ };
+ options.TypeOptions.push(typeOptions);
+ }
+ originalTypeOption.ImageOptions && (typeOptions.ImageOptions = originalTypeOption.ImageOptions);
}
+}
- let currentLibraryOptions;
- let currentAvailableOptions;
+export function getLibraryOptions(parent) {
+ const options = {
+ EnableArchiveMediaFiles: false,
+ EnablePhotos: parent.querySelector('.chkEnablePhotos').checked,
+ EnableRealtimeMonitor: parent.querySelector('.chkEnableRealtimeMonitor').checked,
+ ExtractChapterImagesDuringLibraryScan: parent.querySelector('.chkExtractChaptersDuringLibraryScan').checked,
+ EnableChapterImageExtraction: parent.querySelector('.chkExtractChapterImages').checked,
+ EnableInternetProviders: true,
+ SaveLocalMetadata: parent.querySelector('#chkSaveLocal').checked,
+ EnableAutomaticSeriesGrouping: parent.querySelector('.chkAutomaticallyGroupSeries').checked,
+ PreferredMetadataLanguage: parent.querySelector('#selectLanguage').value,
+ MetadataCountryCode: parent.querySelector('#selectCountry').value,
+ SeasonZeroDisplayName: parent.querySelector('#txtSeasonZeroName').value,
+ AutomaticRefreshIntervalDays: parseInt(parent.querySelector('#selectAutoRefreshInterval').value, 10),
+ EnableEmbeddedTitles: parent.querySelector('#chkEnableEmbeddedTitles').checked,
+ EnableEmbeddedExtrasTitles: parent.querySelector('#chkEnableEmbeddedExtrasTitles').checked,
+ EnableEmbeddedEpisodeInfos: parent.querySelector('#chkEnableEmbeddedEpisodeInfos').checked,
+ AllowEmbeddedSubtitles: parent.querySelector('#selectAllowEmbeddedSubtitles').value,
+ SkipSubtitlesIfEmbeddedSubtitlesPresent: parent.querySelector('#chkSkipIfGraphicalSubsPresent').checked,
+ SkipSubtitlesIfAudioTrackMatches: parent.querySelector('#chkSkipIfAudioTrackPresent').checked,
+ SaveSubtitlesWithMedia: parent.querySelector('#chkSaveSubtitlesLocally').checked,
+ RequirePerfectSubtitleMatch: parent.querySelector('#chkRequirePerfectMatch').checked,
+ AutomaticallyAddToCollection: parent.querySelector('#chkAutomaticallyAddToCollection').checked,
+ MetadataSavers: Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkMetadataSaver'), elem => {
+ return elem.checked;
+ }), elem => {
+ return elem.getAttribute('data-pluginname');
+ }),
+ TypeOptions: []
+ };
+
+ options.LocalMetadataReaderOrder = Array.prototype.map.call(parent.querySelectorAll('.localReaderOption'), elem => {
+ return elem.getAttribute('data-pluginname');
+ });
+ options.SubtitleDownloadLanguages = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleLanguage'), elem => {
+ return elem.checked;
+ }), elem => {
+ return elem.getAttribute('data-lang');
+ });
+ setSubtitleFetchersIntoOptions(parent, options);
+ setMetadataFetchersIntoOptions(parent, options);
+ setImageFetchersIntoOptions(parent, options);
+ setImageOptionsIntoOptions(options);
+
+ return options;
+}
+
+function getOrderedPlugins(plugins, configuredOrder) {
+ plugins = plugins.slice(0);
+ plugins.sort((a, b) => {
+ a = configuredOrder.indexOf(a.Name);
+ b = configuredOrder.indexOf(b.Name);
+ return a - b;
+ });
+ return plugins;
+}
+
+export function setLibraryOptions(parent, options) {
+ currentLibraryOptions = options;
+ currentAvailableOptions = parent.availableOptions;
+ parent.querySelector('#selectLanguage').value = options.PreferredMetadataLanguage || '';
+ parent.querySelector('#selectCountry').value = options.MetadataCountryCode || '';
+ parent.querySelector('#selectAutoRefreshInterval').value = options.AutomaticRefreshIntervalDays || '0';
+ parent.querySelector('#txtSeasonZeroName').value = options.SeasonZeroDisplayName || 'Specials';
+ parent.querySelector('.chkEnablePhotos').checked = options.EnablePhotos;
+ parent.querySelector('.chkEnableRealtimeMonitor').checked = options.EnableRealtimeMonitor;
+ parent.querySelector('.chkExtractChaptersDuringLibraryScan').checked = options.ExtractChapterImagesDuringLibraryScan;
+ parent.querySelector('.chkExtractChapterImages').checked = options.EnableChapterImageExtraction;
+ parent.querySelector('#chkSaveLocal').checked = options.SaveLocalMetadata;
+ parent.querySelector('.chkAutomaticallyGroupSeries').checked = options.EnableAutomaticSeriesGrouping;
+ parent.querySelector('#chkEnableEmbeddedTitles').checked = options.EnableEmbeddedTitles;
+ parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.toggle('hide', !options.EnableEmbeddedTitles);
+ parent.querySelector('#chkEnableEmbeddedExtrasTitles').checked = options.EnableEmbeddedExtrasTitles;
+ parent.querySelector('#chkEnableEmbeddedEpisodeInfos').value = options.EnableEmbeddedEpisodeInfos;
+ parent.querySelector('#selectAllowEmbeddedSubtitles').value = options.AllowEmbeddedSubtitles;
+ parent.querySelector('#chkSkipIfGraphicalSubsPresent').checked = options.SkipSubtitlesIfEmbeddedSubtitlesPresent;
+ parent.querySelector('#chkSaveSubtitlesLocally').checked = options.SaveSubtitlesWithMedia;
+ parent.querySelector('#chkSkipIfAudioTrackPresent').checked = options.SkipSubtitlesIfAudioTrackMatches;
+ parent.querySelector('#chkRequirePerfectMatch').checked = options.RequirePerfectSubtitleMatch;
+ parent.querySelector('#chkAutomaticallyAddToCollection').checked = options.AutomaticallyAddToCollection;
+ Array.prototype.forEach.call(parent.querySelectorAll('.chkMetadataSaver'), elem => {
+ elem.checked = options.MetadataSavers ? options.MetadataSavers.includes(elem.getAttribute('data-pluginname')) : elem.getAttribute('data-defaultenabled') === 'true';
+ });
+ Array.prototype.forEach.call(parent.querySelectorAll('.chkSubtitleLanguage'), elem => {
+ elem.checked = !!options.SubtitleDownloadLanguages && options.SubtitleDownloadLanguages.includes(elem.getAttribute('data-lang'));
+ });
+ renderMetadataReaders(parent, getOrderedPlugins(parent.availableOptions.MetadataReaders, options.LocalMetadataReaderOrder || []));
+ renderMetadataFetchers(parent, parent.availableOptions, options);
+ renderImageFetchers(parent, parent.availableOptions, options);
+ renderSubtitleFetchers(parent, parent.availableOptions, options);
+}
+
+let currentLibraryOptions;
+let currentAvailableOptions;
-/* eslint-enable indent */
export default {
embed: embed,
setContentType: setContentType,
diff --git a/src/components/listview/listview.js b/src/components/listview/listview.js
index b9f156e9a2..a6a588dc66 100644
--- a/src/components/listview/listview.js
+++ b/src/components/listview/listview.js
@@ -1,4 +1,3 @@
-/* eslint-disable indent */
/**
* Module for display list view.
@@ -18,484 +17,483 @@ import '../../elements/emby-ratingbutton/emby-ratingbutton';
import '../../elements/emby-playstatebutton/emby-playstatebutton';
import ServerConnections from '../ServerConnections';
- function getIndex(item, options) {
- if (options.index === 'disc') {
- return item.ParentIndexNumber == null ? '' : globalize.translate('ValueDiscNumber', item.ParentIndexNumber);
- }
-
- const sortBy = (options.sortBy || '').toLowerCase();
- let code;
- let name;
-
- if (sortBy.indexOf('sortname') === 0) {
- if (item.Type === 'Episode') {
- return '';
- }
-
- // SortName
- name = (item.SortName || item.Name || '?')[0].toUpperCase();
-
- code = name.charCodeAt(0);
- if (code < 65 || code > 90) {
- return '#';
- }
-
- return name.toUpperCase();
- }
- if (sortBy.indexOf('officialrating') === 0) {
- return item.OfficialRating || globalize.translate('Unrated');
- }
- if (sortBy.indexOf('communityrating') === 0) {
- if (item.CommunityRating == null) {
- return globalize.translate('Unrated');
- }
-
- return Math.floor(item.CommunityRating);
- }
- if (sortBy.indexOf('criticrating') === 0) {
- if (item.CriticRating == null) {
- return globalize.translate('Unrated');
- }
-
- return Math.floor(item.CriticRating);
- }
- if (sortBy.indexOf('albumartist') === 0) {
- // SortName
- if (!item.AlbumArtist) {
- return '';
- }
-
- name = item.AlbumArtist[0].toUpperCase();
-
- code = name.charCodeAt(0);
- if (code < 65 || code > 90) {
- return '#';
- }
-
- return name.toUpperCase();
- }
- return '';
+function getIndex(item, options) {
+ if (options.index === 'disc') {
+ return item.ParentIndexNumber == null ? '' : globalize.translate('ValueDiscNumber', item.ParentIndexNumber);
}
- function getImageUrl(item, size) {
- const apiClient = ServerConnections.getApiClient(item.ServerId);
- let itemId;
+ const sortBy = (options.sortBy || '').toLowerCase();
+ let code;
+ let name;
- const options = {
- fillWidth: size,
- fillHeight: size,
- type: 'Primary'
- };
-
- if (item.ImageTags && item.ImageTags.Primary) {
- options.tag = item.ImageTags.Primary;
- itemId = item.Id;
- } else if (item.AlbumId && item.AlbumPrimaryImageTag) {
- options.tag = item.AlbumPrimaryImageTag;
- itemId = item.AlbumId;
- } else if (item.SeriesId && item.SeriesPrimaryImageTag) {
- options.tag = item.SeriesPrimaryImageTag;
- itemId = item.SeriesId;
- } else if (item.ParentPrimaryImageTag) {
- options.tag = item.ParentPrimaryImageTag;
- itemId = item.ParentPrimaryImageItemId;
+ if (sortBy.indexOf('sortname') === 0) {
+ if (item.Type === 'Episode') {
+ return '';
}
- if (itemId) {
- return apiClient.getScaledImageUrl(itemId, options);
+ // SortName
+ name = (item.SortName || item.Name || '?')[0].toUpperCase();
+
+ code = name.charCodeAt(0);
+ if (code < 65 || code > 90) {
+ return '#';
}
- return null;
+
+ return name.toUpperCase();
+ }
+ if (sortBy.indexOf('officialrating') === 0) {
+ return item.OfficialRating || globalize.translate('Unrated');
+ }
+ if (sortBy.indexOf('communityrating') === 0) {
+ if (item.CommunityRating == null) {
+ return globalize.translate('Unrated');
+ }
+
+ return Math.floor(item.CommunityRating);
+ }
+ if (sortBy.indexOf('criticrating') === 0) {
+ if (item.CriticRating == null) {
+ return globalize.translate('Unrated');
+ }
+
+ return Math.floor(item.CriticRating);
+ }
+ if (sortBy.indexOf('albumartist') === 0) {
+ // SortName
+ if (!item.AlbumArtist) {
+ return '';
+ }
+
+ name = item.AlbumArtist[0].toUpperCase();
+
+ code = name.charCodeAt(0);
+ if (code < 65 || code > 90) {
+ return '#';
+ }
+
+ return name.toUpperCase();
+ }
+ return '';
+}
+
+function getImageUrl(item, size) {
+ const apiClient = ServerConnections.getApiClient(item.ServerId);
+ let itemId;
+
+ const options = {
+ fillWidth: size,
+ fillHeight: size,
+ type: 'Primary'
+ };
+
+ if (item.ImageTags && item.ImageTags.Primary) {
+ options.tag = item.ImageTags.Primary;
+ itemId = item.Id;
+ } else if (item.AlbumId && item.AlbumPrimaryImageTag) {
+ options.tag = item.AlbumPrimaryImageTag;
+ itemId = item.AlbumId;
+ } else if (item.SeriesId && item.SeriesPrimaryImageTag) {
+ options.tag = item.SeriesPrimaryImageTag;
+ itemId = item.SeriesId;
+ } else if (item.ParentPrimaryImageTag) {
+ options.tag = item.ParentPrimaryImageTag;
+ itemId = item.ParentPrimaryImageItemId;
}
- function getChannelImageUrl(item, size) {
- const apiClient = ServerConnections.getApiClient(item.ServerId);
- const options = {
- fillWidth: size,
- fillHeight: size,
- type: 'Primary'
- };
+ if (itemId) {
+ return apiClient.getScaledImageUrl(itemId, options);
+ }
+ return null;
+}
- if (item.ChannelId && item.ChannelPrimaryImageTag) {
- options.tag = item.ChannelPrimaryImageTag;
- }
+function getChannelImageUrl(item, size) {
+ const apiClient = ServerConnections.getApiClient(item.ServerId);
+ const options = {
+ fillWidth: size,
+ fillHeight: size,
+ type: 'Primary'
+ };
- if (item.ChannelId) {
- return apiClient.getScaledImageUrl(item.ChannelId, options);
- }
+ if (item.ChannelId && item.ChannelPrimaryImageTag) {
+ options.tag = item.ChannelPrimaryImageTag;
}
- function getTextLinesHtml(textlines, isLargeStyle) {
- let html = '';
+ if (item.ChannelId) {
+ return apiClient.getScaledImageUrl(item.ChannelId, options);
+ }
+}
- const largeTitleTagName = layoutManager.tv ? 'h2' : 'div';
+function getTextLinesHtml(textlines, isLargeStyle) {
+ let html = '';
- for (const [i, text] of textlines.entries()) {
- if (!text) {
- continue;
- }
+ const largeTitleTagName = layoutManager.tv ? 'h2' : 'div';
- let elem;
+ for (const [i, text] of textlines.entries()) {
+ if (!text) {
+ continue;
+ }
- if (i === 0) {
- if (isLargeStyle) {
- elem = document.createElement(largeTitleTagName);
- } else {
- elem = document.createElement('div');
- }
+ let elem;
+
+ if (i === 0) {
+ if (isLargeStyle) {
+ elem = document.createElement(largeTitleTagName);
} else {
elem = document.createElement('div');
- elem.classList.add('secondary');
}
-
- elem.classList.add('listItemBodyText');
-
- elem.innerHTML = '
' + escapeHtml(text) + ' ';
-
- html += elem.outerHTML;
+ } else {
+ elem = document.createElement('div');
+ elem.classList.add('secondary');
}
- return html;
+ elem.classList.add('listItemBodyText');
+
+ elem.innerHTML = '
' + escapeHtml(text) + ' ';
+
+ html += elem.outerHTML;
}
- function getRightButtonsHtml(options) {
+ return html;
+}
+
+function getRightButtonsHtml(options) {
+ let html = '';
+
+ for (let i = 0, length = options.rightButtons.length; i < length; i++) {
+ const button = options.rightButtons[i];
+
+ html += `
`;
+ }
+
+ return html;
+}
+
+export function getListViewHtml(options) {
+ const items = options.items;
+
+ let groupTitle = '';
+ const action = options.action || 'link';
+
+ const isLargeStyle = options.imageSize === 'large';
+ const enableOverview = options.enableOverview;
+
+ const clickEntireItem = layoutManager.tv ? true : false;
+ const outerTagName = clickEntireItem ? 'button' : 'div';
+ const enableSideMediaInfo = options.enableSideMediaInfo != null ? options.enableSideMediaInfo : true;
+
+ let outerHtml = '';
+
+ const enableContentWrapper = options.enableOverview && !layoutManager.tv;
+
+ for (let i = 0, length = items.length; i < length; i++) {
+ const item = items[i];
+
let html = '';
- for (let i = 0, length = options.rightButtons.length; i < length; i++) {
- const button = options.rightButtons[i];
+ if (options.showIndex) {
+ const itemGroupTitle = getIndex(item, options);
- html += `
`;
+ if (itemGroupTitle !== groupTitle) {
+ if (html) {
+ html += '
';
+ }
+
+ if (i === 0) {
+ html += '