Add media segment providers to library options

This commit is contained in:
Niels van Velzen 2024-11-19 22:17:17 +01:00
parent 3e7de3c580
commit ce8b68c512
3 changed files with 55 additions and 0 deletions

View File

@ -249,6 +249,40 @@ function renderLyricFetchers(page, availableOptions, libraryOptions) {
elem.innerHTML = html;
}
function renderMediaSegmentProviders(page, availableOptions, libraryOptions) {
let html = '';
const elem = page.querySelector('.mediaSegmentProviders');
let plugins = availableOptions.MediaSegmentProviders;
plugins = getOrderedPlugins(plugins, libraryOptions.MediaSegmentProviderOrder);
elem.classList.toggle('hide', !plugins.length);
if (!plugins.length) return html;
html += `<h3 class="checkboxListLabel">${globalize.translate('LabelMediaSegmentProviders')}</h3>`;
html += '<div class="checkboxList paperList checkboxList-paperList">';
for (let i = 0; i < plugins.length; i++) {
const plugin = plugins[i];
html += `<div class="listItem mediaSegmentProviderItem sortableOption" data-pluginname="${escapeHtml(plugin.Name)}">`;
const isChecked = libraryOptions.DisabledMediaSegmentProviders ? !libraryOptions.DisabledMediaSegmentProviders.includes(plugin.Name) : plugin.DefaultEnabled;
const checkedHtml = isChecked ? ' checked="checked"' : '';
html += `<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkMediaSegmentProvider" data-pluginname="${escapeHtml(plugin.Name)}" ${checkedHtml}><span></span></label>`;
html += '<div class="listItemBody">';
html += '<h3 class="listItemBodyText">';
html += escapeHtml(plugin.Name);
html += '</h3>';
html += '</div>';
if (i > 0) {
html += `<button type="button" is="paper-icon-button-light" title="${globalize.translate('Up')}" class="btnSortableMoveUp btnSortable" data-pluginindex="${i}"><span class="material-icons keyboard_arrow_up" aria-hidden="true"></span></button>`;
} else if (plugins.length > 1) {
html += `<button type="button" is="paper-icon-button-light" title="${globalize.translate('Down')}" class="btnSortableMoveDown btnSortable" data-pluginindex="${i}"><span class="material-icons keyboard_arrow_down" aria-hidden="true"></span></button>`;
}
html += '</div>';
}
html += '</div>';
html += `<div class="fieldDescription">${globalize.translate('MediaSegmentProvidersHelp')}</div>`;
elem.innerHTML = html;
}
function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
let html = '';
let plugins = availableTypeOptions.ImageFetchers;
@ -319,6 +353,7 @@ function populateMetadataSettings(parent, contentType) {
renderMetadataFetchers(parent, availableOptions, {});
renderSubtitleFetchers(parent, availableOptions, {});
renderLyricFetchers(parent, availableOptions, {});
renderMediaSegmentProviders(parent, availableOptions, {});
renderImageFetchers(parent, availableOptions, {});
availableOptions.SubtitleFetchers.length ? parent.querySelector('.subtitleDownloadSettings').classList.remove('hide') : parent.querySelector('.subtitleDownloadSettings').classList.add('hide');
}).catch(() => {
@ -394,6 +429,7 @@ function bindEvents(parent) {
parent.querySelector('.metadataReaders').addEventListener('click', onSortableContainerClick);
parent.querySelector('.subtitleFetchers').addEventListener('click', onSortableContainerClick);
parent.querySelector('.metadataFetchers').addEventListener('click', onSortableContainerClick);
parent.querySelector('.mediaSegmentProviders').addEventListener('click', onSortableContainerClick);
parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick);
parent.querySelector('#chkEnableEmbeddedTitles').addEventListener('change', (e) => {
@ -509,6 +545,18 @@ function setLyricFetchersIntoOptions(parent, options) {
});
}
function setMediaSegmentProvidersIntoOptions(parent, options) {
options.DisabledMediaSegmentProviders = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkMediaSegmentProvider'), elem => {
return !elem.checked;
}), elem => {
return elem.getAttribute('data-pluginname');
});
options.MediaSegmentProviderOrder = Array.prototype.map.call(parent.querySelectorAll('.mediaSegmentProviderItem'), elem => {
return elem.getAttribute('data-pluginname');
});
}
function setMetadataFetchersIntoOptions(parent, options) {
const sections = parent.querySelectorAll('.metadataFetcher');
for (const section of sections) {
@ -622,6 +670,7 @@ export function getLibraryOptions(parent) {
options.DelimiterWhitelist = parent.querySelector('#tagDelimiterWhitelist').value.split('\n').filter(item => item.trim());
setSubtitleFetchersIntoOptions(parent, options);
setLyricFetchersIntoOptions(parent, options);
setMediaSegmentProvidersIntoOptions(parent, options);
setMetadataFetchersIntoOptions(parent, options);
setImageFetchersIntoOptions(parent, options);
setImageOptionsIntoOptions(options);
@ -683,6 +732,7 @@ export function setLibraryOptions(parent, options) {
renderImageFetchers(parent, parent.availableOptions, options);
renderSubtitleFetchers(parent, parent.availableOptions, options);
renderLyricFetchers(parent, parent.availableOptions, options);
renderMediaSegmentProviders(parent, parent.availableOptions, options);
}
let currentLibraryOptions;

View File

@ -112,6 +112,9 @@
<div class="fieldDescription checkboxFieldDescription">${OptionAutomaticallyGroupSeriesHelp}</div>
</div>
<div class="mediaSegmentProviders advanced hide" style="margin-bottom: 2em;">
</div>
<div class="trickplaySettingsSection hide">
<h2>${Trickplay}</h2>
<div class="checkboxContainer checkboxContainer-withDescription fldExtractTrickplayImages">

View File

@ -754,6 +754,7 @@
"LabelMaxDaysForNextUpHelp": "Set the maximum amount of days a show should stay in the 'Next Up' list without watching it.",
"LabelMaxVideoResolution": "Maximum Allowed Video Transcoding Resolution",
"LabelMediaDetails": "Media details",
"LabelMediaSegmentProviders": "Media segment providers",
"LabelMediaSegmentsType": "{0} Segments",
"LabelLineup": "Lineup",
"LabelLocalCustomCss": "Custom CSS code for styling which applies to this client only. You may want to disable server custom CSS code.",
@ -1074,6 +1075,7 @@
"MediaSegmentAction.None": "None",
"MediaSegmentAction.AskToSkip": "Ask To Skip",
"MediaSegmentAction.Skip": "Skip",
"MediaSegmentProvidersHelp": "Enable and rank your preferred media segment providers in order of priority.",
"MediaSegmentSkipPrompt": "Skip {0}",
"MediaSegmentType.Commercial": "Commercial",
"MediaSegmentType.Intro": "Intro",