From c9066acdab6c707fcc57b835c05d229b9815822b Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Fri, 24 Jun 2022 16:00:33 -0500 Subject: [PATCH] Use TryGetValue --- .../ScheduledTasks/FingerprinterTask.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs index 23e7f7b..0520f20 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/FingerprinterTask.cs @@ -579,7 +579,7 @@ public class FingerprinterTask : IScheduledTask foreach (var episode in episodes) { - if (Plugin.Instance!.Intros[episode.EpisodeId].Valid) + if (Plugin.Instance!.Intros.TryGetValue(episode.EpisodeId, out var intro) && intro.Valid) { validCount++; } @@ -761,7 +761,11 @@ public class FingerprinterTask : IScheduledTask private double GetIntroDuration(Guid id) { - var episode = Plugin.Instance!.Intros[id]; + if (!Plugin.Instance!.Intros.TryGetValue(id, out var episode)) + { + return 0; + } + return episode.Valid ? Math.Round(episode.IntroEnd - episode.IntroStart, 2) : 0; }