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> /// </summary>
public string SelectedLibraries { get; set; } = string.Empty; 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> /// <summary>
/// Gets or sets a value indicating whether to analyze automatically, when new Items are added. /// Gets or sets a value indicating whether to analyze automatically, when new Items are added.
/// </summary> /// </summary>

View File

@ -7,7 +7,7 @@
<body> <body>
<div id="TemplateConfigPage" data-role="page" class="page type-interior pluginConfigurationPage" <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"> <div data-role="content">
<style> <style>
summary { summary {
@ -27,6 +27,31 @@
<fieldset class="verticalSection-extrabottompadding"> <fieldset class="verticalSection-extrabottompadding">
<legend>Analysis</legend> <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"> <div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label"> <label class="emby-checkbox-label">
<input id="AutomaticAnalysis" type="checkbox" is="emby-checkbox" /> <input id="AutomaticAnalysis" type="checkbox" is="emby-checkbox" />
@ -597,6 +622,8 @@
] ]
var booleanConfigurationFields = [ var booleanConfigurationFields = [
"DetectIntros",
"DetectCredits",
"AutomaticAnalysis", "AutomaticAnalysis",
"AnalyzeSeasonZero", "AnalyzeSeasonZero",
"RegenerateEdlFiles", "RegenerateEdlFiles",

View File

@ -23,6 +23,7 @@ public class Entrypoint : IServerEntryPoint
private readonly ILogger<Entrypoint> _logger; private readonly ILogger<Entrypoint> _logger;
private readonly ILoggerFactory _loggerFactory; private readonly ILoggerFactory _loggerFactory;
private Timer _queueTimer; private Timer _queueTimer;
private bool _analyzeAgain;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Entrypoint"/> class. /// Initializes a new instance of the <see cref="Entrypoint"/> class.
@ -160,7 +161,7 @@ public class Entrypoint : IServerEntryPoint
{ {
if (Plugin.Instance!.AnalyzerTaskIsRunning) 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 else
{ {
@ -195,25 +196,37 @@ public class Entrypoint : IServerEntryPoint
var progress = new Progress<double>(); var progress = new Progress<double>();
var cancellationToken = new CancellationToken(false); var cancellationToken = new CancellationToken(false);
// intro if (Plugin.Instance!.Configuration.DetectIntros)
var introductionAnalyzer = new BaseItemAnalyzerTask( {
AnalysisMode.Introduction, var baseIntroAnalyzer = new BaseItemAnalyzerTask(
_loggerFactory.CreateLogger<Entrypoint>(), AnalysisMode.Introduction,
_loggerFactory, _loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_libraryManager); _loggerFactory,
_libraryManager);
introductionAnalyzer.AnalyzeItems(progress, cancellationToken); baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken);
}
// outro if (Plugin.Instance!.Configuration.DetectCredits)
var creditsAnalyzer = new BaseItemAnalyzerTask( {
AnalysisMode.Credits, var baseCreditAnalyzer = new BaseItemAnalyzerTask(
_loggerFactory.CreateLogger<Entrypoint>(), AnalysisMode.Credits,
_loggerFactory, _loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_libraryManager); _loggerFactory,
_libraryManager);
creditsAnalyzer.AnalyzeItems(progress, cancellationToken); baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken);
}
Plugin.Instance!.AnalyzerTaskIsRunning = false; 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> /// <summary>

View File

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