2022-05-01 01:24:57 -05:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
2019-02-21 01:57:43 -08:00
|
|
|
using MediaBrowser.Model.Plugins;
|
2019-03-10 08:53:30 +09:00
|
|
|
|
2022-04-29 23:52:50 -05:00
|
|
|
namespace ConfusedPolarBear.Plugin.IntroSkipper.Configuration;
|
2021-12-13 16:58:05 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Plugin configuration.
|
|
|
|
/// </summary>
|
|
|
|
public class PluginConfiguration : BasePluginConfiguration
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
|
|
|
|
/// </summary>
|
|
|
|
public PluginConfiguration()
|
2019-02-21 01:57:43 -08:00
|
|
|
{
|
2022-05-01 01:24:57 -05:00
|
|
|
AnalysisResults = new Collection<Intro>();
|
2019-02-21 01:57:43 -08:00
|
|
|
}
|
2021-12-13 16:58:05 -07:00
|
|
|
|
|
|
|
/// <summary>
|
2022-05-01 01:24:57 -05:00
|
|
|
/// Save timestamps to disk.
|
2021-12-13 16:58:05 -07:00
|
|
|
/// </summary>
|
2022-05-01 01:24:57 -05:00
|
|
|
public void SaveTimestamps()
|
|
|
|
{
|
|
|
|
AnalysisResults.Clear();
|
2021-12-13 16:58:05 -07:00
|
|
|
|
2022-05-01 01:24:57 -05:00
|
|
|
foreach (var intro in Plugin.Instance!.Intros)
|
|
|
|
{
|
|
|
|
AnalysisResults.Add(intro.Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
Plugin.Instance!.SaveConfiguration();
|
|
|
|
}
|
2021-12-13 16:58:05 -07:00
|
|
|
|
|
|
|
/// <summary>
|
2022-05-01 01:24:57 -05:00
|
|
|
/// Restore previous analysis results from disk.
|
2021-12-13 16:58:05 -07:00
|
|
|
/// </summary>
|
2022-05-01 01:24:57 -05:00
|
|
|
public void RestoreTimestamps()
|
|
|
|
{
|
|
|
|
// Since dictionaries can't be easily serialized, analysis results are stored on disk as a list.
|
|
|
|
foreach (var intro in AnalysisResults)
|
|
|
|
{
|
|
|
|
Plugin.Instance!.Intros[intro.EpisodeId] = intro;
|
|
|
|
}
|
|
|
|
}
|
2021-12-13 16:58:05 -07:00
|
|
|
|
|
|
|
/// <summary>
|
2022-05-01 01:24:57 -05:00
|
|
|
/// Previous analysis results.
|
2021-12-13 16:58:05 -07:00
|
|
|
/// </summary>
|
2022-05-01 01:24:57 -05:00
|
|
|
public Collection<Intro> AnalysisResults { get; private set; }
|
2019-03-10 08:53:30 +09:00
|
|
|
}
|