浏览代码

Added episodes page

Luke Pulverenti 11 年之前
父节点
当前提交
b07a1e67c2

+ 27 - 0
MediaBrowser.Api/UserLibrary/ItemsService.cs

@@ -164,6 +164,9 @@ namespace MediaBrowser.Api.UserLibrary
         [ApiMember(Name = "MinIndexNumber", Description = "Optional filter by minimum index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
         public int? MinIndexNumber { get; set; }
 
+        [ApiMember(Name = "ParentIndexNumber", Description = "Optional filter by parent index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
+        public int? ParentIndexNumber { get; set; }
+
         [ApiMember(Name = "HasParentalRating", Description = "Optional filter by items that have or do not have a parental rating", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
         public bool? HasParentalRating { get; set; }
 
@@ -733,6 +736,30 @@ namespace MediaBrowser.Api.UserLibrary
                 items = items.OfType<Video>().Where(i => i.IsHd == request.IsHD.Value);
             }
 
+            if (request.ParentIndexNumber.HasValue)
+            {
+                var filterValue = request.ParentIndexNumber.Value;
+
+                items = items.Where(i =>
+                {
+                    var episode = i as Episode;
+
+                    if (episode != null)
+                    {
+                        return episode.ParentIndexNumber.HasValue && episode.ParentIndexNumber.Value == filterValue;
+                    }
+
+                    var song = i as Audio;
+
+                    if (song != null)
+                    {
+                        return song.ParentIndexNumber.HasValue && song.ParentIndexNumber.Value == filterValue;
+                    }
+                    
+                    return true;
+                });
+            }
+
             return items;
         }
 

+ 21 - 3
MediaBrowser.Model/Querying/ItemQuery.cs

@@ -43,7 +43,7 @@ namespace MediaBrowser.Model.Querying
         /// </summary>
         /// <value>The artists.</value>
         public string[] Artists { get; set; }
-        
+
         /// <summary>
         /// The sort order to return results with
         /// </summary>
@@ -176,14 +176,32 @@ namespace MediaBrowser.Model.Querying
         /// <value>The max official rating.</value>
         public string MaxOfficialRating { get; set; }
 
+        /// <summary>
+        /// Gets or sets the min index number.
+        /// </summary>
+        /// <value>The min index number.</value>
         public int? MinIndexNumber { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether this instance has parental rating.
+        /// </summary>
+        /// <value><c>null</c> if [has parental rating] contains no value, <c>true</c> if [has parental rating]; otherwise, <c>false</c>.</value>
         public bool? HasParentalRating { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether this instance is HD.
+        /// </summary>
+        /// <value><c>null</c> if [is HD] contains no value, <c>true</c> if [is HD]; otherwise, <c>false</c>.</value>
         public bool? IsHD { get; set; }
-        
+
+        /// <summary>
+        /// Gets or sets the parent index number.
+        /// </summary>
+        /// <value>The parent index number.</value>
+        public int? ParentIndexNumber { get; set; }
+
         /// <summary>
-        /// Initializes a new instance of the <see cref="ItemQuery"/> class.
+        /// Initializes a new instance of the <see cref="ItemQuery" /> class.
         /// </summary>
         public ItemQuery()
         {

+ 1 - 0
MediaBrowser.Model/Querying/ItemSortBy.cs

@@ -81,5 +81,6 @@ namespace MediaBrowser.Model.Querying
         public const string SongCount = "SongCount";
         public const string AlbumCount = "AlbumCount";
         public const string MusicVideoCount = "MusicVideoCount";
+        public const string SeriesSortName = "SeriesSortName";
     }
 }

+ 1 - 0
MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj

@@ -202,6 +202,7 @@
     <Compile Include="Sorting\RevenueComparer.cs" />
     <Compile Include="Sorting\RuntimeComparer.cs" />
     <Compile Include="Sorting\SeriesCountComparer.cs" />
+    <Compile Include="Sorting\SeriesSortNameComparer.cs" />
     <Compile Include="Sorting\SongCountComparer.cs" />
     <Compile Include="Sorting\SortNameComparer.cs" />
     <Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" />

+ 57 - 0
MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs

@@ -0,0 +1,57 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.TV;
+using MediaBrowser.Controller.Sorting;
+using MediaBrowser.Model.Querying;
+using System;
+
+namespace MediaBrowser.Server.Implementations.Sorting
+{
+    class SeriesSortNameComparer : IBaseItemComparer
+    {
+        /// <summary>
+        /// Compares the specified x.
+        /// </summary>
+        /// <param name="x">The x.</param>
+        /// <param name="y">The y.</param>
+        /// <returns>System.Int32.</returns>
+        public int Compare(BaseItem x, BaseItem y)
+        {
+            return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase);
+        }
+
+        private string GetValue(BaseItem item)
+        {
+            Series series = null;
+
+            var season = item as Season;
+
+            if (season != null)
+            {
+                series = season.Series;
+            }
+
+            var episode = item as Episode;
+
+            if (episode != null)
+            {
+                series = episode.Series;
+            }
+
+            if (series == null)
+            {
+                series = item as Series;
+            }
+
+            return series != null ? series.SortName : null;
+        }
+
+        /// <summary>
+        /// Gets the name.
+        /// </summary>
+        /// <value>The name.</value>
+        public string Name
+        {
+            get { return ItemSortBy.SeriesSortName; }
+        }
+    }
+}

+ 1 - 1
MediaBrowser.WebDashboard/Api/DashboardService.cs

@@ -457,7 +457,6 @@ namespace MediaBrowser.WebDashboard.Api
                                       "edititempeople.js",
                                       "edititemimages.js",
                                       "edituserpage.js",
-                                      "favoritetv.js",
                                       "gamesrecommendedpage.js",
                                       "gamesystemspage.js",
                                       "gamespage.js",
@@ -498,6 +497,7 @@ namespace MediaBrowser.WebDashboard.Api
                                       "songs.js",
                                       "supporterkeypage.js",
                                       "supporterpage.js",
+                                      "episodes.js",
                                       "tvgenres.js",
                                       "tvnextup.js",
                                       "tvpeople.js",

+ 4 - 4
MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj

@@ -300,7 +300,7 @@
     <Content Include="dashboard-ui\edititemmetadata.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="dashboard-ui\favoritetv.html">
+    <Content Include="dashboard-ui\episodes.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
     <Content Include="dashboard-ui\gamegenres.html">
@@ -318,6 +318,9 @@
     <Content Include="dashboard-ui\gamesystems.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <Content Include="dashboard-ui\scripts\episodes.js">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="dashboard-ui\scripts\wizardsettings.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
@@ -396,9 +399,6 @@
     <Content Include="dashboard-ui\scripts\edititemmetadata.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="dashboard-ui\scripts\favoritetv.js">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\scripts\itemgallery.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>