Allow customizing degree of parallelism

Also grouped settings controls
This commit is contained in:
ConfusedPolarBear 2022-06-09 20:34:18 -05:00
parent 9b79e6b05a
commit 2c2dec9ec9
3 changed files with 71 additions and 42 deletions

View File

@ -19,6 +19,11 @@ public class PluginConfiguration : BasePluginConfiguration
/// </summary> /// </summary>
public bool CacheFingerprints { get; set; } = true; public bool CacheFingerprints { get; set; } = true;
/// <summary>
/// Gets or sets the max degree of parallelism used when analyzing episodes.
/// </summary>
public int MaxParallelism { get; set; } = 2;
/// <summary> /// <summary>
/// Gets or sets a value indicating whether introductions should be automatically skipped. /// Gets or sets a value indicating whether introductions should be automatically skipped.
/// </summary> /// </summary>

View File

@ -12,6 +12,36 @@
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
<form id="FingerprintConfigForm"> <form id="FingerprintConfigForm">
<fieldset class="verticalSection-extrabottompadding">
<legend>Analysis</legend>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="CacheFingerprints" type="checkbox" is="emby-checkbox" />
<span>Cache fingerprints to disk</span>
</label>
<div class="fieldDescription">
If checked, will store the audio fingerprints for all subsequently scanned files to
disk. Caching fingerprints avoids having to re-run fpcalc on each file, at the expense
of disk usage.
</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="MaxParallelism">
Maximum degree of parallelism
</label>
<input id="MaxParallelism" type="number" is="emby-input" min="1" />
<div class="fieldDescription">
Maximum degree of parallelism to use when analyzing episodes.
</div>
</div>
</fieldset>
<fieldset class="verticalSection-extrabottompadding">
<legend>Playback</legend>
<div class="checkboxContainer checkboxContainer-withDescription"> <div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label"> <label class="emby-checkbox-label">
<input id="AutoSkip" type="checkbox" is="emby-checkbox" /> <input id="AutoSkip" type="checkbox" is="emby-checkbox" />
@ -25,21 +55,10 @@
</div> </div>
</div> </div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="CacheFingerprints" type="checkbox" is="emby-checkbox" />
<span>Cache fingerprints to disk</span>
</label>
<div class="fieldDescription">
If checked, will store the fingerprints for all subsequently scanned files to disk.
Caching fingerprints avoids having to re-run fpcalc on each file, at the expense of disk
usage.
</div>
</div>
<div class="inputContainer"> <div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="AnInteger">Show skip prompt at</label> <label class="inputLabel inputLabelUnfocused" for="ShowPromptAdjustment">
Show skip prompt at
</label>
<input id="ShowPromptAdjustment" type="number" is="emby-input" min="0" /> <input id="ShowPromptAdjustment" type="number" is="emby-input" min="0" />
<div class="fieldDescription"> <div class="fieldDescription">
Seconds before the introduction starts to display the skip prompt at. Seconds before the introduction starts to display the skip prompt at.
@ -47,12 +66,15 @@
</div> </div>
<div class="inputContainer"> <div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="AnInteger">Hide skip prompt after</label> <label class="inputLabel inputLabelUnfocused" for="HidePromptAdjustment">
Hide skip prompt after
</label>
<input id="HidePromptAdjustment" type="number" is="emby-input" min="2" /> <input id="HidePromptAdjustment" type="number" is="emby-input" min="2" />
<div class="fieldDescription"> <div class="fieldDescription">
Seconds after the introduction starts to hide the skip prompt at. Seconds after the introduction starts to hide the skip prompt at.
</div> </div>
</div> </div>
</fieldset>
<div> <div>
<button is="emby-button" type="submit" class="raised button-submit block emby-button"> <button is="emby-button" type="submit" class="raised button-submit block emby-button">
@ -66,7 +88,8 @@
<p> <p>
Erasing introduction timestamps is only necessary after upgrading the plugin if specifically Erasing introduction timestamps is only necessary after upgrading the plugin if specifically
requested to do so in the plugin's changelog. After the timestamps are erased, run the Analyze episodes scheduled task to re-analyze all media on the server. requested to do so in the plugin's changelog. After the timestamps are erased, run the
Analyze episodes scheduled task to re-analyze all media on the server.
</p> </p>
</div> </div>
</form> </form>
@ -415,8 +438,9 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration("c83d86bb-a1e0-4c35-a113-e2101cf4ee6b").then(function (config) { ApiClient.getPluginConfiguration("c83d86bb-a1e0-4c35-a113-e2101cf4ee6b").then(function (config) {
document.querySelector('#AutoSkip').checked = config.AutoSkip; document.querySelector('#AutoSkip').checked = config.AutoSkip;
document.querySelector('#CacheFingerprints').checked = config.CacheFingerprints; document.querySelector('#MaxParallelism').value = config.MaxParallelism;
document.querySelector('#CacheFingerprints').checked = config.CacheFingerprints;
document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment; document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment;
document.querySelector('#HidePromptAdjustment').value = config.HidePromptAdjustment; document.querySelector('#HidePromptAdjustment').value = config.HidePromptAdjustment;
@ -429,8 +453,9 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration("c83d86bb-a1e0-4c35-a113-e2101cf4ee6b").then(function (config) { ApiClient.getPluginConfiguration("c83d86bb-a1e0-4c35-a113-e2101cf4ee6b").then(function (config) {
config.AutoSkip = document.querySelector('#AutoSkip').checked; config.AutoSkip = document.querySelector('#AutoSkip').checked;
config.CacheFingerprints = document.querySelector('#CacheFingerprints').checked; config.MaxParallelism = document.querySelector('#MaxParallelism').value;
config.CacheFingerprints = document.querySelector('#CacheFingerprints').checked;
config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value; config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value;
config.HidePromptAdjustment = document.querySelector("#HidePromptAdjustment").value; config.HidePromptAdjustment = document.querySelector("#HidePromptAdjustment").value;

View File

@ -110,10 +110,10 @@ public class FingerprinterTask : IScheduledTask
} }
var totalProcessed = 0; var totalProcessed = 0;
var options = new ParallelOptions()
// TODO: make configurable {
var options = new ParallelOptions(); MaxDegreeOfParallelism = Plugin.Instance!.Configuration.MaxParallelism
options.MaxDegreeOfParallelism = 2; };
Parallel.ForEach(queue, options, (season) => Parallel.ForEach(queue, options, (season) =>
{ {
@ -199,7 +199,6 @@ public class FingerprinterTask : IScheduledTask
var lhs = episodes[i]; var lhs = episodes[i];
var rhs = episodes[i + 1]; var rhs = episodes[i + 1];
// TODO: make configurable
if (!everFoundIntro && failures >= 20) if (!everFoundIntro && failures >= 20)
{ {
_logger.LogWarning( _logger.LogWarning(