Add SelectAllLibraries option (#292)

* Add SelectAllLibraries option

---------

Co-authored-by: rlauu <46294892+rlauu@users.noreply.github.com>
This commit is contained in:
rlauuzo 2024-09-17 08:41:56 +02:00 committed by GitHub
parent 08145e0731
commit b6231417da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 16 deletions

View File

@ -10,6 +10,8 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Configuration;
/// </summary> /// </summary>
public class PluginConfiguration : BasePluginConfiguration public class PluginConfiguration : BasePluginConfiguration
{ {
private bool? _selectAllLibraries;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class. /// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
/// </summary> /// </summary>
@ -25,10 +27,19 @@ public class PluginConfiguration : BasePluginConfiguration
public int MaxParallelism { get; set; } = 2; public int MaxParallelism { get; set; } = 2;
/// <summary> /// <summary>
/// Gets or sets the comma separated list of library names to analyze. If empty, all libraries will be analyzed. /// Gets or sets the comma separated list of library names to analyze.
/// </summary> /// </summary>
public string SelectedLibraries { get; set; } = string.Empty; public string SelectedLibraries { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether all libraries should be analyzed.
/// </summary>
public bool SelectAllLibraries
{
get => _selectAllLibraries ?? string.IsNullOrEmpty(SelectedLibraries);
set => _selectAllLibraries = value;
}
/// <summary> /// <summary>
/// Gets or sets the list of client to auto skip for. /// Gets or sets the list of client to auto skip for.
/// </summary> /// </summary>

View File

@ -77,18 +77,22 @@
</div> </div>
</div> </div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="SelectAllLibraries" type="checkbox" is="emby-checkbox" />
<span>Enable analysis for all libraries containing television episodes</span>
</label>
<div class="folderAccessListContainer"> <div class="folderAccessListContainer">
<div class="folderAccess"> <div class="folderAccess">
<h4 class="checkboxListLabel">Limit analysis to the following libraries</h4> <h4 class="checkboxListLabel">Limit analysis to the following libraries</h4>
<div class="checkboxList paperList" style="padding: 0.5em 1em;" id="libraryCheckboxes"> <div class="checkboxList paperList" style="padding: 0.5em 1em;" id="libraryCheckboxes">
</div> </div>
</div> </div>
<div class="fieldDescription">
Selected libraries will be analyzed. If none are selected, all TV show and mixed libraries will be analyzed.
</div>
<label class="inputLabel" for="SelectedLibraries"></label> <label class="inputLabel" for="SelectedLibraries"></label>
<input id="SelectedLibraries" type="hidden" is="emby-input" /> <input id="SelectedLibraries" type="hidden" is="emby-input" />
</div> </div>
</div>
<details id="intro_reqs"> <details id="intro_reqs">
<summary>Modify Segment Parameters</summary> <summary>Modify Segment Parameters</summary>
@ -739,6 +743,7 @@
"AutoDetectIntros", "AutoDetectIntros",
"AutoDetectCredits", "AutoDetectCredits",
"AnalyzeSeasonZero", "AnalyzeSeasonZero",
"SelectAllLibraries",
"RegenerateEdlFiles", "RegenerateEdlFiles",
"UseChromaprint", "UseChromaprint",
"CacheFingerprints", "CacheFingerprints",
@ -767,6 +772,8 @@
var windowHashInterval = 0; var windowHashInterval = 0;
var autoSkip = document.querySelector("input#AutoSkip"); var autoSkip = document.querySelector("input#AutoSkip");
var selectAllLibraries = document.querySelector("input#SelectAllLibraries");
var librariesContainer = document.querySelector("div.folderAccessListContainer");
var skipFirstEpisode = document.querySelector("div#divSkipFirstEpisode"); var skipFirstEpisode = document.querySelector("div#divSkipFirstEpisode");
var secondsOfIntroStartToPlay = document.querySelector("div#divSecondsOfIntroStartToPlay"); var secondsOfIntroStartToPlay = document.querySelector("div#divSecondsOfIntroStartToPlay");
var autoSkipClientList = document.getElementById("AutoSkipClientList"); var autoSkipClientList = document.getElementById("AutoSkipClientList");
@ -812,6 +819,16 @@
} }
} }
function selectAllLibrariesChanged() {
if (selectAllLibraries.checked) {
librariesContainer.style.display = 'none';
} else {
librariesContainer.style.display = 'unset';
}
}
selectAllLibraries.addEventListener("change", selectAllLibrariesChanged);
function updateList(textField, container) { function updateList(textField, container) {
textField.value = Array.from(container.querySelectorAll('input[type="checkbox"]:checked')) textField.value = Array.from(container.querySelectorAll('input[type="checkbox"]:checked'))
.map(checkbox => checkbox.nextElementSibling.textContent) .map(checkbox => checkbox.nextElementSibling.textContent)
@ -1202,6 +1219,7 @@
} }
populateLibraries(); populateLibraries();
selectAllLibrariesChanged();
autoSkipChanged(); autoSkipChanged();
autoSkipCreditsChanged(); autoSkipCreditsChanged();
persistSkipChanged(); persistSkipChanged();

View File

@ -27,6 +27,7 @@ public class QueueManager(ILogger<QueueManager> logger, ILibraryManager libraryM
private readonly Dictionary<Guid, List<QueuedEpisode>> _queuedEpisodes = []; private readonly Dictionary<Guid, List<QueuedEpisode>> _queuedEpisodes = [];
private double _analysisPercent; private double _analysisPercent;
private List<string> _selectedLibraries = []; private List<string> _selectedLibraries = [];
private bool _selectAllLibraries;
/// <summary> /// <summary>
/// Gets all media items on the server. /// Gets all media items on the server.
@ -42,7 +43,7 @@ public class QueueManager(ILogger<QueueManager> logger, ILibraryManager libraryM
foreach (var folder in _libraryManager.GetVirtualFolders()) foreach (var folder in _libraryManager.GetVirtualFolders())
{ {
// If libraries have been selected for analysis, ensure this library was selected. // If libraries have been selected for analysis, ensure this library was selected.
if (_selectedLibraries.Count > 0 && !_selectedLibraries.Contains(folder.Name)) if (!_selectAllLibraries && !_selectedLibraries.Contains(folder.Name))
{ {
_logger.LogDebug("Not analyzing library \"{Name}\": not selected by user", folder.Name); _logger.LogDebug("Not analyzing library \"{Name}\": not selected by user", folder.Name);
continue; continue;
@ -92,12 +93,14 @@ public class QueueManager(ILogger<QueueManager> logger, ILibraryManager libraryM
// Store the analysis percent // Store the analysis percent
_analysisPercent = Convert.ToDouble(config.AnalysisPercent) / 100; _analysisPercent = Convert.ToDouble(config.AnalysisPercent) / 100;
_selectAllLibraries = config.SelectAllLibraries;
if (!_selectAllLibraries)
{
// Get the list of library names which have been selected for analysis, ignoring whitespace and empty entries. // Get the list of library names which have been selected for analysis, ignoring whitespace and empty entries.
_selectedLibraries = [.. config.SelectedLibraries.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)]; _selectedLibraries = [.. config.SelectedLibraries.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)];
// If any libraries have been selected for analysis, log their names. // If any libraries have been selected for analysis, log their names.
if (_selectedLibraries.Count > 0)
{
_logger.LogInformation("Limiting analysis to the following libraries: {Selected}", _selectedLibraries); _logger.LogInformation("Limiting analysis to the following libraries: {Selected}", _selectedLibraries);
} }
else else

View File

@ -91,7 +91,7 @@ public class BaseItemAnalyzerTask
if (totalQueued == 0) if (totalQueued == 0)
{ {
throw new FingerprintException( throw new FingerprintException(
"No episodes to analyze. If you are limiting the list of libraries to analyze, check that all library names have been spelled correctly."); "No libraries selected for analysis. Please visit the plugin settings to configure.");
} }
if (Plugin.Instance!.Configuration.EdlAction != EdlAction.None) if (Plugin.Instance!.Configuration.EdlAction != EdlAction.None)