allow users to override the URL (#360)
e.g. intro-skipper.org is not available for use in mainland China
This commit is contained in:
parent
718a86945e
commit
6d93df1c76
@ -248,12 +248,17 @@ public class PluginConfiguration : BasePluginConfiguration
|
|||||||
public string AutoSkipCreditsNotificationText { get; set; } = "Credits skipped";
|
public string AutoSkipCreditsNotificationText { get; set; } = "Credits skipped";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the number of threads for an ffmpeg process.
|
/// Gets or sets the number of threads for a ffmpeg process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ProcessThreads { get; set; }
|
public int ProcessThreads { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the relative priority for an ffmpeg process.
|
/// Gets or sets the relative priority for a ffmpeg process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProcessPriorityClass ProcessPriority { get; set; } = ProcessPriorityClass.BelowNormal;
|
public ProcessPriorityClass ProcessPriority { get; set; } = ProcessPriorityClass.BelowNormal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the ManifestUrl is self-managed, e.g. for mainland China.
|
||||||
|
/// </summary>
|
||||||
|
public bool OverrideManifestUrl { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,6 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
XmlSerializationHelper.MigrateXML(_introPath);
|
XmlSerializationHelper.MigrateXML(_introPath);
|
||||||
XmlSerializationHelper.MigrateXML(_creditsPath);
|
XmlSerializationHelper.MigrateXML(_creditsPath);
|
||||||
|
|
||||||
MigrateRepoUrl(serverConfiguration);
|
|
||||||
|
|
||||||
var oldConfigFile = Path.Join(applicationPaths.PluginConfigurationsPath, "ConfusedPolarBear.Plugin.IntroSkipper.xml");
|
var oldConfigFile = Path.Join(applicationPaths.PluginConfigurationsPath, "ConfusedPolarBear.Plugin.IntroSkipper.xml");
|
||||||
|
|
||||||
if (File.Exists(oldConfigFile))
|
if (File.Exists(oldConfigFile))
|
||||||
@ -124,6 +122,8 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
@ -458,16 +458,16 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
var config = serverConfiguration.Configuration;
|
var config = serverConfiguration.Configuration;
|
||||||
|
|
||||||
// Get the list of current plugin repositories
|
// Get the list of current plugin repositories
|
||||||
var pluginRepositories = config.PluginRepositories?.ToList() ?? [];
|
var pluginRepositories = config.PluginRepositories.ToList();
|
||||||
|
|
||||||
// check if old plugins exits
|
// 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
|
// 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
|
// 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"))
|
if (!pluginRepositories.Exists(repo => repo.Url == "https://manifest.intro-skipper.org/manifest.json") && Instance!.Configuration.OverrideManifestUrl)
|
||||||
{
|
{
|
||||||
// Add the new repository to the list
|
// Add the new repository to the list
|
||||||
pluginRepositories.Add(new RepositoryInfo
|
pluginRepositories.Add(new RepositoryInfo
|
||||||
@ -500,8 +500,7 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
string searchPattern = "dashboard-dashboard.*.chunk.js";
|
string searchPattern = "dashboard-dashboard.*.chunk.js";
|
||||||
string[] filePaths = Directory.GetFiles(webPath, searchPattern, SearchOption.TopDirectoryOnly);
|
string[] filePaths = Directory.GetFiles(webPath, searchPattern, SearchOption.TopDirectoryOnly);
|
||||||
string pattern = @"buildVersion""\)\.innerText=""(?<buildVersion>\d+\.\d+\.\d+)"",.*?webVersion""\)\.innerText=""(?<webVersion>\d+\.\d+\.\d+)";
|
string pattern = @"buildVersion""\)\.innerText=""(?<buildVersion>\d+\.\d+\.\d+)"",.*?webVersion""\)\.innerText=""(?<webVersion>\d+\.\d+\.\d+)";
|
||||||
string buildVersionString = "unknow";
|
string webVersionString = "unknown";
|
||||||
string webVersionString = "unknow";
|
|
||||||
// Create a Regex object
|
// Create a Regex object
|
||||||
Regex regex = new Regex(pattern);
|
Regex regex = new Regex(pattern);
|
||||||
|
|
||||||
@ -514,14 +513,13 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
// search for buildVersion and webVersion
|
// search for buildVersion and webVersion
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
buildVersionString = match.Groups["buildVersion"].Value;
|
|
||||||
webVersionString = match.Groups["webVersion"].Value;
|
webVersionString = match.Groups["webVersion"].Value;
|
||||||
_logger.LogInformation("Found jellyfin-web <{WebVersion}>", webVersionString);
|
_logger.LogInformation("Found jellyfin-web <{WebVersion}>", webVersionString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (webVersionString != "unknow")
|
if (webVersionString != "unknown")
|
||||||
{
|
{
|
||||||
// append Revision
|
// append Revision
|
||||||
webVersionString += ".0";
|
webVersionString += ".0";
|
||||||
@ -565,12 +563,17 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
if (!Instance!.Configuration.SkipButtonEnabled)
|
if (!Instance!.Configuration.SkipButtonEnabled)
|
||||||
{
|
{
|
||||||
pattern = @"<script src=""configurationpage\?name=skip-intro-button\.js.*<\/script>";
|
pattern = @"<script src=""configurationpage\?name=skip-intro-button\.js.*<\/script>";
|
||||||
|
if (!Regex.IsMatch(contents, pattern, RegexOptions.IgnoreCase))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
contents = Regex.Replace(contents, pattern, string.Empty, RegexOptions.IgnoreCase);
|
contents = Regex.Replace(contents, pattern, string.Empty, RegexOptions.IgnoreCase);
|
||||||
File.WriteAllText(indexPath, contents);
|
File.WriteAllText(indexPath, contents);
|
||||||
return; // Button is disabled, so remove and abort
|
return; // Button is disabled, so remove and abort
|
||||||
}
|
}
|
||||||
|
|
||||||
// change URL with every release to prevent the Browers from caching
|
// change URL with every release to prevent the Browsers from caching
|
||||||
string scriptTag = "<script src=\"configurationpage?name=skip-intro-button.js&release=" + GetType().Assembly.GetName().Version + "\"></script>";
|
string scriptTag = "<script src=\"configurationpage?name=skip-intro-button.js&release=" + GetType().Assembly.GetName().Version + "\"></script>";
|
||||||
|
|
||||||
// Only inject the script tag once
|
// Only inject the script tag once
|
||||||
|
Loading…
x
Reference in New Issue
Block a user