From c136e3dad2874aebbf1a4e4234ee8d18b4ab2be0 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Tue, 19 Nov 2024 22:17:17 +0100 Subject: [PATCH] Add media segment providers to library options --- .../libraryoptionseditor.js | 51 +++++++++++++++++++ .../libraryoptionseditor.template.html | 3 ++ src/strings/en-us.json | 2 + 3 files changed, 56 insertions(+) diff --git a/src/components/libraryoptionseditor/libraryoptionseditor.js b/src/components/libraryoptionseditor/libraryoptionseditor.js index 006f827f424..2681bf18bad 100644 --- a/src/components/libraryoptionseditor/libraryoptionseditor.js +++ b/src/components/libraryoptionseditor/libraryoptionseditor.js @@ -249,6 +249,39 @@ 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.MediaSegmentProvideOrder); + if (!plugins.length) return html; + + html += `

${globalize.translate('LabelMediaSegmentProviders')}

`; + html += '
'; + for (let i = 0; i < plugins.length; i++) { + const plugin = plugins[i]; + html += `
`; + const isChecked = libraryOptions.DisabledMediaSegmentProviders ? !libraryOptions.DisabledMediaSegmentProviders.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('MediaSegmentProvidersHelp')}
`; + elem.innerHTML = html; +} + function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) { let html = ''; let plugins = availableTypeOptions.ImageFetchers; @@ -319,6 +352,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 +428,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) => { @@ -482,6 +517,8 @@ export function setContentType(parent, contentType) { parent.querySelector('.chkAutomaticallyAddToCollectionContainer').classList.toggle('hide', contentType !== 'movies' && contentType !== 'mixed'); + parent.querySelector('.mediaSegmentProviders').classList.toggle('hide', contentType !== 'tvshows' && contentType !== 'movies'); + return populateMetadataSettings(parent, contentType); } @@ -509,6 +546,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.MediaSegmentProvideOrder = 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 +671,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 +733,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; diff --git a/src/components/libraryoptionseditor/libraryoptionseditor.template.html b/src/components/libraryoptionseditor/libraryoptionseditor.template.html index faebbb65494..f487bc482b1 100644 --- a/src/components/libraryoptionseditor/libraryoptionseditor.template.html +++ b/src/components/libraryoptionseditor/libraryoptionseditor.template.html @@ -112,6 +112,9 @@

${HeaderLibrarySettings}

${OptionAutomaticallyGroupSeriesHelp}
+
+
+

${Trickplay}

diff --git a/src/strings/en-us.json b/src/strings/en-us.json index e6a73a0d606..4e97d0777cf 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -755,6 +755,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.", @@ -1075,6 +1076,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",