added sorting by mpaa rating
This commit is contained in:
parent
4b3ce596a1
commit
683f00ba38
|
@ -31,6 +31,10 @@ namespace MediaBrowser.Model.Querying
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string DateCreated = "DateCreated";
|
public const string DateCreated = "DateCreated";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The official rating
|
||||||
|
/// </summary>
|
||||||
|
public const string OfficialRating = "OfficialRating";
|
||||||
|
/// <summary>
|
||||||
/// The date played
|
/// The date played
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string DatePlayed = "DatePlayed";
|
public const string DatePlayed = "DatePlayed";
|
||||||
|
|
|
@ -173,6 +173,7 @@
|
||||||
<Compile Include="Sorting\CriticRatingComparer.cs" />
|
<Compile Include="Sorting\CriticRatingComparer.cs" />
|
||||||
<Compile Include="Sorting\DateCreatedComparer.cs" />
|
<Compile Include="Sorting\DateCreatedComparer.cs" />
|
||||||
<Compile Include="Sorting\DatePlayedComparer.cs" />
|
<Compile Include="Sorting\DatePlayedComparer.cs" />
|
||||||
|
<Compile Include="Sorting\OfficialRatingComparer.cs" />
|
||||||
<Compile Include="Sorting\PlayCountComparer.cs" />
|
<Compile Include="Sorting\PlayCountComparer.cs" />
|
||||||
<Compile Include="Sorting\PremiereDateComparer.cs" />
|
<Compile Include="Sorting\PremiereDateComparer.cs" />
|
||||||
<Compile Include="Sorting\ProductionYearComparer.cs" />
|
<Compile Include="Sorting\ProductionYearComparer.cs" />
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Localization;
|
||||||
|
using MediaBrowser.Controller.Sorting;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Server.Implementations.Sorting
|
||||||
|
{
|
||||||
|
public class OfficialRatingComparer : IBaseItemComparer
|
||||||
|
{
|
||||||
|
private readonly ILocalizationManager _localization;
|
||||||
|
|
||||||
|
public OfficialRatingComparer(ILocalizationManager localization)
|
||||||
|
{
|
||||||
|
_localization = localization;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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)
|
||||||
|
{
|
||||||
|
var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;
|
||||||
|
var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;
|
||||||
|
|
||||||
|
return levelX.CompareTo(levelY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name.</value>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return ItemSortBy.OfficialRating; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user