diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs index 142e171..a67c813 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs @@ -226,6 +226,52 @@ public class Plugin : BasePlugin, IHasWebPages } } + /// + /// Save timestamps to disk. + /// + /// Mode. + public void SaveTimestamps(AnalysisMode mode) + { + lock (_serializationLock) + { + var introList = new List(); + + // Serialize intros + if (mode == AnalysisMode.Introduction) + { + foreach (var intro in Instance!.Intros) + { + introList.Add(intro.Value); + } + + try + { + XmlSerializationHelper.SerializeToXml(introList, _introPath); + } + catch (Exception e) + { + _logger.LogError("SaveTimestamps intros {Message}", e.Message); + } + } + else if (mode == AnalysisMode.Credits) + { + foreach (var intro in Instance.Credits) + { + introList.Add(intro.Value); + } + + try + { + XmlSerializationHelper.SerializeToXml(introList, _creditsPath); + } + catch (Exception e) + { + _logger.LogError("SaveTimestamps credits {Message}", e.Message); + } + } + } + } + /// /// Restore previous analysis results from disk. /// @@ -346,7 +392,7 @@ public class Plugin : BasePlugin, IHasWebPages } } - Instance!.SaveTimestamps(); + Instance!.SaveTimestamps(mode); } }