jellyfin/MediaBrowser.Controller/Entities/InternalItemsQuery.cs

268 lines
9.9 KiB
C#
Raw Normal View History

2015-07-28 21:42:24 +02:00
using MediaBrowser.Model.Entities;
using System;
2015-07-28 21:42:24 +02:00
using System.Collections.Generic;
2015-11-06 16:02:22 +01:00
using MediaBrowser.Model.Configuration;
2016-10-08 07:57:38 +02:00
using System.Linq;
2016-10-10 20:18:28 +02:00
using MediaBrowser.Controller.Dto;
2016-10-08 07:57:38 +02:00
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Controller.Entities
{
2014-10-07 01:58:46 +02:00
public class InternalItemsQuery
{
public bool Recursive { get; set; }
public int? StartIndex { get; set; }
public int? Limit { get; set; }
public string[] SortBy { get; set; }
public SortOrder SortOrder { get; set; }
public User User { get; set; }
2016-06-01 07:50:00 +02:00
public BaseItem SimilarTo { get; set; }
public bool? IsFolder { get; set; }
public bool? IsFavorite { get; set; }
2014-10-07 01:58:46 +02:00
public bool? IsFavoriteOrLiked { get; set; }
public bool? IsLiked { get; set; }
public bool? IsPlayed { get; set; }
public bool? IsResumable { get; set; }
2016-02-14 18:58:31 +01:00
public bool? IncludeItemsByName { get; set; }
public string[] MediaTypes { get; set; }
2014-10-07 01:58:46 +02:00
public string[] IncludeItemTypes { get; set; }
public string[] ExcludeItemTypes { get; set; }
2015-11-15 23:30:47 +01:00
public string[] ExcludeTags { get; set; }
2016-04-15 04:39:39 +02:00
public string[] ExcludeInheritedTags { get; set; }
2014-10-08 03:37:45 +02:00
public string[] Genres { get; set; }
public string[] Keywords { get; set; }
2014-10-08 03:37:45 +02:00
2016-08-18 07:56:10 +02:00
public bool? IsSpecialSeason { get; set; }
2014-10-08 03:37:45 +02:00
public bool? IsMissing { get; set; }
public bool? IsUnaired { get; set; }
public bool? IsVirtualUnaired { get; set; }
public bool? CollapseBoxSetItems { get; set; }
public string NameStartsWithOrGreater { get; set; }
public string NameStartsWith { get; set; }
public string NameLessThan { get; set; }
2015-07-18 21:32:59 +02:00
public string NameContains { get; set; }
2016-06-29 18:31:01 +02:00
public string MinSortName { get; set; }
2014-10-08 03:37:45 +02:00
2016-05-02 07:32:04 +02:00
public string PresentationUniqueKey { get; set; }
2016-03-01 20:39:46 +01:00
public string Path { get; set; }
2016-08-18 07:56:10 +02:00
public string PathNotStartsWith { get; set; }
2016-05-04 18:32:34 +02:00
public string Name { get; set; }
2016-05-06 06:50:39 +02:00
public string SlugName { get; set; }
2016-05-04 18:32:34 +02:00
2014-10-08 03:37:45 +02:00
public string Person { get; set; }
2015-03-18 17:40:16 +01:00
public string[] PersonIds { get; set; }
2015-07-14 21:04:16 +02:00
public string[] ItemIds { get; set; }
2016-05-31 20:42:32 +02:00
public string[] ExcludeItemIds { get; set; }
2014-10-08 03:37:45 +02:00
public string AdjacentTo { get; set; }
public string[] PersonTypes { get; set; }
public bool? Is3D { get; set; }
public bool? IsHD { get; set; }
public bool? IsInBoxSet { get; set; }
public bool? IsLocked { get; set; }
public bool? IsPlaceHolder { get; set; }
public bool? HasImdbId { get; set; }
public bool? HasOverview { get; set; }
public bool? HasTmdbId { get; set; }
public bool? HasOfficialRating { get; set; }
public bool? HasTvdbId { get; set; }
public bool? HasThemeSong { get; set; }
public bool? HasThemeVideo { get; set; }
public bool? HasSubtitles { get; set; }
public bool? HasSpecialFeature { get; set; }
public bool? HasTrailer { get; set; }
public bool? HasParentalRating { get; set; }
2015-03-13 19:45:03 +01:00
public string[] StudioIds { get; set; }
2015-11-06 16:02:22 +01:00
public string[] GenreIds { get; set; }
2014-10-08 03:37:45 +02:00
public ImageType[] ImageTypes { get; set; }
public VideoType[] VideoTypes { get; set; }
2015-11-06 16:02:22 +01:00
public UnratedItem[] BlockUnratedItems { get; set; }
2014-10-08 03:37:45 +02:00
public int[] Years { get; set; }
public string[] Tags { get; set; }
public string[] OfficialRatings { get; set; }
2014-10-07 01:58:46 +02:00
2015-10-28 20:40:38 +01:00
public DateTime? MinPremiereDate { get; set; }
2016-03-20 07:46:51 +01:00
public DateTime? MaxPremiereDate { get; set; }
2015-06-01 16:49:23 +02:00
public DateTime? MinStartDate { get; set; }
public DateTime? MaxStartDate { get; set; }
public DateTime? MinEndDate { get; set; }
public DateTime? MaxEndDate { get; set; }
public bool? IsAiring { get; set; }
public bool? IsMovie { get; set; }
public bool? IsSports { get; set; }
2015-06-01 19:49:11 +02:00
public bool? IsKids { get; set; }
2016-09-29 14:55:49 +02:00
public bool? IsNews { get; set; }
public bool? IsSeries { get; set; }
2015-07-14 21:04:16 +02:00
public int? MinPlayers { get; set; }
public int? MaxPlayers { get; set; }
2015-11-06 16:53:23 +01:00
public int? MinIndexNumber { get; set; }
2016-03-20 21:04:27 +01:00
public int? AiredDuringSeason { get; set; }
2015-07-14 21:04:16 +02:00
public double? MinCriticRating { get; set; }
public double? MinCommunityRating { get; set; }
2016-03-01 19:42:39 +01:00
2015-06-01 16:49:23 +02:00
public string[] ChannelIds { get; set; }
2015-07-14 21:04:16 +02:00
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
2016-03-20 20:53:22 +01:00
public int? ParentIndexNumber { get; set; }
2016-06-15 04:18:19 +02:00
public int? ParentIndexNumberNotEquals { get; set; }
2016-05-04 18:32:34 +02:00
public int? IndexNumber { get; set; }
2016-03-21 04:10:37 +01:00
public int? MinParentalRating { get; set; }
2015-07-28 14:33:30 +02:00
public int? MaxParentalRating { get; set; }
2015-07-14 21:04:16 +02:00
2015-08-28 06:19:08 +02:00
public bool? HasDeadParentId { get; set; }
2016-06-12 07:03:52 +02:00
public bool? IsVirtualItem { get; set; }
2015-09-16 19:16:39 +02:00
2015-09-24 04:31:40 +02:00
public Guid? ParentId { get; set; }
2015-10-29 14:28:05 +01:00
public string[] AncestorIds { get; set; }
2015-11-14 19:57:26 +01:00
public string[] TopParentIds { get; set; }
2015-10-29 20:01:04 +01:00
2016-03-20 20:53:22 +01:00
public LocationType[] LocationTypes { get; set; }
2016-03-01 19:42:39 +01:00
public string[] PresetViews { get; set; }
2016-03-19 06:04:38 +01:00
public SourceType[] SourceTypes { get; set; }
2016-03-19 16:38:05 +01:00
public SourceType[] ExcludeSourceTypes { get; set; }
2016-03-19 20:32:37 +01:00
public TrailerType[] TrailerTypes { get; set; }
2016-03-01 19:42:39 +01:00
2016-03-20 20:53:22 +01:00
public DayOfWeek[] AirDays { get; set; }
public SeriesStatus[] SeriesStatuses { get; set; }
2016-03-21 01:15:56 +01:00
public string AlbumArtistStartsWithOrGreater { get; set; }
2016-10-01 09:06:00 +02:00
public string ExternalSeriesId { get; set; }
public string ExternalId { get; set; }
2016-03-21 01:15:56 +01:00
2016-03-21 17:50:50 +01:00
public string[] AlbumNames { get; set; }
2016-12-20 20:59:25 +01:00
public string[] ArtistIds { get; set; }
2016-07-23 00:10:39 +02:00
public string[] ExcludeArtistIds { get; set; }
2016-05-07 19:47:41 +02:00
public string AncestorWithPresentationUniqueKey { get; set; }
2016-12-06 09:24:29 +01:00
public string SeriesPresentationUniqueKey { get; set; }
2016-05-06 06:50:39 +02:00
public bool GroupByPresentationUniqueKey { get; set; }
2016-05-09 05:13:38 +02:00
public bool EnableTotalRecordCount { get; set; }
2016-05-18 07:34:10 +02:00
public bool ForceDirect { get; set; }
2016-06-15 04:18:19 +02:00
public Dictionary<string, string> ExcludeProviderIds { get; set; }
2016-06-29 05:17:27 +02:00
public bool EnableGroupByMetadataKey { get; set; }
2016-05-06 06:50:39 +02:00
2016-09-30 08:50:06 +02:00
public List<Tuple<string, SortOrder>> OrderBy { get; set; }
2016-10-03 08:28:45 +02:00
public DateTime? MinDateCreated { get; set; }
public DateTime? MinDateLastSaved { get; set; }
2016-10-10 20:18:28 +02:00
public DtoOptions DtoOptions { get; set; }
2017-01-07 09:04:54 +01:00
public int MinSimilarityScore { get; set; }
2016-10-08 07:57:38 +02:00
public bool HasField(ItemFields name)
{
2016-10-10 20:18:28 +02:00
var fields = DtoOptions.Fields;
2016-10-08 07:57:38 +02:00
switch (name)
{
2016-10-11 23:33:38 +02:00
case ItemFields.ThemeSongIds:
case ItemFields.ThemeVideoIds:
2016-10-09 09:18:43 +02:00
case ItemFields.ProductionLocations:
2016-10-08 07:57:38 +02:00
case ItemFields.Keywords:
case ItemFields.Taglines:
case ItemFields.CustomRating:
case ItemFields.DateCreated:
case ItemFields.SortName:
case ItemFields.Overview:
case ItemFields.OfficialRatingDescription:
case ItemFields.HomePageUrl:
case ItemFields.VoteCount:
case ItemFields.DisplayMediaType:
2016-10-16 00:12:16 +02:00
//case ItemFields.ServiceName:
2016-10-08 07:57:38 +02:00
case ItemFields.Genres:
case ItemFields.Studios:
case ItemFields.Settings:
case ItemFields.OriginalTitle:
case ItemFields.Tags:
case ItemFields.DateLastMediaAdded:
case ItemFields.CriticRatingSummary:
2016-10-10 20:18:28 +02:00
return fields.Count == 0 || fields.Contains(name);
2016-10-08 07:57:38 +02:00
default:
return true;
}
}
2014-10-07 01:58:46 +02:00
public InternalItemsQuery()
{
2017-01-21 21:27:07 +01:00
MinSimilarityScore = 20;
2017-01-07 09:04:54 +01:00
2016-05-06 06:50:39 +02:00
GroupByPresentationUniqueKey = true;
2016-05-09 05:13:38 +02:00
EnableTotalRecordCount = true;
2016-05-06 06:50:39 +02:00
2016-10-10 20:18:28 +02:00
DtoOptions = new DtoOptions();
2016-03-21 17:50:50 +01:00
AlbumNames = new string[] { };
2016-12-20 20:59:25 +01:00
ArtistIds = new string[] { };
2016-07-23 00:10:39 +02:00
ExcludeArtistIds = new string[] { };
2016-06-02 06:41:12 +02:00
ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
2015-11-06 16:02:22 +01:00
BlockUnratedItems = new UnratedItem[] { };
Tags = new string[] { };
OfficialRatings = new string[] { };
SortBy = new string[] { };
MediaTypes = new string[] { };
Keywords = new string[] { };
2014-10-07 01:58:46 +02:00
IncludeItemTypes = new string[] { };
ExcludeItemTypes = new string[] { };
2014-10-08 03:37:45 +02:00
Genres = new string[] { };
2015-03-13 19:45:03 +01:00
StudioIds = new string[] { };
2015-11-06 16:02:22 +01:00
GenreIds = new string[] { };
2014-10-08 03:37:45 +02:00
ImageTypes = new ImageType[] { };
VideoTypes = new VideoType[] { };
Years = new int[] { };
PersonTypes = new string[] { };
2015-03-18 17:40:16 +01:00
PersonIds = new string[] { };
2015-06-01 16:49:23 +02:00
ChannelIds = new string[] { };
2015-07-14 21:04:16 +02:00
ItemIds = new string[] { };
2016-05-31 20:42:32 +02:00
ExcludeItemIds = new string[] { };
2015-10-29 14:28:05 +01:00
AncestorIds = new string[] { };
2015-11-14 19:57:26 +01:00
TopParentIds = new string[] { };
2015-11-15 23:30:47 +01:00
ExcludeTags = new string[] { };
2016-04-15 04:39:39 +02:00
ExcludeInheritedTags = new string[] { };
2016-03-20 20:53:22 +01:00
LocationTypes = new LocationType[] { };
2016-03-01 19:42:39 +01:00
PresetViews = new string[] { };
2016-03-19 06:04:38 +01:00
SourceTypes = new SourceType[] { };
2016-03-19 16:38:05 +01:00
ExcludeSourceTypes = new SourceType[] { };
2016-03-19 20:32:37 +01:00
TrailerTypes = new TrailerType[] { };
2016-03-20 20:53:22 +01:00
AirDays = new DayOfWeek[] { };
SeriesStatuses = new SeriesStatus[] { };
2016-09-30 08:50:06 +02:00
OrderBy = new List<Tuple<string, SortOrder>>();
}
2015-10-28 20:40:38 +01:00
public InternalItemsQuery(User user)
: this()
2016-05-15 21:25:54 +02:00
{
SetUser(user);
}
public void SetUser(User user)
2015-10-28 20:40:38 +01:00
{
if (user != null)
{
var policy = user.Policy;
MaxParentalRating = policy.MaxParentalRating;
2015-10-29 14:28:05 +01:00
2015-11-15 23:30:47 +01:00
if (policy.MaxParentalRating.HasValue)
{
BlockUnratedItems = policy.BlockUnratedItems;
}
2016-04-15 04:39:39 +02:00
ExcludeInheritedTags = policy.BlockedTags;
2016-03-01 19:42:39 +01:00
2015-10-29 14:28:05 +01:00
User = user;
2015-10-28 20:40:38 +01:00
}
}
}
}