using System; using System.Collections.Generic; using System.Text.RegularExpressions; using Kyoo.Controllers; using Kyoo.Models.Attributes; namespace Kyoo.Models { /// /// A season of a . /// public class Season : IResource { /// public int ID { get; set; } /// public string Slug { get => $"{ShowSlug}-s{SeasonNumber}"; set { Match match = Regex.Match(value, @"(?.*)-s(?\d*)"); if (!match.Success) throw new ArgumentException("Invalid season slug. Format: {showSlug}-s{seasonNumber}"); ShowSlug = match.Groups["show"].Value; SeasonNumber = int.Parse(match.Groups["season"].Value); } } /// /// The slug of the Show that contain this episode. If this is not set, this season is ill-formed. /// [SerializeIgnore] public string ShowSlug { private get; set; } /// /// The ID of the Show containing this season. This value is only set when the has been loaded. /// [SerializeIgnore] public int ShowID { get; set; } /// /// The show that contains this season. This must be explicitly loaded via a call to . /// [LoadableRelation(nameof(ShowID))] public Show Show { get; set; } /// /// The number of this season. This can be set to 0 to indicate specials. This defaults to -1 for unset. /// public int SeasonNumber { get; set; } = -1; /// /// The title of this season. /// public string Title { get; set; } /// /// A quick overview of this season. /// public string Overview { get; set; } /// /// The starting air date of this season. /// public DateTime? StartDate { get; set; } /// /// The ending date of this season. /// public DateTime? EndDate { get; set; } /// /// The path of this poster. /// By default, the http path for this poster is returned from the public API. /// This can be disabled using the internal query flag. /// [SerializeAs("{HOST}/api/seasons/{Slug}/thumb")] public string Poster { get; set; } /// /// The link to metadata providers that this episode has. See for more information. /// [EditableRelation] [LoadableRelation] public ICollection> ExternalIDs { get; set; } /// /// The list of episodes that this season contains. /// [LoadableRelation] public ICollection Episodes { get; set; } } }