瀏覽代碼

Populate ThemeVideoIds and ThemeSongIds

cvium 4 年之前
父節點
當前提交
1ae3dc202c
共有 1 個文件被更改,包括 46 次插入5 次删除
  1. 46 5
      MediaBrowser.Controller/Entities/BaseItem.cs

+ 46 - 5
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -58,8 +58,6 @@ namespace MediaBrowser.Controller.Entities
 
 
         protected BaseItem()
         protected BaseItem()
         {
         {
-            ThemeSongIds = Array.Empty<Guid>();
-            ThemeVideoIds = Array.Empty<Guid>();
             Tags = Array.Empty<string>();
             Tags = Array.Empty<string>();
             Genres = Array.Empty<string>();
             Genres = Array.Empty<string>();
             Studios = Array.Empty<string>();
             Studios = Array.Empty<string>();
@@ -98,12 +96,52 @@ namespace MediaBrowser.Controller.Entities
         };
         };
 
 
         [JsonIgnore]
         [JsonIgnore]
-        public Guid[] ThemeSongIds { get; set; }
+        public Guid[] ThemeSongIds
+        {
+            get
+            {
+                if (_themeSongIds == null)
+                {
+                    _themeSongIds = GetExtras()
+                        .Where(extra => extra.ExtraType == Model.Entities.ExtraType.ThemeSong)
+                        .Select(song => song.Id)
+                        .ToArray();
+                }
+
+                return _themeSongIds;
+            }
+
+            private set
+            {
+                _themeSongIds = value;
+            }
+        }
+
         [JsonIgnore]
         [JsonIgnore]
-        public Guid[] ThemeVideoIds { get; set; }
+        public Guid[] ThemeVideoIds
+        {
+            get
+            {
+                if (_themeVideoIds == null)
+                {
+                    _themeVideoIds = GetExtras()
+                        .Where(extra => extra.ExtraType == Model.Entities.ExtraType.ThemeVideo)
+                        .Select(song => song.Id)
+                        .ToArray();
+                }
+
+                return _themeVideoIds;
+            }
+
+            private set
+            {
+                _themeVideoIds = value;
+            }
+        }
 
 
         [JsonIgnore]
         [JsonIgnore]
         public string PreferredMetadataCountryCode { get; set; }
         public string PreferredMetadataCountryCode { get; set; }
+
         [JsonIgnore]
         [JsonIgnore]
         public string PreferredMetadataLanguage { get; set; }
         public string PreferredMetadataLanguage { get; set; }
 
 
@@ -633,6 +671,9 @@ namespace MediaBrowser.Controller.Entities
         }
         }
 
 
         private string _sortName;
         private string _sortName;
+        private Guid[] _themeSongIds;
+        private Guid[] _themeVideoIds;
+
         /// <summary>
         /// <summary>
         /// Gets the name of the sort.
         /// Gets the name of the sort.
         /// </summary>
         /// </summary>
@@ -2909,7 +2950,7 @@ namespace MediaBrowser.Controller.Entities
 
 
         public IEnumerable<BaseItem> GetThemeSongs()
         public IEnumerable<BaseItem> GetThemeSongs()
         {
         {
-            return ThemeVideoIds.Select(LibraryManager.GetItemById).Where(i => i.ExtraType.Equals(Model.Entities.ExtraType.ThemeSong)).OrderBy(i => i.SortName);
+            return ThemeSongIds.Select(LibraryManager.GetItemById).Where(i => i.ExtraType.Equals(Model.Entities.ExtraType.ThemeSong)).OrderBy(i => i.SortName);
         }
         }
 
 
         public IEnumerable<BaseItem> GetThemeVideos()
         public IEnumerable<BaseItem> GetThemeVideos()