diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 0785b904a..ff7749795 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -82,10 +82,6 @@ - - - - diff --git a/MediaBrowser.Api/Reports/Common/HeaderMetadata.cs b/MediaBrowser.Api/Reports/Common/HeaderMetadata.cs index b25123df8..e25e78802 100644 --- a/MediaBrowser.Api/Reports/Common/HeaderMetadata.cs +++ b/MediaBrowser.Api/Reports/Common/HeaderMetadata.cs @@ -35,7 +35,8 @@ namespace MediaBrowser.Api.Reports Tracks, EpisodeSeries, EpisodeSeason, - AudioAlbumArtist, + EpisodeNumber, + AudioAlbumArtist, MusicArtist, AudioAlbum, Locked, diff --git a/MediaBrowser.Api/Reports/Common/ReportBuilderBase.cs b/MediaBrowser.Api/Reports/Common/ReportBuilderBase.cs index 39b2610d5..6d5a180fb 100644 --- a/MediaBrowser.Api/Reports/Common/ReportBuilderBase.cs +++ b/MediaBrowser.Api/Reports/Common/ReportBuilderBase.cs @@ -148,6 +148,11 @@ namespace MediaBrowser.Api.Reports /// The localized header. protected static string GetLocalizedHeader(HeaderMetadata internalHeader) { + if (internalHeader == HeaderMetadata.EpisodeNumber) + { + return "Episode"; + } + string headerName = ""; if (internalHeader != HeaderMetadata.None) { diff --git a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs index c9c63847c..9c3dde6a4 100644 --- a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs +++ b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs @@ -102,7 +102,7 @@ namespace MediaBrowser.Api.Reports HeaderMetadata.Series, HeaderMetadata.Season, HeaderMetadata.SeasonNumber, - HeaderMetadata.DateAdded, + HeaderMetadata.DateAdded, HeaderMetadata.Year, HeaderMetadata.Genres }; @@ -269,10 +269,11 @@ namespace MediaBrowser.Api.Reports HeaderMetadata.ImagePrimary, HeaderMetadata.ImageBackdrop, HeaderMetadata.ImageLogo, - HeaderMetadata.Name, + HeaderMetadata.Name, HeaderMetadata.EpisodeSeries, HeaderMetadata.Season, - HeaderMetadata.DateAdded, + HeaderMetadata.EpisodeNumber, + HeaderMetadata.DateAdded, HeaderMetadata.ReleaseDate, HeaderMetadata.Year, HeaderMetadata.Genres, @@ -450,6 +451,12 @@ namespace MediaBrowser.Api.Reports internalHeader = HeaderMetadata.Season; break; + case HeaderMetadata.EpisodeNumber: + option.Column = (i, r) => this.GetObject(i, (x) => x.IndexNumber == null ? "" : x.IndexNumber.ToString()); + //option.Header.SortField = "IndexNumber"; + //option.Header.HeaderFieldType = ReportFieldType.Int; + break; + case HeaderMetadata.Network: option.Column = (i, r) => this.GetListAsString(i.Studios); option.ItemID = (i) => this.GetStudioID(i.Studios.FirstOrDefault()); diff --git a/MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs b/MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs deleted file mode 100644 index 52b095dee..000000000 --- a/MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs +++ /dev/null @@ -1,256 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Library; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace MediaBrowser.Api.Reports -{ - /// A report stat builder. - /// - public class ReportStatBuilder : ReportBuilderBase - { - #region [Constructors] - - /// - /// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatBuilder class. - /// Manager for library. - public ReportStatBuilder(ILibraryManager libraryManager) - : base(libraryManager) - { - } - - #endregion - - #region [Public Methods] - - /// Gets report stat result. - /// The items. - /// List of types of the report include items. - /// The top item. - /// The report stat result. - public ReportStatResult GetResult(BaseItem[] items, ReportIncludeItemTypes reportIncludeItemTypes, int topItem = 5) - { - ReportStatResult result = new ReportStatResult(); - result = this.GetResultGenres(result, items, topItem); - result = this.GetResultStudios(result, items, topItem); - result = this.GetResultPersons(result, items, topItem); - result = this.GetResultProductionYears(result, items, topItem); - result = this.GetResultCommunityRatings(result, items, topItem); - result = this.GetResultParentalRatings(result, items, topItem); - - switch (reportIncludeItemTypes) - { - case ReportIncludeItemTypes.Season: - case ReportIncludeItemTypes.Series: - case ReportIncludeItemTypes.MusicAlbum: - case ReportIncludeItemTypes.MusicArtist: - case ReportIncludeItemTypes.Game: - break; - case ReportIncludeItemTypes.Movie: - case ReportIncludeItemTypes.BoxSet: - - break; - case ReportIncludeItemTypes.Book: - case ReportIncludeItemTypes.Episode: - case ReportIncludeItemTypes.Video: - case ReportIncludeItemTypes.MusicVideo: - case ReportIncludeItemTypes.Trailer: - case ReportIncludeItemTypes.Audio: - case ReportIncludeItemTypes.BaseItem: - default: - break; - } - - result.Groups = result.Groups.OrderByDescending(n => n.Items.Count()).ToList(); - - return result; - } - - #endregion - - #region [Protected Internal Methods] - /// Gets the headers. - /// Type of the header. - /// The request. - /// The headers. - /// - protected internal override List GetHeaders(H request) - { - throw new NotImplementedException(); - } - - #endregion - - #region [Private Methods] - - /// Gets the groups. - /// The result. - /// The header. - /// The top item. - /// The top. - private void GetGroups(ReportStatResult result, string header, int topItem, IEnumerable top) - { - if (top != null && top.Count() > 0) - { - var group = new ReportStatGroup { Header = ReportStatGroup.FormatedHeader(header, topItem) }; - group.Items.AddRange(top); - result.Groups.Add(group); - } - } - - /// Gets result community ratings. - /// The result. - /// The items. - /// The top item. - /// The result community ratings. - private ReportStatResult GetResultCommunityRatings(ReportStatResult result, BaseItem[] items, int topItem = 5) - { - this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.CommunityRating), topItem, - items.Where(x => x.CommunityRating != null && x.CommunityRating > 0) - .GroupBy(x => x.CommunityRating) - .OrderByDescending(x => x.Count()) - .Take(topItem) - .Select(x => new ReportStatItem - { - Name = x.Key.ToString(), - Value = x.Count().ToString() - }) - ); - - return result; - } - - /// Gets result genres. - /// The result. - /// The items. - /// The top item. - /// The result genres. - private ReportStatResult GetResultGenres(ReportStatResult result, BaseItem[] items, int topItem = 5) - { - this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Genres), topItem, - items.SelectMany(x => x.Genres) - .GroupBy(x => x) - .OrderByDescending(x => x.Count()) - .Take(topItem) - .Select(x => new ReportStatItem - { - Name = x.Key, - Value = x.Count().ToString(), - Id = GetGenreID(x.Key) - })); - return result; - - } - - /// Gets result parental ratings. - /// The result. - /// The items. - /// The top item. - /// The result parental ratings. - private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5) - { - this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.ParentalRatings), topItem, - items.Where(x => x.OfficialRating != null) - .GroupBy(x => x.OfficialRating) - .OrderByDescending(x => x.Count()) - .Take(topItem) - .Select(x => new ReportStatItem - { - Name = x.Key.ToString(), - Value = x.Count().ToString() - }) - ); - - return result; - } - - /// Gets result persons. - /// The result. - /// The items. - /// The top item. - /// The result persons. - private ReportStatResult GetResultPersons(ReportStatResult result, BaseItem[] items, int topItem = 5) - { - List t = new List - { - HeaderMetadata.Actor, - HeaderMetadata.Composer, - HeaderMetadata.Director, - HeaderMetadata.GuestStar, - HeaderMetadata.Producer, - HeaderMetadata.Writer, - HeaderMetadata.Artist, - HeaderMetadata.AlbumArtist - }; - foreach (var item in t) - { - var ps = items.SelectMany(x => _libraryManager.GetPeople(x)) - .Where(n => n.Type == item.ToString()) - .GroupBy(x => x.Name) - .OrderByDescending(x => x.Count()) - .Take(topItem); - if (ps != null && ps.Count() > 0) - this.GetGroups(result, GetLocalizedHeader(item), topItem, - ps.Select(x => new ReportStatItem - { - Name = x.Key, - Value = x.Count().ToString(), - Id = GetPersonID(x.Key) - }) - ); - } - - return result; - } - - /// Gets result production years. - /// The result. - /// The items. - /// The top item. - /// The result production years. - private ReportStatResult GetResultProductionYears(ReportStatResult result, BaseItem[] items, int topItem = 5) - { - this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Year), topItem, - items.Where(x => x.ProductionYear != null && x.ProductionYear > 0) - .GroupBy(x => x.ProductionYear) - .OrderByDescending(x => x.Count()) - .Take(topItem) - .Select(x => new ReportStatItem - { - Name = x.Key.ToString(), - Value = x.Count().ToString() - }) - ); - - return result; - } - - /// Gets result studios. - /// The result. - /// The items. - /// The top item. - /// The result studios. - private ReportStatResult GetResultStudios(ReportStatResult result, BaseItem[] items, int topItem = 5) - { - this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Studios), topItem, - items.SelectMany(x => x.Studios) - .GroupBy(x => x) - .OrderByDescending(x => x.Count()) - .Take(topItem) - .Select(x => new ReportStatItem - { - Name = x.Key, - Value = x.Count().ToString(), - Id = GetStudioID(x.Key) - }) - ); - - return result; - - } - - #endregion - - } -} diff --git a/MediaBrowser.Api/Reports/Stat/ReportStatGroup.cs b/MediaBrowser.Api/Reports/Stat/ReportStatGroup.cs deleted file mode 100644 index f901b5417..000000000 --- a/MediaBrowser.Api/Reports/Stat/ReportStatGroup.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; - -namespace MediaBrowser.Api.Reports -{ - /// A report stat group. - public class ReportStatGroup - { - /// - /// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatGroup class. - public ReportStatGroup() - { - Items = new List(); - TotalRecordCount = 0; - } - - /// Gets or sets the header. - /// The header. - public string Header { get; set; } - - /// Gets or sets the items. - /// The items. - public List Items { get; set; } - - /// Gets or sets the number of total records. - /// The total number of record count. - public int TotalRecordCount { get; set; } - - internal static string FormatedHeader(string header, int topItem) - { - return string.Format("Top {0} {1}", topItem, header); - } - } -} diff --git a/MediaBrowser.Api/Reports/Stat/ReportStatItem.cs b/MediaBrowser.Api/Reports/Stat/ReportStatItem.cs deleted file mode 100644 index c93ba15af..000000000 --- a/MediaBrowser.Api/Reports/Stat/ReportStatItem.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace MediaBrowser.Api.Reports -{ - /// A report stat item. - public class ReportStatItem - { - /// Gets or sets the name. - /// The name. - public string Name { get; set; } - - /// Gets or sets the image. - /// The image. - public string Image { get; set; } - - /// Gets or sets the value. - /// The value. - public string Value { get; set; } - - /// Gets or sets the identifier. - /// The identifier. - public string Id { get; set; } - - } -} diff --git a/MediaBrowser.Api/Reports/Stat/ReportStatResult.cs b/MediaBrowser.Api/Reports/Stat/ReportStatResult.cs deleted file mode 100644 index fbf98fc17..000000000 --- a/MediaBrowser.Api/Reports/Stat/ReportStatResult.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; - -namespace MediaBrowser.Api.Reports -{ - /// Encapsulates the result of a report stat. - public class ReportStatResult - { - /// - /// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatResult class. - public ReportStatResult() - { - Groups = new List(); - TotalRecordCount = 0; - } - - /// Gets or sets the groups. - /// The groups. - public List Groups { get; set; } - - /// Gets or sets the number of total records. - /// The total number of record count. - public int TotalRecordCount { get; set; } - } -}