add options to disable scans of either intros or credits

This commit is contained in:
rlauu 2024-03-30 19:02:18 +01:00 committed by TwistedUmbrellaX
parent 3446c180aa
commit 2e67a4fb5e
4 changed files with 84 additions and 33 deletions

View File

@ -27,6 +27,16 @@ public class PluginConfiguration : BasePluginConfiguration
/// </summary>
public string SelectedLibraries { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether to scan for intros during a scheduled task.
/// </summary>
public bool DetectIntros { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether to scan for credits during a scheduled task.
/// </summary>
public bool DetectCredits { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether to analyze automatically, when new Items are added.
/// </summary>

View File

@ -7,7 +7,7 @@
<body>
<div id="TemplateConfigPage" data-role="page" class="page type-interior pluginConfigurationPage"
data-require="emby-input,emby-button,emby-select,emby-checkbox">
data-require="emby-input,emby-button,emby-select,emby-checkbox,emby-linkbutton">
<div data-role="content">
<style>
summary {
@ -27,6 +27,31 @@
<fieldset class="verticalSection-extrabottompadding">
<legend>Analysis</legend>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="DetectIntros" type="checkbox" is="emby-checkbox" />
<span>Detect Introductions</span>
</label>
<div class="fieldDescription">
This option enables scheduled introduction detection. Your videos will be scanned for introductions during a scheduled task.
</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="DetectCredits" type="checkbox" is="emby-checkbox" />
<span>Detect Credits</span>
</label>
<div class="fieldDescription">
This option enables scheduled credit detection. Your videos will be scanned for credits during a scheduled task.
</div>
<div class="fieldDescription">
Note: Selecting neither Intro nor Credit Detection will disable automatic scans. To configure the scheduled task, see <a is="emby-linkbutton" class="button-link" href="scheduledtasks.html">scheduled tasks</a>.
</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="AutomaticAnalysis" type="checkbox" is="emby-checkbox" />
@ -597,6 +622,8 @@
]
var booleanConfigurationFields = [
"DetectIntros",
"DetectCredits",
"AutomaticAnalysis",
"AnalyzeSeasonZero",
"RegenerateEdlFiles",

View File

@ -23,6 +23,7 @@ public class Entrypoint : IServerEntryPoint
private readonly ILogger<Entrypoint> _logger;
private readonly ILoggerFactory _loggerFactory;
private Timer _queueTimer;
private bool _analyzeAgain;
/// <summary>
/// Initializes a new instance of the <see cref="Entrypoint"/> class.
@ -160,7 +161,7 @@ public class Entrypoint : IServerEntryPoint
{
if (Plugin.Instance!.AnalyzerTaskIsRunning)
{
return; // Don't do anything if a Analyzer is running
_analyzeAgain = true; // Items added during a scan will be included later.
}
else
{
@ -195,25 +196,37 @@ public class Entrypoint : IServerEntryPoint
var progress = new Progress<double>();
var cancellationToken = new CancellationToken(false);
// intro
var introductionAnalyzer = new BaseItemAnalyzerTask(
if (Plugin.Instance!.Configuration.DetectIntros)
{
var baseIntroAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Introduction,
_loggerFactory.CreateLogger<Entrypoint>(),
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_loggerFactory,
_libraryManager);
introductionAnalyzer.AnalyzeItems(progress, cancellationToken);
baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken);
}
// outro
var creditsAnalyzer = new BaseItemAnalyzerTask(
if (Plugin.Instance!.Configuration.DetectCredits)
{
var baseCreditAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Credits,
_loggerFactory.CreateLogger<Entrypoint>(),
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_loggerFactory,
_libraryManager);
creditsAnalyzer.AnalyzeItems(progress, cancellationToken);
baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken);
}
Plugin.Instance!.AnalyzerTaskIsRunning = false;
// New item detected, start timer again
if (_analyzeAgain)
{
_logger.LogInformation("Analyzing ended, but we need to analyze again!");
_analyzeAgain = false;
StartTimer();
}
}
/// <summary>

View File

@ -73,7 +73,8 @@ public class DetectIntrosAndCreditsTask : IScheduledTask
Plugin.Instance!.AnalyzerTaskIsRunning = true;
}
// intro
if (Plugin.Instance!.Configuration.DetectIntros)
{
var baseIntroAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Introduction,
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
@ -81,11 +82,10 @@ public class DetectIntrosAndCreditsTask : IScheduledTask
_libraryManager);
baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken);
}
// reset progress
progress.Report(0);
// outro
if (Plugin.Instance!.Configuration.DetectCredits)
{
var baseCreditAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Credits,
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
@ -93,6 +93,7 @@ public class DetectIntrosAndCreditsTask : IScheduledTask
_libraryManager);
baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken);
}
Plugin.Instance!.AnalyzerTaskIsRunning = false;