From fd4df1f249178c95a310cf2b9cc0a33ad746a0ab Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Wed, 27 Mar 2024 00:23:07 +0100 Subject: [PATCH] refactor: more changes to the settings --- Shokofin/Configuration/PluginConfiguration.cs | 3 - Shokofin/Configuration/configController.js | 45 ++----------- Shokofin/Configuration/configPage.html | 64 ++++++++----------- Shokofin/Plugin.cs | 6 +- Shokofin/Resolvers/ShokoResolveManager.cs | 22 ++++--- 5 files changed, 49 insertions(+), 91 deletions(-) diff --git a/Shokofin/Configuration/PluginConfiguration.cs b/Shokofin/Configuration/PluginConfiguration.cs index b9957131..181e952e 100644 --- a/Shokofin/Configuration/PluginConfiguration.cs +++ b/Shokofin/Configuration/PluginConfiguration.cs @@ -82,8 +82,6 @@ public virtual string PrettyHost public UserConfiguration[] UserList { get; set; } - public string[] IgnoredFileExtensions { get; set; } - public string[] IgnoredFolders { get; set; } public bool? LibraryFilteringMode { get; set; } @@ -133,7 +131,6 @@ public PluginConfiguration() CollectionGrouping = CollectionCreationType.None; MovieOrdering = OrderType.Default; UserList = Array.Empty(); - IgnoredFileExtensions = new [] { ".nfo", ".jpg", ".jpeg", ".png" }; IgnoredFolders = new [] { ".streams", "@recently-snapshot" }; LibraryFilteringMode = null; EXPERIMENTAL_AutoMergeVersions = false; diff --git a/Shokofin/Configuration/configController.js b/Shokofin/Configuration/configController.js index 14adc630..34684052 100644 --- a/Shokofin/Configuration/configController.js +++ b/Shokofin/Configuration/configController.js @@ -8,38 +8,6 @@ const Messages = { UnableToRender: "There was an error loading the page, please refresh once to see if that will fix it.", }; -/** - * Filter out duplicate values and sanitize list. - * @param {string} value - Stringified list of values to filter. - * @returns {string[]} An array of sanitized and filtered values. - */ - function filterIgnoredExtensions(value) { - // We convert to a set to filter out duplicate values. - const filteredSet = new Set( - value - // Split the values at every space, tab, comma. - .split(/[\s,]+/g) - // Sanitize inputs. - .map(str => { - // Trim the start and end and convert to lower-case. - str = str.trim().toLowerCase(); - - // Add a dot if it's missing. - if (str[0] !== ".") - str = "." + str; - - return str; - }), - ); - - // Filter out empty values. - if (filteredSet.has("")) - filteredSet.delete(""); - - // Convert it back into an array. - return Array.from(filteredSet); -} - /** * Filter out duplicate values and sanitize list. * @param {string} value - Stringified list of values to filter. @@ -137,7 +105,6 @@ async function defaultSubmit(form) { publicHost = publicHost.slice(0, -1); form.querySelector("#PublicHost").value = publicHost; } - const ignoredFileExtensions = filterIgnoredExtensions(form.querySelector("#IgnoredFileExtensions").value); const ignoredFolders = filterIgnoredFolders(form.querySelector("#IgnoredFolders").value); const filteringModeRaw = form.querySelector("#LibraryFilteringMode").value; const filteringMode = filteringModeRaw === "true" ? true : filteringModeRaw === "false" ? false : null; @@ -176,8 +143,6 @@ async function defaultSubmit(form) { // Advanced settings config.PublicHost = publicHost; - config.IgnoredFileExtensions = ignoredFileExtensions; - form.querySelector("#IgnoredFileExtensions").value = ignoredFileExtensions.join(" "); config.IgnoredFolders = ignoredFolders; form.querySelector("#IgnoredFolders").value = ignoredFolders.join(); @@ -300,7 +265,6 @@ async function syncSettings(form) { publicHost = publicHost.slice(0, -1); form.querySelector("#PublicHost").value = publicHost; } - const ignoredFileExtensions = filterIgnoredExtensions(form.querySelector("#IgnoredFileExtensions").value); const ignoredFolders = filterIgnoredFolders(form.querySelector("#IgnoredFolders").value); const filteringModeRaw = form.querySelector("#LibraryFilteringMode").value; const filteringMode = filteringModeRaw === "true" ? true : filteringModeRaw === "false" ? false : null; @@ -339,8 +303,6 @@ async function syncSettings(form) { // Advanced settings config.PublicHost = publicHost; - config.IgnoredFileExtensions = ignoredFileExtensions; - form.querySelector("#IgnoredFileExtensions").value = ignoredFileExtensions.join(" "); config.IgnoredFolders = ignoredFolders; form.querySelector("#IgnoredFolders").value = ignoredFolders.join(); @@ -477,6 +439,12 @@ export default function (page) { form.querySelector("#VirtualFileSystem").addEventListener("change", function () { form.querySelector("#LibraryFilteringMode").disabled = this.checked; + if (this.checked) { + form.querySelector("#LibraryFilteringModeContainer").setAttribute("hidden", ""); + } + else { + form.querySelector("#LibraryFilteringModeContainer").removeAttribute("hidden"); + } }); page.addEventListener("viewshow", async function () { @@ -525,7 +493,6 @@ export default function (page) { // Advanced settings form.querySelector("#PublicHost").value = config.PublicHost; - form.querySelector("#IgnoredFileExtensions").value = config.IgnoredFileExtensions.join(" "); form.querySelector("#IgnoredFolders").value = config.IgnoredFolders.join(); // Experimental settings diff --git a/Shokofin/Configuration/configPage.html b/Shokofin/Configuration/configPage.html index b6e1b6ba..8c75921b 100644 --- a/Shokofin/Configuration/configPage.html +++ b/Shokofin/Configuration/configPage.html @@ -131,21 +131,41 @@

Plugin Compatibility Settings

Library Settings

-
If you wish to set the Series/Grouping setting below to "Don't group Series into Seasons", you must disable "Automatically merge series that are spread across multiple folders" in the settings for all Libraries that depend on Shokofin for their metadata.
On the other hand, if you want to have Series and Grouping be determined by Shoko, or TvDB/TMDB - you must enable the "Automatically merge series that are spread across multiple folders" setting for all Libraries that use Shokofin for their metadata.
See the settings under each individual Library here: Library Settings
+
Everything related to how the plugin manages the library.
+
+ + +
Determines how to group entities into Collections.
+
+
+ + +
Determines how Specials are placed within Seasons. Warning: Modifying this setting requires a recreation (read as; delete existing then create a new) of any libraries using this plugin — otherwise you will have mixed metadata.
+
-
Enables the use of the Virtual File System for any media libraries managed by the plugin.
+
Enables the use of the Virtual File System™ for any media libraries managed by the plugin.
- What does it do? + What does this mean? Enabling this setting should in theory make it so you won't have to think about file structure imcompatibilities, since it will override your existing file structure and replace it with a layer of symbolic links managed by the plugin instead of your actual file structure.Do not enable this for an existing library. If you do, then delete and re-create your library from scratch.
-
+ -
- - -
Determines how to group entities into Collections.
-
-
- - -
Determines how Specials are placed within Seasons. Warning: Modifying this setting requires a recreation (read as; delete existing then create a new) of any libraries using this plugin — otherwise you will have mixed metadata.
+
This filters out movies from the shows in your library. Disable this if you want your movies to show up as episodes within seasons of your shows instead.
Add a number to the title of each Special episode
@@ -348,10 +344,6 @@

Advanced Settings

This is the public URL leading to where Shoko is running. It is used to redirect to Shoko if you click on a Shoko ID in the UI if Shoko and/or Jellyfin is running within a container. It should include both the protocol and the IP/DNS name.
-
- -
A space separated list of file extensions which will be ignored during the library scan.
-
A comma separated list of folder names which will be ignored during the library scan.
diff --git a/Shokofin/Plugin.cs b/Shokofin/Plugin.cs index e79eed00..8a0e5167 100644 --- a/Shokofin/Plugin.cs +++ b/Shokofin/Plugin.cs @@ -32,20 +32,16 @@ public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) { Instance = this; ConfigurationChanged += OnConfigChanged; - IgnoredFileExtensions = this.Configuration.IgnoredFileExtensions.ToHashSet(); - IgnoredFolders = this.Configuration.IgnoredFolders.ToHashSet(); + IgnoredFolders = Configuration.IgnoredFolders.ToHashSet(); } public void OnConfigChanged(object? sender, BasePluginConfiguration e) { if (e is not PluginConfiguration config) return; - IgnoredFileExtensions = config.IgnoredFileExtensions.ToHashSet(); IgnoredFolders = config.IgnoredFolders.ToHashSet(); } - public HashSet IgnoredFileExtensions; - public HashSet IgnoredFolders; #pragma warning disable 8618 diff --git a/Shokofin/Resolvers/ShokoResolveManager.cs b/Shokofin/Resolvers/ShokoResolveManager.cs index 5a46d2b0..9e17f679 100644 --- a/Shokofin/Resolvers/ShokoResolveManager.cs +++ b/Shokofin/Resolvers/ShokoResolveManager.cs @@ -312,9 +312,11 @@ private async Task GenerateSymbolicLinks(Folder mediaFolder, IEnumerable<(string public async Task ShouldFilterItem(Folder? parent, FileSystemMetadata fileInfo) { - // Everything in the root folder is ignored by us. + if (parent == null || fileInfo == null) + return false; + var root = LibraryManager.RootFolder; - if (fileInfo == null || parent == null || root == null || parent == root || fileInfo.FullName.StartsWith(root.Path)) + if (root == null || parent == root) return false; try { @@ -326,12 +328,12 @@ public async Task ShouldFilterItem(Folder? parent, FileSystemMetadata file if (!Lookup.IsEnabledForItem(parent, out var isSoleProvider)) return false; - if (fileInfo.IsDirectory && Plugin.Instance.IgnoredFolders.Contains(Path.GetFileName(fileInfo.FullName).ToLowerInvariant())) { + if (fileInfo.IsDirectory && Plugin.Instance.IgnoredFolders.Contains(Path.GetFileName(fileInfo.FullName).ToLowerInvariant())) { Logger.LogDebug("Excluded folder at path {Path}", fileInfo.FullName); return true; } - if (!fileInfo.IsDirectory && Plugin.Instance.IgnoredFileExtensions.Contains(fileInfo.Extension.ToLowerInvariant())) { + if (!fileInfo.IsDirectory && !_namingOptions.VideoFileExtensions.Contains(fileInfo.Extension.ToLowerInvariant())) { Logger.LogDebug("Skipped excluded file at path {Path}", fileInfo.FullName); return false; } @@ -445,9 +447,11 @@ private async Task ScanFile(string partialPath, string fullPath, bool shou if (!Plugin.Instance.Configuration.VirtualFileSystem) return null; + if (!(collectionType == CollectionType.TvShows || collectionType == CollectionType.Movies || collectionType == null) || parent == null || fileInfo == null) + return null; + var root = LibraryManager.RootFolder; - if (!(collectionType == CollectionType.TvShows || collectionType == CollectionType.Movies || collectionType == null) || - fileInfo == null || parent == null || root == null || parent == root || fileInfo.FullName.StartsWith(root.Path)) + if (root == null || parent == root) return null; try { @@ -498,9 +502,11 @@ private async Task ScanFile(string partialPath, string fullPath, bool shou if (!Plugin.Instance.Configuration.VirtualFileSystem) return null; + if (!(collectionType == CollectionType.TvShows || collectionType == CollectionType.Movies || collectionType == null) || parent == null) + return null; + var root = LibraryManager.RootFolder; - if (!(collectionType == CollectionType.TvShows || collectionType == CollectionType.Movies || collectionType == null) || - root == null || parent == null || parent == root) + if (root == null || parent == root) return null; try {