migrate own repo url (#345)
This commit is contained in:
parent
89ae0b41e3
commit
c0513b1f22
@ -12,6 +12,7 @@ using MediaBrowser.Controller.Persistence;
|
|||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using MediaBrowser.Model.Updates;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
@ -118,6 +119,8 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
|
|
||||||
ConfigurationChanged += OnConfigurationChanged;
|
ConfigurationChanged += OnConfigurationChanged;
|
||||||
|
|
||||||
|
MigrateRepoUrl(serverConfiguration);
|
||||||
|
|
||||||
// TODO: remove when https://github.com/jellyfin/jellyfin-meta/discussions/30 is complete
|
// TODO: remove when https://github.com/jellyfin/jellyfin-meta/discussions/30 is complete
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -395,6 +398,52 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
AutoSkipCreditsChanged?.Invoke(this, EventArgs.Empty);
|
AutoSkipCreditsChanged?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MigrateRepoUrl(IServerConfigurationManager serverConfiguration)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<string> oldRepos =
|
||||||
|
[
|
||||||
|
"https://raw.githubusercontent.com/intro-skipper/intro-skipper/master/manifest.json",
|
||||||
|
"https://raw.githubusercontent.com/jumoog/intro-skipper/master/manifest.json"
|
||||||
|
];
|
||||||
|
// Access the current server configuration
|
||||||
|
var config = serverConfiguration.Configuration;
|
||||||
|
|
||||||
|
// Get the list of current plugin repositories
|
||||||
|
var pluginRepositories = config.PluginRepositories?.ToList() ?? [];
|
||||||
|
|
||||||
|
// check if old plugins exits
|
||||||
|
if (pluginRepositories.Exists(repo => repo != null && repo.Url != null && oldRepos.Contains(repo.Url)))
|
||||||
|
{
|
||||||
|
// remove all old plugins
|
||||||
|
pluginRepositories.RemoveAll(repo => repo != null && 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.workers.dev/manifest.json"))
|
||||||
|
{
|
||||||
|
// Add the new repository to the list
|
||||||
|
pluginRepositories.Add(new RepositoryInfo
|
||||||
|
{
|
||||||
|
Name = "intro skipper (automatically migrated by plugin)",
|
||||||
|
Url = "https://manifest.intro-skipper.workers.dev/manifest.json",
|
||||||
|
Enabled = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the configuration with the new repository list
|
||||||
|
config.PluginRepositories = [.. pluginRepositories];
|
||||||
|
|
||||||
|
// Save the updated configuration
|
||||||
|
serverConfiguration.SaveConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error occurred while migrating repo URL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Inject the skip button script into the web interface.
|
/// Inject the skip button script into the web interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user