// Kyoo - A portable and vast media library solution. // Copyright (c) Kyoo. // // See AUTHORS.md and LICENSE file in the project root for full license information. // // Kyoo is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // Kyoo is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Kyoo. If not, see . using System; using System.Collections.Generic; using System.Text.RegularExpressions; using JetBrains.Annotations; using Kyoo.Abstractions.Controllers; using Kyoo.Abstractions.Models.Attributes; namespace Kyoo.Abstractions.Models { /// /// A season of a . /// public class Season : IResource, IMetadata, IThumbnails { /// public int ID { get; set; } /// [Computed] public string Slug { get { if (ShowSlug == null && Show == null) return $"{ShowID}-s{SeasonNumber}"; return $"{ShowSlug ?? Show?.Slug}-s{SeasonNumber}"; } [UsedImplicitly] [NotNull] private set { Match match = Regex.Match(value ?? string.Empty, @"(?.+)-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. /// [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. /// public int SeasonNumber { get; set; } /// /// 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; } /// public Dictionary Images { get; set; } /// [EditableRelation] [LoadableRelation] public ICollection ExternalIDs { get; set; } /// /// The list of episodes that this season contains. /// [LoadableRelation] public ICollection Episodes { get; set; } } }