From 259bddfc1aa1baef71d766d5c0e43e9e22836d44 Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Fri, 8 Jul 2022 23:21:07 -0500 Subject: [PATCH] Simplify max bucket fingerprint retrieval --- .../ScheduledTasks/FingerprinterTask.cs | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs index 9aecebc..331c1cb 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs @@ -788,29 +788,13 @@ public class FingerprinterTask : IScheduledTask var goodFingerprints = new List>(); foreach (var id in maxBucket.Episodes) { - // Sometimes an episode isn't in the fingerprint cache. When this occurs, it has to be fingerprinted again. - _logger.LogTrace("Second pass: searching cache for {Id}", id); - - if (_fingerprintCache.ContainsKey(id)) + if (!_fingerprintCache.TryGetValue(id, out var fp)) { - _logger.LogTrace("Second pass: cache hit for {Id}", id); - goodFingerprints.Add(_fingerprintCache[id]); + _logger.LogTrace("Second pass: max bucket episode {Id} not in cache, skipping", id); + continue; } - else - { - _logger.LogTrace("Second pass: cache miss for {Id}", id); - var fullEp = episodes.Find((e) => { return e.EpisodeId == id; }); - - if (fullEp is not null) - { - goodFingerprints.Add(Chromaprint.Fingerprint(fullEp)); - } - else - { - _logger.LogTrace("Second pass: unable to find episode {Id}", id); - } - } + goodFingerprints.Add(fp); } foreach (var episode in episodes)