using System;
namespace ConfusedPolarBear.Plugin.IntroSkipper;
///
/// Result of fingerprinting and analyzing two episodes in a season.
/// All times are measured in seconds relative to the beginning of the media file.
///
public class Intro
{
///
/// Initializes a new instance of the class.
///
/// Episode.
/// Introduction time range.
public Intro(Guid episode, TimeRange intro)
{
EpisodeId = episode;
IntroStart = intro.Start;
IntroEnd = intro.End;
}
///
/// Initializes a new instance of the class.
///
/// Episode.
public Intro(Guid episode)
{
EpisodeId = episode;
IntroStart = 0;
IntroEnd = 0;
}
///
/// Initializes a new instance of the class.
///
public Intro()
{
}
///
/// Gets or sets the Episode ID.
///
public Guid EpisodeId { get; set; }
///
/// Gets a value indicating whether this introduction is valid or not.
/// Invalid results must not be returned through the API.
///
public bool Valid => IntroEnd > 0;
///
/// Gets or sets the introduction sequence start time.
///
public double IntroStart { get; set; }
///
/// Gets or sets the introduction sequence end time.
///
public double IntroEnd { get; set; }
///
/// Gets or sets the recommended time to display the skip intro prompt.
///
public double ShowSkipPromptAt { get; set; }
///
/// Gets or sets the recommended time to hide the skip intro prompt.
///
public double HideSkipPromptAt { get; set; }
///
/// Convert this Intro object to a Kodi compatible EDL entry.
///
/// User specified configuration EDL action.
/// String.
public string ToEdl(EdlAction action)
{
if (action == EdlAction.None)
{
throw new ArgumentException("Cannot serialize an EdlAction of None");
}
var start = Math.Round(IntroStart, 2);
var end = Math.Round(IntroEnd, 2);
return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} {1} {2}", start, end, (int)action);
}
}
///
/// An Intro class with episode metadata. Only used in end to end testing programs.
///
public class IntroWithMetadata : Intro
{
///
/// Initializes a new instance of the class.
///
/// Series name.
/// Season number.
/// Episode title.
/// Intro timestamps.
public IntroWithMetadata(string series, int season, string title, Intro intro)
{
Series = series;
Season = season;
Title = title;
EpisodeId = intro.EpisodeId;
IntroStart = intro.IntroStart;
IntroEnd = intro.IntroEnd;
}
///
/// Gets or sets the series name of the TV episode associated with this intro.
///
public string Series { get; set; }
///
/// Gets or sets the season number of the TV episode associated with this intro.
///
public int Season { get; set; }
///
/// Gets or sets the title of the TV episode associated with this intro.
///
public string Title { get; set; }
}