diff options
Diffstat (limited to 'MediaBrowser.Controller/Entities/TV/Season.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Season.cs | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 744416560..830ccb8a2 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -1,11 +1,10 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; -using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Runtime.Serialization; @@ -14,7 +13,7 @@ namespace MediaBrowser.Controller.Entities.TV /// <summary> /// Class Season /// </summary> - public class Season : Folder + public class Season : Folder, IHasSeries, IHasLookupInfo<SeasonInfo> { /// <summary> @@ -119,16 +118,11 @@ namespace MediaBrowser.Controller.Entities.TV [IgnoreDataMember] public override string OfficialRatingForComparison { - get { return Series != null ? Series.OfficialRatingForComparison : base.OfficialRatingForComparison; } - } - - /// <summary> - /// Our rating comes from our series - /// </summary> - [IgnoreDataMember] - public override string CustomRatingForComparison - { - get { return Series != null ? Series.CustomRatingForComparison : base.CustomRatingForComparison; } + get + { + var series = Series; + return series != null ? series.OfficialRatingForComparison : base.OfficialRatingForComparison; + } } /// <summary> @@ -223,7 +217,7 @@ namespace MediaBrowser.Controller.Entities.TV { episodes = episodes.Where(i => !i.IsVirtualUnaired); } - + return LibraryManager .Sort(episodes, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending) .Cast<Episode>(); @@ -239,5 +233,51 @@ namespace MediaBrowser.Controller.Entities.TV // Don't block. Let either the entire series rating or episode rating determine it return false; } + + [IgnoreDataMember] + public string SeriesName + { + get + { + var series = Series; + return series == null ? null : series.Name; + } + } + + /// <summary> + /// Gets the lookup information. + /// </summary> + /// <returns>SeasonInfo.</returns> + public SeasonInfo GetLookupInfo() + { + return GetItemLookupInfo<SeasonInfo>(); + } + + /// <summary> + /// This is called before any metadata refresh and returns ItemUpdateType indictating if changes were made, and what. + /// </summary> + /// <returns>ItemUpdateType.</returns> + public override ItemUpdateType BeforeMetadataRefresh() + { + var updateType = base.BeforeMetadataRefresh(); + + var locationType = LocationType; + + if (locationType == LocationType.FileSystem || locationType == LocationType.Offline) + { + if (!IndexNumber.HasValue && !string.IsNullOrEmpty(Path)) + { + IndexNumber = IndexNumber ?? TVUtils.GetSeasonNumberFromPath(Path); + + // If a change was made record it + if (IndexNumber.HasValue) + { + updateType = updateType | ItemUpdateType.MetadataImport; + } + } + } + + return updateType; + } } } |
