add adult content filter to catalog

This commit is contained in:
Luke Pulverenti 2014-06-07 17:06:01 -04:00
parent e210825e54
commit 4f0e6f61e7
5 changed files with 20 additions and 9 deletions

View File

@ -49,7 +49,7 @@ namespace MediaBrowser.Api
} }
[Route("/Channels/{Id}/Items", "GET", Summary = "Gets channel items")] [Route("/Channels/{Id}/Items", "GET", Summary = "Gets channel items")]
public class GetChannelItems : IReturn<QueryResult<BaseItemDto>> public class GetChannelItems : IReturn<QueryResult<BaseItemDto>>, IHasItemFields
{ {
[ApiMember(Name = "Id", Description = "Channel Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] [ApiMember(Name = "Id", Description = "Channel Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Id { get; set; } public string Id { get; set; }
@ -87,6 +87,9 @@ namespace MediaBrowser.Api
[ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] [ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string SortBy { get; set; } public string SortBy { get; set; }
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Fields { get; set; }
/// <summary> /// <summary>
/// Gets the filters. /// Gets the filters.
/// </summary> /// </summary>
@ -163,7 +166,8 @@ namespace MediaBrowser.Api
FolderId = request.FolderId, FolderId = request.FolderId,
SortOrder = request.SortOrder, SortOrder = request.SortOrder,
SortBy = (request.SortBy ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), SortBy = (request.SortBy ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(),
Filters = request.GetFilters().ToArray() Filters = request.GetFilters().ToArray(),
Fields = request.GetItemFields().ToList()
}, CancellationToken.None).Result; }, CancellationToken.None).Result;

View File

@ -50,6 +50,9 @@ namespace MediaBrowser.Api
[ApiMember(Name = "IsPremium", Description = "Optional. Filter by premium status", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] [ApiMember(Name = "IsPremium", Description = "Optional. Filter by premium status", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? IsPremium { get; set; } public bool? IsPremium { get; set; }
[ApiMember(Name = "IsAdult", Description = "Optional. Filter by package that contain adult content.", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? IsAdult { get; set; }
} }
/// <summary> /// <summary>
@ -193,6 +196,11 @@ namespace MediaBrowser.Api
packages = packages.Where(p => p.isPremium == request.IsPremium.Value); packages = packages.Where(p => p.isPremium == request.IsPremium.Value);
} }
if (request.IsAdult.HasValue)
{
packages = packages.Where(p => p.adult == request.IsAdult.Value);
}
return ToOptimizedResult(packages.ToList()); return ToOptimizedResult(packages.ToList());
} }

View File

@ -1,5 +1,6 @@
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using System.Collections.Generic;
namespace MediaBrowser.Model.Channels namespace MediaBrowser.Model.Channels
{ {
@ -38,11 +39,13 @@ namespace MediaBrowser.Model.Channels
public SortOrder? SortOrder { get; set; } public SortOrder? SortOrder { get; set; }
public string[] SortBy { get; set; } public string[] SortBy { get; set; }
public ItemFilter[] Filters { get; set; } public ItemFilter[] Filters { get; set; }
public List<ItemFields> Fields { get; set; }
public ChannelItemQuery() public ChannelItemQuery()
{ {
Filters = new ItemFilter[] { }; Filters = new ItemFilter[] { };
SortBy = new string[] { }; SortBy = new string[] { };
Fields = new List<ItemFields>();
} }
} }

View File

@ -797,12 +797,7 @@ namespace MediaBrowser.Server.Implementations.Channels
await RefreshIfNeeded(all, cancellationToken).ConfigureAwait(false); await RefreshIfNeeded(all, cancellationToken).ConfigureAwait(false);
// Get everything var returnItemArray = all.Select(i => _dtoService.GetBaseItemDto(i, query.Fields, user))
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var returnItemArray = all.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToArray(); .ToArray();
return new QueryResult<BaseItemDto> return new QueryResult<BaseItemDto>

View File

@ -823,5 +823,6 @@
"HeaderOtherDisplaySettings": "Display Settings", "HeaderOtherDisplaySettings": "Display Settings",
"HeaderLibraryViews": "Library Views", "HeaderLibraryViews": "Library Views",
"LabelSelectFolderGroups": "Automatically group content from the following folders into views such as Movies, Music and TV:", "LabelSelectFolderGroups": "Automatically group content from the following folders into views such as Movies, Music and TV:",
"LabelSelectFolderGroupsHelp": "Folders that are unchecked will be displayed by themselves in their own view." "LabelSelectFolderGroupsHelp": "Folders that are unchecked will be displayed by themselves in their own view.",
"OptionDisplayAdultContent": "Display adult content"
} }