From f32408109d4efd58040489f410689f77972a19fb Mon Sep 17 00:00:00 2001 From: Kilian von Pflugk Date: Sun, 27 Oct 2024 22:38:46 +0100 Subject: [PATCH] allow users to override the URL (#360) --- .../Configuration/PluginConfiguration.cs | 9 +++++++-- IntroSkipper/Plugin.cs | 20 +++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/IntroSkipper/Configuration/PluginConfiguration.cs b/IntroSkipper/Configuration/PluginConfiguration.cs index 8cdb72f..3451a46 100644 --- a/IntroSkipper/Configuration/PluginConfiguration.cs +++ b/IntroSkipper/Configuration/PluginConfiguration.cs @@ -248,12 +248,17 @@ public class PluginConfiguration : BasePluginConfiguration public string AutoSkipCreditsNotificationText { get; set; } = "Credits skipped"; /// - /// Gets or sets the number of threads for an ffmpeg process. + /// Gets or sets the number of threads for a ffmpeg process. /// public int ProcessThreads { get; set; } /// - /// Gets or sets the relative priority for an ffmpeg process. + /// Gets or sets the relative priority for a ffmpeg process. /// public ProcessPriorityClass ProcessPriority { get; set; } = ProcessPriorityClass.BelowNormal; + + /// + /// Gets or sets a value indicating whether the ManifestUrl is self-managed, e.g. for mainland China. + /// + public bool OverrideManifestUrl { get; set; } } diff --git a/IntroSkipper/Plugin.cs b/IntroSkipper/Plugin.cs index b6f8f52..8d61435 100644 --- a/IntroSkipper/Plugin.cs +++ b/IntroSkipper/Plugin.cs @@ -91,8 +91,6 @@ public class Plugin : BasePlugin, IHasWebPages XmlSerializationHelper.MigrateXML(_introPath); XmlSerializationHelper.MigrateXML(_creditsPath); - MigrateRepoUrl(serverConfiguration); - var oldConfigFile = Path.Join(applicationPaths.PluginConfigurationsPath, "ConfusedPolarBear.Plugin.IntroSkipper.xml"); if (File.Exists(oldConfigFile)) @@ -123,6 +121,8 @@ public class Plugin : BasePlugin, IHasWebPages } } + MigrateRepoUrl(serverConfiguration); + // TODO: remove when https://github.com/jellyfin/jellyfin-meta/discussions/30 is complete try { @@ -457,16 +457,16 @@ public class Plugin : BasePlugin, IHasWebPages var config = serverConfiguration.Configuration; // Get the list of current plugin repositories - var pluginRepositories = config.PluginRepositories?.ToList() ?? []; + var pluginRepositories = config.PluginRepositories.ToList(); // check if old plugins exits - if (pluginRepositories.Exists(repo => repo != null && repo.Url != null && oldRepos.Contains(repo.Url))) + if (pluginRepositories.Exists(repo => repo.Url != null && oldRepos.Contains(repo.Url))) { // remove all old plugins - pluginRepositories.RemoveAll(repo => repo != null && repo.Url != null && oldRepos.Contains(repo.Url)); + pluginRepositories.RemoveAll(repo => repo.Url != null && oldRepos.Contains(repo.Url)); - // Add repository only if it does not exit - if (!pluginRepositories.Exists(repo => repo.Url == "https://manifest.intro-skipper.org/manifest.json")) + // Add repository only if it does not exit and the OverideManifestUrl Option is activated + if (!pluginRepositories.Exists(repo => repo.Url == "https://manifest.intro-skipper.org/manifest.json") && Instance!.Configuration.OverrideManifestUrl) { // Add the new repository to the list pluginRepositories.Add(new RepositoryInfo @@ -499,8 +499,7 @@ public class Plugin : BasePlugin, IHasWebPages string searchPattern = "dashboard-dashboard.*.chunk.js"; string[] filePaths = Directory.GetFiles(webPath, searchPattern, SearchOption.TopDirectoryOnly); string pattern = @"buildVersion""\)\.innerText=""(?\d+\.\d+\.\d+)"",.*?webVersion""\)\.innerText=""(?\d+\.\d+\.\d+)"; - string buildVersionString = "unknow"; - string webVersionString = "unknow"; + string webVersionString = "unknown"; // Create a Regex object Regex regex = new Regex(pattern); @@ -513,14 +512,13 @@ public class Plugin : BasePlugin, IHasWebPages // search for buildVersion and webVersion if (match.Success) { - buildVersionString = match.Groups["buildVersion"].Value; webVersionString = match.Groups["webVersion"].Value; _logger.LogInformation("Found jellyfin-web <{WebVersion}>", webVersionString); break; } } - if (webVersionString != "unknow") + if (webVersionString != "unknown") { // append Revision webVersionString += ".0";