diff --git a/src/components/libraryoptionseditor/libraryoptionseditor.js b/src/components/libraryoptionseditor/libraryoptionseditor.js index c52e62f30f..f6de831830 100644 --- a/src/components/libraryoptionseditor/libraryoptionseditor.js +++ b/src/components/libraryoptionseditor/libraryoptionseditor.js @@ -213,6 +213,39 @@ function renderSubtitleFetchers(page, availableOptions, libraryOptions) { elem.innerHTML = html; } +function renderLyricFetchers(page, availableOptions, libraryOptions) { + let html = ''; + const elem = page.querySelector('.lyricFetchers'); + + const plugins = availableOptions.LyricFetchers; + if (!plugins.length) return html; + + html += `

${globalize.translate('LabelLyricDownloaders')}

`; + html += '
'; + console.log(libraryOptions); + for (let i = 0; i < plugins.length; i++) { + const plugin = plugins[i]; + html += `
`; + const isChecked = libraryOptions.DisabledLyricFetchers ? !libraryOptions.DisabledLyricFetchers.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('LyricDownloadersHelp')}
`; + elem.innerHTML = html; +} + function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) { let html = ''; let plugins = availableTypeOptions.ImageFetchers; @@ -282,6 +315,7 @@ function populateMetadataSettings(parent, contentType) { renderMetadataReaders(parent, availableOptions.MetadataReaders); renderMetadataFetchers(parent, availableOptions, {}); renderSubtitleFetchers(parent, availableOptions, {}); + renderLyricFetchers(parent, availableOptions, {}); renderImageFetchers(parent, availableOptions, {}); availableOptions.SubtitleFetchers.length ? parent.querySelector('.subtitleDownloadSettings').classList.remove('hide') : parent.querySelector('.subtitleDownloadSettings').classList.add('hide'); }).catch(() => { @@ -432,6 +466,12 @@ export function setContentType(parent, contentType) { parent.querySelector('.fldAllowEmbeddedSubtitlesContainer').classList.add('hide'); } + if (contentType === 'music') { + parent.querySelector('.lyricSettingsSection').classList.remove('hide'); + } else { + parent.querySelector('.lyricSettingsSection').classList.add('hide'); + } + parent.querySelector('.chkAutomaticallyAddToCollectionContainer').classList.toggle('hide', contentType !== 'movies' && contentType !== 'mixed'); return populateMetadataSettings(parent, contentType); @@ -449,6 +489,14 @@ function setSubtitleFetchersIntoOptions(parent, options) { }); } +function setLyricFetchersIntoOptions(parent, options) { + options.DisabledLyricFetchers = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkLyricFetcher'), elem => { + return !elem.checked; + }), elem => { + return elem.getAttribute('data-pluginname'); + }); +} + function setMetadataFetchersIntoOptions(parent, options) { const sections = parent.querySelectorAll('.metadataFetcher'); for (const section of sections) { @@ -536,6 +584,7 @@ export function getLibraryOptions(parent) { SkipSubtitlesIfEmbeddedSubtitlesPresent: parent.querySelector('#chkSkipIfGraphicalSubsPresent').checked, SkipSubtitlesIfAudioTrackMatches: parent.querySelector('#chkSkipIfAudioTrackPresent').checked, SaveSubtitlesWithMedia: parent.querySelector('#chkSaveSubtitlesLocally').checked, + SaveLyricsWithMedia: parent.querySelector('#chkSaveLyricsLocally').checked, RequirePerfectSubtitleMatch: parent.querySelector('#chkRequirePerfectMatch').checked, AutomaticallyAddToCollection: parent.querySelector('#chkAutomaticallyAddToCollection').checked, MetadataSavers: Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkMetadataSaver'), elem => { @@ -555,6 +604,7 @@ export function getLibraryOptions(parent) { return elem.getAttribute('data-lang'); }); setSubtitleFetchersIntoOptions(parent, options); + setLyricFetchersIntoOptions(parent, options); setMetadataFetchersIntoOptions(parent, options); setImageFetchersIntoOptions(parent, options); setImageOptionsIntoOptions(options); @@ -596,6 +646,7 @@ export function setLibraryOptions(parent, options) { parent.querySelector('#selectAllowEmbeddedSubtitles').value = options.AllowEmbeddedSubtitles; parent.querySelector('#chkSkipIfGraphicalSubsPresent').checked = options.SkipSubtitlesIfEmbeddedSubtitlesPresent; parent.querySelector('#chkSaveSubtitlesLocally').checked = options.SaveSubtitlesWithMedia; + parent.querySelector('#chkSaveLyricsLocally').checked = options.SaveLyricsWithMedia; parent.querySelector('#chkSkipIfAudioTrackPresent').checked = options.SkipSubtitlesIfAudioTrackMatches; parent.querySelector('#chkRequirePerfectMatch').checked = options.RequirePerfectSubtitleMatch; parent.querySelector('#chkAutomaticallyAddToCollection').checked = options.AutomaticallyAddToCollection; @@ -609,6 +660,7 @@ export function setLibraryOptions(parent, options) { renderMetadataFetchers(parent, parent.availableOptions, options); renderImageFetchers(parent, parent.availableOptions, options); renderSubtitleFetchers(parent, parent.availableOptions, options); + renderLyricFetchers(parent, parent.availableOptions, options); } let currentLibraryOptions; diff --git a/src/components/libraryoptionseditor/libraryoptionseditor.template.html b/src/components/libraryoptionseditor/libraryoptionseditor.template.html index 18c288cc6b..9dec9c5ef6 100644 --- a/src/components/libraryoptionseditor/libraryoptionseditor.template.html +++ b/src/components/libraryoptionseditor/libraryoptionseditor.template.html @@ -193,3 +193,18 @@
${SaveSubtitlesIntoMediaFoldersHelp}
+ +
+

${Lyrics}

+ +
+
+ +
+ +
${SaveLyricsIntoMediaFoldersHelp}
+
+
diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 7ac237d099..63f19e1817 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -417,6 +417,7 @@ "HeaderLibrarySettings": "Library Settings", "HeaderLiveTvTunerSetup": "Live TV Tuner Setup", "HeaderLoginFailure": "Login Failure", + "HeaderLyricDownloads": "Lyric Downloads", "HeaderMedia": "Media", "HeaderMediaFolders": "Media Folders", "HeaderMetadataSettings": "Metadata Settings", @@ -706,11 +707,12 @@ "LabelLineup": "Lineup", "LabelLocalCustomCss": "Custom CSS code for styling which applies to this client only. You may want to disable server custom CSS code.", "LabelLocalHttpServerPortNumber": "Local HTTP port number", - "LabelLocalHttpServerPortNumberHelp": "The TCP port number for the HTTP server.", + "LabelLocalHttpServerPortNudmberHelp": "The TCP port number for the HTTP server.", "LabelLockItemToPreventChanges": "Lock this item to prevent future changes", "LabelLoginDisclaimer": "Login disclaimer", "LabelLoginDisclaimerHelp": "A message that will be displayed at the bottom of the login page.", "LabelLogs": "Logs", + "LabelLyricDownloaders": "Lyric downloaders", "LabelMaxAudiobookResume": "Audiobook remaining minutes to resume", "LabelMaxAudiobookResumeHelp": "Titles are assumed fully played if stopped when the remaining duration is less than this value.", "LabelMaxBackdropsPerItem": "Maximum number of backdrops per item", @@ -966,6 +968,7 @@ "Lyric": "Lyric", "Lyricist": "Lyricist", "Lyrics": "Lyrics", + "LyricDownloadersHelp": "Enable and rank your preferred subtitle downloaders in order of priority.", "ManageLibrary": "Manage library", "ManageRecording": "Manage recording", "MapChannels": "Map Channels", @@ -1347,6 +1350,8 @@ "Saturday": "Saturday", "Save": "Save", "SaveChanges": "Save changes", + "SaveLyricsIntoMediaFolders": "Save lyrics into media folders", + "SaveLyricsIntoMediaFoldersHelp": "Storing lyrics next to audio files will allow them to be more easily managed.", "SavePassword": "Save Password", "SaveRecordingNFO": "Save recording EPG metadata in NFO", "SaveRecordingNFOHelp": "Save metadata from EPG listings provider along side media.",