using System; using System.Runtime.Serialization; using Jellyfin.Data.Enums; namespace ConfusedPolarBear.Plugin.IntroSkipper.Data; /// /// Represents an item to ignore. /// [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/ConfusedPolarBear.Plugin.IntroSkipper")] public class IgnoreListItem { /// /// Initializes a new instance of the class. /// public IgnoreListItem() { } /// /// Initializes a new instance of the class. /// /// The season id. public IgnoreListItem(Guid seasonId) { SeasonId = seasonId; } /// /// Initializes a new instance of the class. /// /// The item to copy. public IgnoreListItem(IgnoreListItem item) { SeasonId = item.SeasonId; IgnoreIntro = item.IgnoreIntro; IgnoreCredits = item.IgnoreCredits; } /// /// Gets or sets the season id. /// [DataMember] public Guid SeasonId { get; set; } = Guid.Empty; /// /// Gets or sets a value indicating whether to ignore the intro. /// [DataMember] public bool IgnoreIntro { get; set; } = false; /// /// Gets or sets a value indicating whether to ignore the credits. /// [DataMember] public bool IgnoreCredits { get; set; } = false; /// /// Toggles the provided mode to the provided value. /// /// Analysis mode. /// Value to set. public void Toggle(MediaSegmentType mode, bool value) { switch (mode) { case MediaSegmentType.Intro: IgnoreIntro = value; break; case MediaSegmentType.Outro: IgnoreCredits = value; break; } } /// /// Checks if the provided mode is ignored. /// /// Analysis mode. /// True if ignored, false otherwise. public bool IsIgnored(MediaSegmentType mode) { return mode switch { MediaSegmentType.Intro => IgnoreIntro, MediaSegmentType.Outro => IgnoreCredits, _ => false, }; } }