From 930100798a9ee8b1e6b03eb1a14474a047469ef9 Mon Sep 17 00:00:00 2001
From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Fri, 2 Sep 2022 01:54:49 -0500
Subject: [PATCH] Add option to not skip the first episode's intro
Closes #78
---
.../AutoSkip.cs | 10 +++++-
.../Configuration/PluginConfiguration.cs | 5 +++
.../Configuration/configPage.html | 34 ++++++++++++++-----
3 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs
index 3846bb9..3da05ea 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs
@@ -74,6 +74,8 @@ public class AutoSkip : IServerEntryPoint
private void UserDataManager_UserDataSaved(object? sender, UserDataSaveEventArgs e)
{
var itemId = e.Item.Id;
+ var newState = false;
+ var episodeNumber = e.Item.IndexNumber.GetValueOrDefault(-1);
// Ignore all events except playback start & end
if (e.SaveReason != UserDataSaveReason.PlaybackStart && e.SaveReason != UserDataSaveReason.PlaybackFinished)
@@ -106,13 +108,19 @@ public class AutoSkip : IServerEntryPoint
return;
}
+ // If this is the first episode in the season, and SkipFirstEpisode is false, pretend that we've already sent the seek command for this playback session.
+ if (!Plugin.Instance!.Configuration.SkipFirstEpisode && episodeNumber == 1)
+ {
+ newState = true;
+ }
+
// Reset the seek command state for this device.
lock (_sentSeekCommandLock)
{
var device = session.DeviceId;
_logger.LogDebug("Resetting seek command state for session {Session}", device);
- _sentSeekCommand[device] = false;
+ _sentSeekCommand[device] = newState;
}
}
diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs
index db86ce3..929feb9 100644
--- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs
+++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs
@@ -78,4 +78,9 @@ public class PluginConfiguration : BasePluginConfiguration
/// Gets or sets the seconds after the intro starts to hide the skip prompt at.
///
public int HidePromptAdjustment { get; set; } = 10;
+
+ ///