Remove old Path (#326)

and clean up

Co-authored-by: rlauu <46294892+rlauu@users.noreply.github.com>
This commit is contained in:
rlauuzo 2024-10-05 18:15:48 +02:00 committed by GitHub
parent bed71516ff
commit 8a323144ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 59 deletions

View File

@ -9,8 +9,6 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Configuration;
/// </summary>
public class PluginConfiguration : BasePluginConfiguration
{
private bool? _selectAllLibraries;
/// <summary>
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
/// </summary>
@ -33,11 +31,7 @@ public class PluginConfiguration : BasePluginConfiguration
/// <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;
}
public bool SelectAllLibraries { get; set; } = true;
/// <summary>
/// Gets or sets the list of client to auto skip for.
@ -47,17 +41,17 @@ public class PluginConfiguration : BasePluginConfiguration
/// <summary>
/// Gets or sets a value indicating whether to scan for intros during a scheduled task.
/// </summary>
public bool AutoDetectIntros { get; set; } = false;
public bool AutoDetectIntros { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to scan for credits during a scheduled task.
/// </summary>
public bool AutoDetectCredits { get; set; } = false;
public bool AutoDetectCredits { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to analyze season 0.
/// </summary>
public bool AnalyzeSeasonZero { get; set; } = false;
public bool AnalyzeSeasonZero { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the episode's fingerprint should be cached to the filesystem.
@ -182,7 +176,7 @@ public class PluginConfiguration : BasePluginConfiguration
/// <summary>
/// Gets or sets the amount of intro at start to play (in seconds).
/// </summary>
public int SecondsOfIntroStartToPlay { get; set; } = 0;
public int SecondsOfIntroStartToPlay { get; set; }
/// <summary>
/// Gets or sets the amount of credit at start to play (in seconds).

View File

@ -70,54 +70,6 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
_creditsPath = Path.Join(applicationPaths.DataPath, pluginDirName, "credits.xml");
_ignorelistPath = Path.Join(applicationPaths.DataPath, pluginDirName, "ignorelist.xml");
var cacheRoot = applicationPaths.CachePath;
var oldIntrosDirectory = Path.Join(cacheRoot, pluginDirName);
if (!Directory.Exists(oldIntrosDirectory))
{
pluginDirName = "intros";
pluginCachePath = "cache";
cacheRoot = applicationPaths.PluginConfigurationsPath;
oldIntrosDirectory = Path.Join(cacheRoot, pluginDirName);
}
var oldFingerprintCachePath = Path.Join(oldIntrosDirectory, pluginCachePath);
var oldIntroPath = Path.Join(cacheRoot, pluginDirName, "intros.xml");
var oldCreditsPath = Path.Join(cacheRoot, pluginDirName, "credits.xml");
// Create the base & cache directories (if needed).
if (!Directory.Exists(FingerprintCachePath))
{
Directory.CreateDirectory(FingerprintCachePath);
// Check if the old cache directory exists
if (Directory.Exists(oldFingerprintCachePath))
{
// move intro.xml if exists
if (File.Exists(oldIntroPath))
{
File.Move(oldIntroPath, _introPath);
}
// move credits.xml if exists
if (File.Exists(oldCreditsPath))
{
File.Move(oldCreditsPath, _creditsPath);
}
// Move the contents from old directory to new directory
string[] files = Directory.GetFiles(oldFingerprintCachePath);
foreach (string file in files)
{
string fileName = Path.GetFileName(file);
string destFile = Path.Combine(FingerprintCachePath, fileName);
File.Move(file, destFile);
}
// Optionally, you may delete the old directory after moving its contents
Directory.Delete(oldIntrosDirectory, true);
}
}
// migrate from XMLSchema to DataContract
XmlSerializationHelper.MigrateXML(_introPath);
XmlSerializationHelper.MigrateXML(_creditsPath);