Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add media segment providers to library options #6330

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/components/libraryoptionseditor/libraryoptionseditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += `<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;
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ <h2>${HeaderLibrarySettings}</h2>
<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">
Expand Down
2 changes: 2 additions & 0 deletions src/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
Loading