diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-05-06 00:50:39 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-05-06 00:50:39 -0400 |
| commit | 5a496a1fc8d9ee2e728d6f712ae6bdf4862183f1 (patch) | |
| tree | 70f8d08ae6cd74e08f5800136fe73728fd0ad3d0 /MediaBrowser.Controller | |
| parent | 242fb3c770a657e3c2a23ac21ec7d902879d8023 (diff) | |
reduce recursive querying
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 20 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/InternalItemsQuery.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 147 |
5 files changed, 104 insertions, 77 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 6bf55e108..2e968c880 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -44,6 +44,9 @@ namespace MediaBrowser.Controller.Entities ImageInfos = new List<ItemImageInfo>(); } + public static readonly char[] SlugReplaceChars = { '?', '/', '&' }; + public static char SlugChar = '-'; + /// <summary> /// The supported image extensions /// </summary> @@ -125,6 +128,21 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public string SlugName + { + get + { + var name = Name; + if (string.IsNullOrWhiteSpace(name)) + { + return string.Empty; + } + + return SlugReplaceChars.Aggregate(name, (current, c) => current.Replace(c, SlugChar)); + } + } + public string OriginalTitle { get; set; } /// <summary> @@ -728,12 +746,14 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the critic rating. /// </summary> /// <value>The critic rating.</value> + [IgnoreDataMember] public float? CriticRating { get; set; } /// <summary> /// Gets or sets the critic rating summary. /// </summary> /// <value>The critic rating summary.</value> + [IgnoreDataMember] public string CriticRatingSummary { get; set; } /// <summary> diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index f57e2fa17..d9c0b7bfe 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -707,8 +707,8 @@ namespace MediaBrowser.Controller.Entities { return ItemRepository.GetItemIdsList(new InternalItemsQuery { - ParentId = Id - + ParentId = Id, + GroupByPresentationUniqueKey = false }); } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 6838fde71..2615f351a 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -49,6 +49,7 @@ namespace MediaBrowser.Controller.Entities public string PresentationUniqueKey { get; set; } public string Path { get; set; } public string Name { get; set; } + public string SlugName { get; set; } public string Person { get; set; } public string[] PersonIds { get; set; } @@ -133,9 +134,13 @@ namespace MediaBrowser.Controller.Entities public string[] AlbumNames { get; set; } public string[] ArtistNames { get; set; } - + + public bool GroupByPresentationUniqueKey { get; set; } + public InternalItemsQuery() { + GroupByPresentationUniqueKey = true; + AlbumNames = new string[] { }; ArtistNames = new string[] { }; diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index cd3e07ea3..09a9d97bc 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using MediaBrowser.Controller.Entities.Audio; namespace MediaBrowser.Controller.Entities.Movies { @@ -118,7 +119,7 @@ namespace MediaBrowser.Controller.Entities.Movies // Gather all possible ratings var ratings = GetRecursiveChildren() .Concat(GetLinkedChildren()) - .Where(i => i is Movie || i is Series) + .Where(i => i is Movie || i is Series || i is MusicAlbum || i is Game) .Select(i => i.OfficialRating) .Where(i => !string.IsNullOrEmpty(i)) .Distinct(StringComparer.OrdinalIgnoreCase) diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 67b710534..6a9d7cb51 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -28,7 +28,8 @@ namespace MediaBrowser.Controller.Entities IThemeMedia, IArchivable { - public Guid? PrimaryVersionId { get; set; } + [IgnoreDataMember] + public string PrimaryVersionId { get; set; } public List<string> AdditionalParts { get; set; } public List<string> LocalAlternateVersions { get; set; } @@ -49,9 +50,9 @@ namespace MediaBrowser.Controller.Entities { get { - if (PrimaryVersionId.HasValue) + if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) { - return PrimaryVersionId.Value.ToString("N"); + return PrimaryVersionId; } return base.PresentationUniqueKey; @@ -70,6 +71,72 @@ namespace MediaBrowser.Controller.Entities /// <value>The timestamp.</value> public TransportStreamTimestamp? Timestamp { get; set; } + /// <summary> + /// Gets or sets the subtitle paths. + /// </summary> + /// <value>The subtitle paths.</value> + public List<string> SubtitleFiles { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether this instance has subtitles. + /// </summary> + /// <value><c>true</c> if this instance has subtitles; otherwise, <c>false</c>.</value> + public bool HasSubtitles { get; set; } + + public bool IsPlaceHolder { get; set; } + public bool IsShortcut { get; set; } + public string ShortcutPath { get; set; } + + /// <summary> + /// Gets or sets the video bit rate. + /// </summary> + /// <value>The video bit rate.</value> + public int? VideoBitRate { get; set; } + + /// <summary> + /// Gets or sets the default index of the video stream. + /// </summary> + /// <value>The default index of the video stream.</value> + public int? DefaultVideoStreamIndex { get; set; } + + /// <summary> + /// Gets or sets the type of the video. + /// </summary> + /// <value>The type of the video.</value> + public VideoType VideoType { get; set; } + + /// <summary> + /// Gets or sets the type of the iso. + /// </summary> + /// <value>The type of the iso.</value> + public IsoType? IsoType { get; set; } + + /// <summary> + /// Gets or sets the video3 D format. + /// </summary> + /// <value>The video3 D format.</value> + public Video3DFormat? Video3DFormat { get; set; } + + /// <summary> + /// If the video is a folder-rip, this will hold the file list for the largest playlist + /// </summary> + public List<string> PlayableStreamFileNames { get; set; } + + /// <summary> + /// Gets the playable stream files. + /// </summary> + /// <returns>List{System.String}.</returns> + public List<string> GetPlayableStreamFiles() + { + return GetPlayableStreamFiles(Path); + } + + /// <summary> + /// Gets or sets the aspect ratio. + /// </summary> + /// <value>The aspect ratio.</value> + public string AspectRatio { get; set; } + public Video() { PlayableStreamFileNames = new List<string>(); @@ -104,9 +171,9 @@ namespace MediaBrowser.Controller.Entities { get { - if (PrimaryVersionId.HasValue) + if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) { - var item = LibraryManager.GetItemById(PrimaryVersionId.Value) as Video; + var item = LibraryManager.GetItemById(PrimaryVersionId) as Video; if (item != null) { return item.MediaSourceCount; @@ -238,72 +305,6 @@ namespace MediaBrowser.Controller.Entities .OrderBy(i => i.SortName); } - /// <summary> - /// Gets or sets the subtitle paths. - /// </summary> - /// <value>The subtitle paths.</value> - public List<string> SubtitleFiles { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance has subtitles. - /// </summary> - /// <value><c>true</c> if this instance has subtitles; otherwise, <c>false</c>.</value> - public bool HasSubtitles { get; set; } - - public bool IsPlaceHolder { get; set; } - public bool IsShortcut { get; set; } - public string ShortcutPath { get; set; } - - /// <summary> - /// Gets or sets the video bit rate. - /// </summary> - /// <value>The video bit rate.</value> - public int? VideoBitRate { get; set; } - - /// <summary> - /// Gets or sets the default index of the video stream. - /// </summary> - /// <value>The default index of the video stream.</value> - public int? DefaultVideoStreamIndex { get; set; } - - /// <summary> - /// Gets or sets the type of the video. - /// </summary> - /// <value>The type of the video.</value> - public VideoType VideoType { get; set; } - - /// <summary> - /// Gets or sets the type of the iso. - /// </summary> - /// <value>The type of the iso.</value> - public IsoType? IsoType { get; set; } - - /// <summary> - /// Gets or sets the video3 D format. - /// </summary> - /// <value>The video3 D format.</value> - public Video3DFormat? Video3DFormat { get; set; } - - /// <summary> - /// If the video is a folder-rip, this will hold the file list for the largest playlist - /// </summary> - public List<string> PlayableStreamFileNames { get; set; } - - /// <summary> - /// Gets the playable stream files. - /// </summary> - /// <returns>List{System.String}.</returns> - public List<string> GetPlayableStreamFiles() - { - return GetPlayableStreamFiles(Path); - } - - /// <summary> - /// Gets or sets the aspect ratio. - /// </summary> - /// <value>The aspect ratio.</value> - public string AspectRatio { get; set; } - [IgnoreDataMember] public override string ContainingFolderPath { @@ -520,9 +521,9 @@ namespace MediaBrowser.Controller.Entities list.Add(new Tuple<Video, MediaSourceType>(this, MediaSourceType.Default)); list.AddRange(GetLinkedAlternateVersions().Select(i => new Tuple<Video, MediaSourceType>(i, MediaSourceType.Grouping))); - if (PrimaryVersionId.HasValue) + if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) { - var primary = LibraryManager.GetItemById(PrimaryVersionId.Value) as Video; + var primary = LibraryManager.GetItemById(PrimaryVersionId) as Video; if (primary != null) { var existingIds = list.Select(i => i.Item1.Id).ToList(); |
