diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs
index c712b3b..d62acef 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs
@@ -32,9 +32,11 @@ public class PluginConfiguration : BasePluginConfiguration
public EdlAction EdlAction { get; set; } = EdlAction.None;
///
- /// Gets or sets a value indicating whether or not to overwrite existing EDL files.
+ /// Gets or sets a value indicating whether to regenerate all EDL files during the next scan.
+ /// By default, EDL files are only written for a season if the season had at least one newly analyzed episode.
+ /// If this is set, all EDL files will be regenerated and overwrite any existing EDL file.
///
- public bool OverwriteExistingEdlFiles { get; set; } = false;
+ public bool RegenerateEdlFiles { get; set; } = false;
// ===== Playback settings =====
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html
index 540657a..c42b0b6 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html
@@ -71,19 +71,18 @@
MPlayer compatible EDL files
alongside your episode files.
- If this value is changed after EDL files are generated, you must either manually delete
- the EDL files or check the "Overwrite existing EDL files" checkbox below.
+ If this value is changed after EDL files are generated, you must check the "Regenerate EDL files" checkbox below.
@@ -489,7 +488,7 @@
document.querySelector('#MaxParallelism').value = config.MaxParallelism;
document.querySelector('#EdlAction').value = config.EdlAction;
- document.querySelector('#OverwriteEdl').checked = config.OverwriteExistingEdlFiles;
+ document.querySelector('#RegenerateEdl').checked = config.RegenerateEdlFiles;
document.querySelector('#CacheFingerprints').checked = config.CacheFingerprints;
document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment;
@@ -507,7 +506,7 @@
config.MaxParallelism = document.querySelector('#MaxParallelism').value;
config.EdlAction = document.querySelector('#EdlAction').value;
- config.OverwriteExistingEdlFiles = document.querySelector('#OverwriteEdl').checked;
+ config.RegenerateEdlFiles = document.querySelector('#RegenerateEdl').checked;
config.CacheFingerprints = document.querySelector('#CacheFingerprints').checked;
config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value;
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs
index 38e2d16..ac2386f 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/EdlManager.cs
@@ -1,5 +1,6 @@
namespace ConfusedPolarBear.Plugin.IntroSkipper;
+using System;
using System.Collections.ObjectModel;
using System.IO;
using Microsoft.Extensions.Logging;
@@ -20,13 +21,35 @@ public static class EdlManager
_logger = logger;
}
+ ///
+ /// Logs the configuration that will be used during EDL file creation.
+ ///
+ public static void LogConfiguration()
+ {
+ if (_logger is null)
+ {
+ throw new InvalidOperationException("Logger must not be null");
+ }
+
+ var config = Plugin.Instance!.Configuration;
+
+ if (config.EdlAction == EdlAction.None)
+ {
+ _logger.LogDebug("EDL action: None - taking no further action");
+ return;
+ }
+
+ _logger.LogDebug("EDL action: {Action}", config.EdlAction);
+ _logger.LogDebug("Regenerate EDL files: {Regenerate}", config.RegenerateEdlFiles);
+ }
+
///
/// If the EDL action is set to a value other than None, update EDL files for the provided episodes.
///
/// Episodes to update EDL files for.
public static void UpdateEDLFiles(ReadOnlyCollection episodes)
{
- var overwrite = Plugin.Instance!.Configuration.OverwriteExistingEdlFiles;
+ var regenerate = Plugin.Instance!.Configuration.RegenerateEdlFiles;
var action = Plugin.Instance!.Configuration.EdlAction;
if (action == EdlAction.None)
{
@@ -39,12 +62,18 @@ public static class EdlManager
foreach (var episode in episodes)
{
var id = episode.EpisodeId;
- var intro = Plugin.Instance!.Intros[id];
+
+ if (!Plugin.Instance!.Intros.TryGetValue(id, out var intro))
+ {
+ _logger?.LogDebug("Episode {Id} did not have an introduction, skipping", id);
+ continue;
+ }
+
var edlPath = GetEdlPath(Plugin.Instance!.GetItemPath(id));
_logger?.LogTrace("Episode {Id} has EDL path {Path}", id, edlPath);
- if (!overwrite && File.Exists(edlPath))
+ if (!regenerate && File.Exists(edlPath))
{
_logger?.LogTrace("Refusing to overwrite existing EDL file {Path}", edlPath);
continue;
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs
index 24ee83a..7067e88 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs
@@ -137,6 +137,9 @@ public class FingerprinterTask : IScheduledTask
"No episodes to analyze: either no show libraries are defined or ffmpeg could not be found");
}
+ // Log EDL settings
+ EdlManager.LogConfiguration();
+
// Include the previously processed episodes in the percentage reported to the UI.
var totalProcessed = CountProcessedEpisodes();
@@ -145,6 +148,7 @@ public class FingerprinterTask : IScheduledTask
MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism
};
+ // Analyze all episodes in the queue using the degrees of parallelism the user specified.
Parallel.ForEach(queue, options, (season) =>
{
var first = season.Value[0];
@@ -156,7 +160,7 @@ public class FingerprinterTask : IScheduledTask
// (instead of just using the number of episodes in the current season).
var analyzed = AnalyzeSeason(season, cancellationToken);
Interlocked.Add(ref totalProcessed, analyzed);
- writeEdl = analyzed > 0;
+ writeEdl = analyzed > 0 || Plugin.Instance!.Configuration.RegenerateEdlFiles;
}
catch (FingerprintException ex)
{
@@ -193,6 +197,14 @@ public class FingerprinterTask : IScheduledTask
progress.Report((totalProcessed * 100) / Plugin.Instance!.TotalQueued);
});
+ // Turn the regenerate EDL flag off after the scan completes.
+ if (Plugin.Instance!.Configuration.RegenerateEdlFiles)
+ {
+ _logger.LogInformation("Turning EDL file regeneration flag off");
+ Plugin.Instance!.Configuration.RegenerateEdlFiles = false;
+ Plugin.Instance!.SaveConfiguration();
+ }
+
return Task.CompletedTask;
}