From 916bda6f32b8bbf0210f06fbb288b98bd1dfbed1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 25 Aug 2016 02:44:24 -0400 Subject: [PATCH] fix slow episode responses --- .../Entities/TV/Episode.cs | 44 ++++++++++--------- MediaBrowser.Controller/Entities/TV/Season.cs | 7 ++- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 726390f65..30379f3ff 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -135,7 +135,10 @@ namespace MediaBrowser.Controller.Entities.TV [IgnoreDataMember] public Series Series { - get { return FindParent(); } + get + { + return SeriesId.HasValue ? (LibraryManager.GetItemById(SeriesId.Value) as Series) : null; + } } [IgnoreDataMember] @@ -143,24 +146,7 @@ namespace MediaBrowser.Controller.Entities.TV { get { - var season = FindParent(); - - // Episodes directly in series folder - if (season == null) - { - var series = Series; - - if (series != null && ParentIndexNumber.HasValue) - { - var findNumber = ParentIndexNumber.Value; - - season = series.Children - .OfType() - .FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == findNumber); - } - } - - return season; + return SeasonId.HasValue ? (LibraryManager.GetItemById(SeasonId.Value) as Season) : null; } } @@ -193,7 +179,23 @@ namespace MediaBrowser.Controller.Entities.TV public Guid? FindSeasonId() { - var season = Season; + var season = FindParent(); + + // Episodes directly in series folder + if (season == null) + { + var series = Series; + + if (series != null && ParentIndexNumber.HasValue) + { + var findNumber = ParentIndexNumber.Value; + + season = series.Children + .OfType() + .FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == findNumber); + } + } + return season == null ? (Guid?)null : season.Id; } @@ -263,7 +265,7 @@ namespace MediaBrowser.Controller.Entities.TV public Guid? FindSeriesId() { - var series = Series; + var series = FindParent(); return series == null ? (Guid?)null : series.Id; } diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 842b2fd60..cf5d52a2b 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -99,7 +99,10 @@ namespace MediaBrowser.Controller.Entities.TV [IgnoreDataMember] public Series Series { - get { return FindParent(); } + get + { + return SeriesId.HasValue ? (LibraryManager.GetItemById(SeriesId.Value) as Series) : null; + } } [IgnoreDataMember] @@ -241,7 +244,7 @@ namespace MediaBrowser.Controller.Entities.TV public Guid? FindSeriesId() { - var series = Series; + var series = FindParent(); return series == null ? (Guid?)null : series.Id; }