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,47 +12,69 @@
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
<form id="FingerprintConfigForm"> <form id="FingerprintConfigForm">
<div class="checkboxContainer checkboxContainer-withDescription"> <fieldset class="verticalSection-extrabottompadding">
<label class="emby-checkbox-label"> <legend>Analysis</legend>
<input id="AutoSkip" type="checkbox" is="emby-checkbox" />
<span>Automatically skip intros</span>
</label>
<div class="fieldDescription"> <div class="checkboxContainer checkboxContainer-withDescription">
If checked, intros will be automatically skipped. Will only work if web <label class="emby-checkbox-label">
sockets are configured correctly.<br /> <input id="CacheFingerprints" type="checkbox" is="emby-checkbox" />
<strong>Jellyfin must be restarted after changing this setting.</strong> <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>
</div>
<div class="checkboxContainer checkboxContainer-withDescription"> <div class="inputContainer">
<label class="emby-checkbox-label"> <label class="inputLabel inputLabelUnfocused" for="MaxParallelism">
<input id="CacheFingerprints" type="checkbox" is="emby-checkbox" /> Maximum degree of parallelism
<span>Cache fingerprints to disk</span> </label>
</label> <input id="MaxParallelism" type="number" is="emby-input" min="1" />
<div class="fieldDescription">
<div class="fieldDescription"> Maximum degree of parallelism to use when analyzing episodes.
If checked, will store the fingerprints for all subsequently scanned files to disk. </div>
Caching fingerprints avoids having to re-run fpcalc on each file, at the expense of disk
usage.
</div> </div>
</div> </fieldset>
<div class="inputContainer"> <fieldset class="verticalSection-extrabottompadding">
<label class="inputLabel inputLabelUnfocused" for="AnInteger">Show skip prompt at</label> <legend>Playback</legend>
<input id="ShowPromptAdjustment" type="number" is="emby-input" min="0" />
<div class="fieldDescription">
Seconds before the introduction starts to display the skip prompt at.
</div>
</div>
<div class="inputContainer"> <div class="checkboxContainer checkboxContainer-withDescription">
<label class="inputLabel inputLabelUnfocused" for="AnInteger">Hide skip prompt after</label> <label class="emby-checkbox-label">
<input id="HidePromptAdjustment" type="number" is="emby-input" min="2" /> <input id="AutoSkip" type="checkbox" is="emby-checkbox" />
<div class="fieldDescription"> <span>Automatically skip intros</span>
Seconds after the introduction starts to hide the skip prompt at. </label>
<div class="fieldDescription">
If checked, intros will be automatically skipped. Will only work if web
sockets are configured correctly.<br />
<strong>Jellyfin must be restarted after changing this setting.</strong>
</div>
</div> </div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="ShowPromptAdjustment">
Show skip prompt at
</label>
<input id="ShowPromptAdjustment" type="number" is="emby-input" min="0" />
<div class="fieldDescription">
Seconds before the introduction starts to display the skip prompt at.
</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="HidePromptAdjustment">
Hide skip prompt after
</label>
<input id="HidePromptAdjustment" type="number" is="emby-input" min="2" />
<div class="fieldDescription">
Seconds after the introduction starts to hide the skip prompt at.
</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(