This commit is contained in:
ConfusedPolarBear 2022-07-03 02:47:48 -05:00
parent 98b4b66a27
commit 46355d19d4
4 changed files with 13 additions and 16 deletions

View File

@ -127,7 +127,7 @@ public class AutoSkip : IServerEntryPoint
// Don't send the seek command more than once in the same session. // Don't send the seek command more than once in the same session.
lock (_sentSeekCommandLock) lock (_sentSeekCommandLock)
{ {
if (_sentSeekCommand[deviceId]) if (_sentSeekCommand.TryGetValue(deviceId, out var sent) && sent)
{ {
_logger.LogTrace("Already sent seek command for session {Session}", deviceId); _logger.LogTrace("Already sent seek command for session {Session}", deviceId);
continue; continue;

View File

@ -52,12 +52,7 @@ public class SkipIntroController : ControllerBase
/// <returns>Intro object if the provided item has an intro, null otherwise.</returns> /// <returns>Intro object if the provided item has an intro, null otherwise.</returns>
private Intro? GetIntro(Guid id) private Intro? GetIntro(Guid id)
{ {
if (!Plugin.Instance!.Intros.ContainsKey(id)) return Plugin.Instance!.Intros.TryGetValue(id, out var intro) ? intro : null;
{
return null;
}
return Plugin.Instance!.Intros[id];
} }
/// <summary> /// <summary>

View File

@ -147,14 +147,6 @@ public class QueueManager
return; return;
} }
var queue = Plugin.Instance.AnalysisQueue;
// Allocate a new list for each new season
if (!queue.ContainsKey(episode.SeasonId))
{
Plugin.Instance.AnalysisQueue[episode.SeasonId] = new List<QueuedEpisode>();
}
// Only fingerprint up to 25% of the episode and at most 10 minutes. // Only fingerprint up to 25% of the episode and at most 10 minutes.
var duration = TimeSpan.FromTicks(episode.RunTimeTicks ?? 0).TotalSeconds; var duration = TimeSpan.FromTicks(episode.RunTimeTicks ?? 0).TotalSeconds;
if (duration >= 5 * 60) if (duration >= 5 * 60)
@ -164,6 +156,10 @@ public class QueueManager
duration = Math.Min(duration, 10 * 60); duration = Math.Min(duration, 10 * 60);
// Allocate a new list for each new season
Plugin.Instance!.AnalysisQueue.TryAdd(episode.SeasonId, new List<QueuedEpisode>());
// Queue the episode for analysis
Plugin.Instance.AnalysisQueue[episode.SeasonId].Add(new QueuedEpisode() Plugin.Instance.AnalysisQueue[episode.SeasonId].Add(new QueuedEpisode()
{ {
SeriesName = episode.SeriesName, SeriesName = episode.SeriesName,

View File

@ -724,11 +724,17 @@ public class FingerprinterTask : IScheduledTask
// Analyze the episode again, ignoring whatever is returned for the known good episode. // Analyze the episode again, ignoring whatever is returned for the known good episode.
foreach (var lhsFingerprint in goodFingerprints) foreach (var lhsFingerprint in goodFingerprints)
{ {
if (!_fingerprintCache.TryGetValue(episode.EpisodeId, out var fp))
{
_logger.LogTrace("Unable to get cached fingerprint for {Id}, skipping", episode.EpisodeId);
continue;
}
var (_, newRhs) = FingerprintEpisodes( var (_, newRhs) = FingerprintEpisodes(
maxEpisode.EpisodeId, maxEpisode.EpisodeId,
lhsFingerprint, lhsFingerprint,
episode.EpisodeId, episode.EpisodeId,
_fingerprintCache[episode.EpisodeId]); fp);
// Ensure that the new intro duration is within the targeted bucket and longer than what was found previously. // Ensure that the new intro duration is within the targeted bucket and longer than what was found previously.
var newDuration = Math.Round(newRhs.IntroEnd - newRhs.IntroStart, 2); var newDuration = Math.Round(newRhs.IntroEnd - newRhs.IntroStart, 2);