Add EDL regeneration flag
This commit is contained in:
parent
b83fcdd3a1
commit
7591025297
@ -32,9 +32,11 @@ public class PluginConfiguration : BasePluginConfiguration
|
|||||||
public EdlAction EdlAction { get; set; } = EdlAction.None;
|
public EdlAction EdlAction { get; set; } = EdlAction.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool OverwriteExistingEdlFiles { get; set; } = false;
|
public bool RegenerateEdlFiles { get; set; } = false;
|
||||||
|
|
||||||
// ===== Playback settings =====
|
// ===== Playback settings =====
|
||||||
|
|
||||||
|
@ -71,19 +71,18 @@
|
|||||||
<a href="https://kodi.wiki/view/Edit_decision_list">MPlayer compatible EDL files</a>
|
<a href="https://kodi.wiki/view/Edit_decision_list">MPlayer compatible EDL files</a>
|
||||||
alongside your episode files. <br />
|
alongside your episode files. <br />
|
||||||
|
|
||||||
If this value is changed after EDL files are generated, you must either manually delete
|
If this value is changed after EDL files are generated, you must check the "Regenerate EDL files" checkbox below.
|
||||||
the EDL files or check the "Overwrite existing EDL files" checkbox below.
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||||
<label class="emby-checkbox-label">
|
<label class="emby-checkbox-label">
|
||||||
<input id="OverwriteEdl" type="checkbox" is="emby-checkbox" />
|
<input id="RegenerateEdl" type="checkbox" is="emby-checkbox" />
|
||||||
<span>Overwrite existing EDL files</span>
|
<span>Regenerate EDL files during next scan</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="fieldDescription">
|
<div class="fieldDescription">
|
||||||
If checked, the plugin will overwrite any EDL files associated with your episode files.
|
If checked, the plugin will <strong>overwrite all EDL files</strong> associated with your episodes with the currently discovered introduction timestamps and EDL action.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@ -489,7 +488,7 @@
|
|||||||
document.querySelector('#MaxParallelism').value = config.MaxParallelism;
|
document.querySelector('#MaxParallelism').value = config.MaxParallelism;
|
||||||
|
|
||||||
document.querySelector('#EdlAction').value = config.EdlAction;
|
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('#CacheFingerprints').checked = config.CacheFingerprints;
|
||||||
document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment;
|
document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment;
|
||||||
@ -507,7 +506,7 @@
|
|||||||
config.MaxParallelism = document.querySelector('#MaxParallelism').value;
|
config.MaxParallelism = document.querySelector('#MaxParallelism').value;
|
||||||
|
|
||||||
config.EdlAction = document.querySelector('#EdlAction').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.CacheFingerprints = document.querySelector('#CacheFingerprints').checked;
|
||||||
config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value;
|
config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
namespace ConfusedPolarBear.Plugin.IntroSkipper;
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -20,13 +21,35 @@ public static class EdlManager
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs the configuration that will be used during EDL file creation.
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If the EDL action is set to a value other than None, update EDL files for the provided episodes.
|
/// If the EDL action is set to a value other than None, update EDL files for the provided episodes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="episodes">Episodes to update EDL files for.</param>
|
/// <param name="episodes">Episodes to update EDL files for.</param>
|
||||||
public static void UpdateEDLFiles(ReadOnlyCollection<QueuedEpisode> episodes)
|
public static void UpdateEDLFiles(ReadOnlyCollection<QueuedEpisode> episodes)
|
||||||
{
|
{
|
||||||
var overwrite = Plugin.Instance!.Configuration.OverwriteExistingEdlFiles;
|
var regenerate = Plugin.Instance!.Configuration.RegenerateEdlFiles;
|
||||||
var action = Plugin.Instance!.Configuration.EdlAction;
|
var action = Plugin.Instance!.Configuration.EdlAction;
|
||||||
if (action == EdlAction.None)
|
if (action == EdlAction.None)
|
||||||
{
|
{
|
||||||
@ -39,12 +62,18 @@ public static class EdlManager
|
|||||||
foreach (var episode in episodes)
|
foreach (var episode in episodes)
|
||||||
{
|
{
|
||||||
var id = episode.EpisodeId;
|
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));
|
var edlPath = GetEdlPath(Plugin.Instance!.GetItemPath(id));
|
||||||
|
|
||||||
_logger?.LogTrace("Episode {Id} has EDL path {Path}", id, edlPath);
|
_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);
|
_logger?.LogTrace("Refusing to overwrite existing EDL file {Path}", edlPath);
|
||||||
continue;
|
continue;
|
||||||
|
@ -137,6 +137,9 @@ public class FingerprinterTask : IScheduledTask
|
|||||||
"No episodes to analyze: either no show libraries are defined or ffmpeg could not be found");
|
"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.
|
// Include the previously processed episodes in the percentage reported to the UI.
|
||||||
var totalProcessed = CountProcessedEpisodes();
|
var totalProcessed = CountProcessedEpisodes();
|
||||||
|
|
||||||
@ -145,6 +148,7 @@ public class FingerprinterTask : IScheduledTask
|
|||||||
MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism
|
MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Analyze all episodes in the queue using the degrees of parallelism the user specified.
|
||||||
Parallel.ForEach(queue, options, (season) =>
|
Parallel.ForEach(queue, options, (season) =>
|
||||||
{
|
{
|
||||||
var first = season.Value[0];
|
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).
|
// (instead of just using the number of episodes in the current season).
|
||||||
var analyzed = AnalyzeSeason(season, cancellationToken);
|
var analyzed = AnalyzeSeason(season, cancellationToken);
|
||||||
Interlocked.Add(ref totalProcessed, analyzed);
|
Interlocked.Add(ref totalProcessed, analyzed);
|
||||||
writeEdl = analyzed > 0;
|
writeEdl = analyzed > 0 || Plugin.Instance!.Configuration.RegenerateEdlFiles;
|
||||||
}
|
}
|
||||||
catch (FingerprintException ex)
|
catch (FingerprintException ex)
|
||||||
{
|
{
|
||||||
@ -193,6 +197,14 @@ public class FingerprinterTask : IScheduledTask
|
|||||||
progress.Report((totalProcessed * 100) / Plugin.Instance!.TotalQueued);
|
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;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user