move plugin cache into jellyfins cache
Enhance the organization of the introskipper plugin by relocating its data into Jellyfin's cache directory, aligning it with most plugins. Create a dedicated directory within Jellyfin's cache directory to store introskipper data. Move existing introskipper data files, including intros.xml and credits.xml, to the new cache directory.
This commit is contained in:
parent
3a9c553ed2
commit
a98525ddaa
@ -30,6 +30,9 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
private ILogger<Plugin> _logger;
|
private ILogger<Plugin> _logger;
|
||||||
private string _introPath;
|
private string _introPath;
|
||||||
private string _creditsPath;
|
private string _creditsPath;
|
||||||
|
private string _oldintroPath;
|
||||||
|
private string _oldcreditsPath;
|
||||||
|
private string _oldFingerprintCachePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Plugin"/> class.
|
/// Initializes a new instance of the <see cref="Plugin"/> class.
|
||||||
@ -58,15 +61,38 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
|
|
||||||
FFmpegPath = serverConfiguration.GetEncodingOptions().EncoderAppPathDisplay;
|
FFmpegPath = serverConfiguration.GetEncodingOptions().EncoderAppPathDisplay;
|
||||||
|
|
||||||
var introsDirectory = Path.Join(applicationPaths.PluginConfigurationsPath, "intros");
|
var introsDirectory = Path.Join(applicationPaths.CachePath, "introskipper");
|
||||||
FingerprintCachePath = Path.Join(introsDirectory, "cache");
|
FingerprintCachePath = Path.Join(introsDirectory, "chromaprints");
|
||||||
_introPath = Path.Join(applicationPaths.PluginConfigurationsPath, "intros", "intros.xml");
|
_introPath = Path.Join(applicationPaths.CachePath, "introskipper", "intros.xml");
|
||||||
_creditsPath = Path.Join(applicationPaths.PluginConfigurationsPath, "intros", "credits.xml");
|
_creditsPath = Path.Join(applicationPaths.CachePath, "introskipper", "credits.xml");
|
||||||
|
|
||||||
|
var oldintrosDirectory = Path.Join(applicationPaths.PluginConfigurationsPath, "intros");
|
||||||
|
_oldFingerprintCachePath = Path.Join(oldintrosDirectory, "cache");
|
||||||
|
_oldintroPath = Path.Join(applicationPaths.PluginConfigurationsPath, "intros", "intros.xml");
|
||||||
|
_oldcreditsPath = Path.Join(applicationPaths.PluginConfigurationsPath, "intros", "credits.xml");
|
||||||
|
|
||||||
// Create the base & cache directories (if needed).
|
// Create the base & cache directories (if needed).
|
||||||
if (!Directory.Exists(FingerprintCachePath))
|
if (!Directory.Exists(FingerprintCachePath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(FingerprintCachePath);
|
Directory.CreateDirectory(FingerprintCachePath);
|
||||||
|
|
||||||
|
// Check if the old cache directory exists
|
||||||
|
if (Directory.Exists(_oldFingerprintCachePath))
|
||||||
|
{
|
||||||
|
// Move the contents from old directory to new directory
|
||||||
|
File.Move(_oldintroPath, _introPath);
|
||||||
|
File.Move(_oldcreditsPath, _creditsPath);
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationChanged += OnConfigurationChanged;
|
ConfigurationChanged += OnConfigurationChanged;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user