diff options
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/ItemsService.cs | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index c732e27d6..68a56607e 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -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 |
