Skip to content

Commit

Permalink
Revert "Revert "add options to disable scans of either intros or cred…
Browse files Browse the repository at this point in the history
…its""

This reverts commit 3c3024a.
  • Loading branch information
rlauuzo committed Mar 30, 2024
1 parent 3c3024a commit 126c0c8
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ public PluginConfiguration()
/// </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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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" />
Expand Down Expand Up @@ -597,6 +622,8 @@ <h3>Fingerprint Visualizer</h3>
]

var booleanConfigurationFields = [
"DetectIntros",
"DetectCredits",
"AutomaticAnalysis",
"AnalyzeSeasonZero",
"RegenerateEdlFiles",
Expand Down
43 changes: 28 additions & 15 deletions ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -160,7 +161,7 @@ private void StartTimer()
{
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
{
Expand Down Expand Up @@ -195,25 +196,37 @@ private void PerformAnalysis()
var progress = new Progress<double>();
var cancellationToken = new CancellationToken(false);

// intro
var introductionAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Introduction,
_loggerFactory.CreateLogger<Entrypoint>(),
_loggerFactory,
_libraryManager);
if (Plugin.Instance!.Configuration.DetectIntros)
{
var baseIntroAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Introduction,
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_loggerFactory,
_libraryManager);

introductionAnalyzer.AnalyzeItems(progress, cancellationToken);
baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken);
}

// outro
var creditsAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Credits,
_loggerFactory.CreateLogger<Entrypoint>(),
_loggerFactory,
_libraryManager);
if (Plugin.Instance!.Configuration.DetectCredits)
{
var baseCreditAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Credits,
_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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,27 @@ public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellat
Plugin.Instance!.AnalyzerTaskIsRunning = true;
}

// intro
var baseIntroAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Introduction,
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_loggerFactory,
_libraryManager);

baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken);

// reset progress
progress.Report(0);

// outro
var baseCreditAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Credits,
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_loggerFactory,
_libraryManager);

baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken);
if (Plugin.Instance!.Configuration.DetectIntros)
{
var baseIntroAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Introduction,
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_loggerFactory,
_libraryManager);

baseIntroAnalyzer.AnalyzeItems(progress, cancellationToken);
}

if (Plugin.Instance!.Configuration.DetectCredits)
{
var baseCreditAnalyzer = new BaseItemAnalyzerTask(
AnalysisMode.Credits,
_loggerFactory.CreateLogger<DetectIntrosAndCreditsTask>(),
_loggerFactory,
_libraryManager);

baseCreditAnalyzer.AnalyzeItems(progress, cancellationToken);
}

Plugin.Instance!.AnalyzerTaskIsRunning = false;

Expand Down

0 comments on commit 126c0c8

Please sign in to comment.