diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html index 401bd92..ad4fc31 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html @@ -201,7 +201,8 @@
- If checked, intros will be automatically skipped. If you access Jellyfin through a reverse proxy, it must be configured to proxy web + If checked, intros will be automatically skipped. If you access Jellyfin through a + reverse proxy, it must be configured to proxy web sockets.
@@ -253,10 +254,6 @@ Save
- - @@ -302,7 +299,17 @@

Introduction timestamp editor

+
+ + +
+ +

@@ -376,7 +383,8 @@

Fingerprint Visualizer

// settings elements var visualizer = document.querySelector("details#visualizer"); var support = document.querySelector("details#support"); - var btnEraseTimestamps = document.querySelector("button#btnEraseTimestamps"); + var btnEraseIntroTimestamps = document.querySelector("button#btnEraseIntroTimestamps"); + var btnEraseCreditTimestamps = document.querySelector("button#btnEraseCreditTimestamps"); // all plugin configuration fields that can be get or set with .value (i.e. strings or numbers). var configurationFields = [ @@ -662,6 +670,28 @@

Fingerprint Visualizer

return new Date(seconds * 1000).toISOString().substr(14, 5); } + // erase all intro/credits timestamps + function eraseTimestamps(mode) { + const lower = mode.toLocaleLowerCase(); + const title = "Confirm timestamp erasure"; + const body = "Are you sure you want to erase all previously discovered " + + mode.toLocaleLowerCase() + + " timestamps?"; + + Dashboard.confirm( + body, + title, + (result) => { + if (!result) { + return; + } + + fetchWithAuth("Intros/EraseTimestamps?mode=" + mode, "POST", null); + + Dashboard.alert(mode + " timestamps erased"); + }); + } + document.querySelector('#TemplateConfigPage') .addEventListener('pageshow', function () { Dashboard.showLoadingMsg(); @@ -707,19 +737,12 @@

Fingerprint Visualizer

selectSeason.addEventListener("change", seasonChanged); selectEpisode1.addEventListener("change", episodeChanged); selectEpisode2.addEventListener("change", episodeChanged); - btnEraseTimestamps.addEventListener("click", (e) => { - Dashboard.confirm( - "Are you sure you want to erase all previously discovered introduction timestamps?", - "Confirm timestamp erasure", - (result) => { - if (!result) { - return; - } - - // reset all intro timestamps on the server so a new fingerprint comparison algorithm can be tested - fetchWithAuth("Intros/EraseTimestamps", "POST", null); - }); - + btnEraseIntroTimestamps.addEventListener("click", (e) => { + eraseTimestamps("Introduction"); + e.preventDefault(); + }); + btnEraseCreditTimestamps.addEventListener("click", (e) => { + eraseTimestamps("Credits"); e.preventDefault(); }); btnSeasonEraseTimestamps.addEventListener("click", () => { diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs index 85b9804..3f12bb9 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs @@ -76,13 +76,22 @@ public ActionResult GetIntroTimestamps( /// /// Erases all previously discovered introduction timestamps. /// + /// Mode. /// Operation successful. /// No content. [Authorize(Policy = "RequiresElevation")] [HttpPost("Intros/EraseTimestamps")] - public ActionResult ResetIntroTimestamps() + public ActionResult ResetIntroTimestamps([FromQuery] AnalysisMode mode) { - Plugin.Instance!.Intros.Clear(); + if (mode == AnalysisMode.Introduction) + { + Plugin.Instance!.Intros.Clear(); + } + else if (mode == AnalysisMode.Credits) + { + Plugin.Instance!.Credits.Clear(); + } + Plugin.Instance!.SaveTimestamps(); return NoContent(); }