fixed ratings. moved them to static text files

This commit is contained in:
Luke Pulverenti
2013-06-10 13:46:11 -04:00
parent c174859b52
commit d2933cab73
17 changed files with 264 additions and 438 deletions

View File

@@ -202,6 +202,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly ILibrarySearchEngine _searchEngine;
private readonly ILocalizationManager _localization;
/// <summary>
/// Initializes a new instance of the <see cref="ItemsService" /> class.
@@ -451,17 +452,47 @@ namespace MediaBrowser.Api.UserLibrary
// Min official rating
if (!string.IsNullOrEmpty(request.MinOfficialRating))
{
var level = Ratings.Level(request.MinOfficialRating);
var level = _localization.GetRatingLevel(request.MinOfficialRating);
items = items.Where(i => Ratings.Level(i.CustomRating ?? i.OfficialRating) >= level);
if (level.HasValue)
{
items = items.Where(i =>
{
var rating = i.CustomRating ?? i.OfficialRating;
if (string.IsNullOrEmpty(rating))
{
return true;
}
var itemLevel = _localization.GetRatingLevel(rating);
return !itemLevel.HasValue || itemLevel.Value >= level.Value;
});
}
}
// Max official rating
if (!string.IsNullOrEmpty(request.MaxOfficialRating))
{
var level = Ratings.Level(request.MaxOfficialRating);
var level = _localization.GetRatingLevel(request.MinOfficialRating);
items = items.Where(i => Ratings.Level(i.CustomRating ?? i.OfficialRating) <= level);
if (level.HasValue)
{
items = items.Where(i =>
{
var rating = i.CustomRating ?? i.OfficialRating;
if (string.IsNullOrEmpty(rating))
{
return true;
}
var itemLevel = _localization.GetRatingLevel(rating);
return !itemLevel.HasValue || itemLevel.Value <= level.Value;
});
}
}
// Exclude item types