0b27b6e297
Co-authored-by: rlauu <46294892+rlauu@users.noreply.github.com>
97 lines
2.6 KiB
C#
97 lines
2.6 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Runtime.Serialization;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace IntroSkipper.Data;
|
|
|
|
/// <summary>
|
|
/// Result of fingerprinting and analyzing two episodes in a season.
|
|
/// All times are measured in seconds relative to the beginning of the media file.
|
|
/// </summary>
|
|
[DataContract(Namespace = "http://schemas.datacontract.org/2004/07/ConfusedPolarBear.Plugin.IntroSkipper.Segment")]
|
|
public class Segment
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="Segment"/> class.
|
|
/// </summary>
|
|
/// <param name="episode">Episode.</param>
|
|
/// <param name="segment">Introduction time range.</param>
|
|
public Segment(Guid episode, TimeRange segment)
|
|
{
|
|
EpisodeId = episode;
|
|
Start = segment.Start;
|
|
End = segment.End;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="Segment"/> class.
|
|
/// </summary>
|
|
/// <param name="episode">Episode.</param>
|
|
public Segment(Guid episode)
|
|
{
|
|
EpisodeId = episode;
|
|
Start = 0;
|
|
End = 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="Segment"/> class.
|
|
/// </summary>
|
|
/// <param name="intro">intro.</param>
|
|
public Segment(Segment intro)
|
|
{
|
|
EpisodeId = intro.EpisodeId;
|
|
Start = intro.Start;
|
|
End = intro.End;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="Segment"/> class.
|
|
/// </summary>
|
|
/// <param name="intro">intro.</param>
|
|
public Segment(Intro intro)
|
|
{
|
|
EpisodeId = intro.EpisodeId;
|
|
Start = intro.IntroStart;
|
|
End = intro.IntroEnd;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="Segment"/> class.
|
|
/// </summary>
|
|
public Segment()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Episode ID.
|
|
/// </summary>
|
|
[DataMember]
|
|
public Guid EpisodeId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the introduction sequence start time.
|
|
/// </summary>
|
|
[DataMember]
|
|
public double Start { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the introduction sequence end time.
|
|
/// </summary>
|
|
[DataMember]
|
|
public double End { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets a value indicating whether this introduction is valid or not.
|
|
/// Invalid results must not be returned through the API.
|
|
/// </summary>
|
|
public bool Valid => End > 0;
|
|
|
|
/// <summary>
|
|
/// Gets the duration of this intro.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public double Duration => End - Start;
|
|
}
|