|
@@ -260,7 +260,8 @@ namespace MediaBrowser.Api.Reports
|
|
|
MinCommunityRating = request.MinCommunityRating,
|
|
|
MinCriticRating = request.MinCriticRating,
|
|
|
ParentIndexNumber = request.ParentIndexNumber,
|
|
|
- AiredDuringSeason = request.AiredDuringSeason
|
|
|
+ AiredDuringSeason = request.AiredDuringSeason,
|
|
|
+ AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater
|
|
|
};
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(request.Ids))
|
|
@@ -337,152 +338,53 @@ namespace MediaBrowser.Api.Reports
|
|
|
query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray();
|
|
|
}
|
|
|
|
|
|
- if (request.HasQueryLimit == false)
|
|
|
+ // Min official rating
|
|
|
+ if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
|
|
{
|
|
|
- query.StartIndex = null;
|
|
|
- query.Limit = null;
|
|
|
+ query.MinParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
|
|
|
}
|
|
|
|
|
|
- return query;
|
|
|
- }
|
|
|
-
|
|
|
- private bool ApplyAdditionalFilters(BaseReportRequest request, BaseItem i, User user, ILibraryManager libraryManager)
|
|
|
- {
|
|
|
- // Artists
|
|
|
- if (!string.IsNullOrEmpty(request.ArtistIds))
|
|
|
+ // Max official rating
|
|
|
+ if (!string.IsNullOrEmpty(request.MaxOfficialRating))
|
|
|
{
|
|
|
- var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
|
|
|
-
|
|
|
- var audio = i as IHasArtist;
|
|
|
-
|
|
|
- if (!(audio != null && artistIds.Any(id =>
|
|
|
- {
|
|
|
- var artistItem = libraryManager.GetItemById(id);
|
|
|
- return artistItem != null && audio.HasAnyArtist(artistItem.Name);
|
|
|
- })))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ query.MaxParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
|
|
|
}
|
|
|
|
|
|
// Artists
|
|
|
if (!string.IsNullOrEmpty(request.Artists))
|
|
|
{
|
|
|
- var artists = request.Artists.Split('|');
|
|
|
-
|
|
|
- var audio = i as IHasArtist;
|
|
|
-
|
|
|
- if (!(audio != null && artists.Any(audio.HasAnyArtist)))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ query.ArtistNames = request.Artists.Split('|');
|
|
|
}
|
|
|
|
|
|
// Albums
|
|
|
if (!string.IsNullOrEmpty(request.Albums))
|
|
|
{
|
|
|
- var albums = request.Albums.Split('|');
|
|
|
-
|
|
|
- var audio = i as Audio;
|
|
|
-
|
|
|
- if (audio != null)
|
|
|
- {
|
|
|
- if (!albums.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase)))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var album = i as MusicAlbum;
|
|
|
-
|
|
|
- if (album != null)
|
|
|
- {
|
|
|
- if (!albums.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase)))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var musicVideo = i as MusicVideo;
|
|
|
-
|
|
|
- if (musicVideo != null)
|
|
|
- {
|
|
|
- if (!albums.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase)))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ query.AlbumNames = request.Albums.Split('|');
|
|
|
}
|
|
|
|
|
|
- // Min index number
|
|
|
- if (request.MinIndexNumber.HasValue)
|
|
|
+ if (request.HasQueryLimit == false)
|
|
|
{
|
|
|
- if (!(i.IndexNumber.HasValue && i.IndexNumber.Value >= request.MinIndexNumber.Value))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ query.StartIndex = null;
|
|
|
+ query.Limit = null;
|
|
|
}
|
|
|
|
|
|
- // Min official rating
|
|
|
- if (!string.IsNullOrEmpty(request.MinOfficialRating))
|
|
|
- {
|
|
|
- var level = _localization.GetRatingLevel(request.MinOfficialRating);
|
|
|
-
|
|
|
- if (level.HasValue)
|
|
|
- {
|
|
|
- var rating = i.CustomRating;
|
|
|
-
|
|
|
- if (string.IsNullOrEmpty(rating))
|
|
|
- {
|
|
|
- rating = i.OfficialRating;
|
|
|
- }
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(rating))
|
|
|
- {
|
|
|
- var itemLevel = _localization.GetRatingLevel(rating);
|
|
|
-
|
|
|
- if (!(!itemLevel.HasValue || itemLevel.Value >= level.Value))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return query;
|
|
|
+ }
|
|
|
|
|
|
- // Max official rating
|
|
|
- if (!string.IsNullOrEmpty(request.MaxOfficialRating))
|
|
|
+ private bool ApplyAdditionalFilters(BaseReportRequest request, BaseItem i, User user, ILibraryManager libraryManager)
|
|
|
+ {
|
|
|
+ // Artists
|
|
|
+ if (!string.IsNullOrEmpty(request.ArtistIds))
|
|
|
{
|
|
|
- var level = _localization.GetRatingLevel(request.MaxOfficialRating);
|
|
|
-
|
|
|
- if (level.HasValue)
|
|
|
- {
|
|
|
- var rating = i.CustomRating;
|
|
|
-
|
|
|
- if (string.IsNullOrEmpty(rating))
|
|
|
- {
|
|
|
- rating = i.OfficialRating;
|
|
|
- }
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(rating))
|
|
|
- {
|
|
|
- var itemLevel = _localization.GetRatingLevel(rating);
|
|
|
-
|
|
|
- if (!(!itemLevel.HasValue || itemLevel.Value <= level.Value))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater))
|
|
|
- {
|
|
|
- var ok = new[] { i }.OfType<IHasAlbumArtist>()
|
|
|
- .Any(p => string.Compare(request.AlbumArtistStartsWithOrGreater, p.AlbumArtists.FirstOrDefault(), StringComparison.CurrentCultureIgnoreCase) < 1);
|
|
|
+ var audio = i as IHasArtist;
|
|
|
|
|
|
- if (!ok)
|
|
|
+ if (!(audio != null && artistIds.Any(id =>
|
|
|
+ {
|
|
|
+ var artistItem = libraryManager.GetItemById(id);
|
|
|
+ return artistItem != null && audio.HasAnyArtist(artistItem.Name);
|
|
|
+ })))
|
|
|
{
|
|
|
return false;
|
|
|
}
|