InternalItemsQuery.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using MediaBrowser.Model.Entities;
  2. using System;
  3. using System.Collections.Generic;
  4. using MediaBrowser.Model.Configuration;
  5. using System.Linq;
  6. using MediaBrowser.Controller.Dto;
  7. using MediaBrowser.Model.Querying;
  8. namespace MediaBrowser.Controller.Entities
  9. {
  10. public class InternalItemsQuery
  11. {
  12. public bool Recursive { get; set; }
  13. public int? StartIndex { get; set; }
  14. public int? Limit { get; set; }
  15. public string[] SortBy { get; set; }
  16. public SortOrder SortOrder { get; set; }
  17. public User User { get; set; }
  18. public BaseItem SimilarTo { get; set; }
  19. public bool? IsFolder { get; set; }
  20. public bool? IsFavorite { get; set; }
  21. public bool? IsFavoriteOrLiked { get; set; }
  22. public bool? IsLiked { get; set; }
  23. public bool? IsPlayed { get; set; }
  24. public bool? IsResumable { get; set; }
  25. public bool? IncludeItemsByName { get; set; }
  26. public string[] MediaTypes { get; set; }
  27. public string[] IncludeItemTypes { get; set; }
  28. public string[] ExcludeItemTypes { get; set; }
  29. public string[] ExcludeTags { get; set; }
  30. public string[] ExcludeInheritedTags { get; set; }
  31. public string[] Genres { get; set; }
  32. public string[] Keywords { get; set; }
  33. public bool? IsSpecialSeason { get; set; }
  34. public bool? IsMissing { get; set; }
  35. public bool? IsUnaired { get; set; }
  36. public bool? IsVirtualUnaired { get; set; }
  37. public bool? CollapseBoxSetItems { get; set; }
  38. public string NameStartsWithOrGreater { get; set; }
  39. public string NameStartsWith { get; set; }
  40. public string NameLessThan { get; set; }
  41. public string NameContains { get; set; }
  42. public string MinSortName { get; set; }
  43. public string PresentationUniqueKey { get; set; }
  44. public string Path { get; set; }
  45. public string PathNotStartsWith { get; set; }
  46. public string Name { get; set; }
  47. public string SlugName { get; set; }
  48. public string Person { get; set; }
  49. public string[] PersonIds { get; set; }
  50. public string[] ItemIds { get; set; }
  51. public string[] ExcludeItemIds { get; set; }
  52. public string AdjacentTo { get; set; }
  53. public string[] PersonTypes { get; set; }
  54. public bool? Is3D { get; set; }
  55. public bool? IsHD { get; set; }
  56. public bool? IsInBoxSet { get; set; }
  57. public bool? IsLocked { get; set; }
  58. public bool? IsPlaceHolder { get; set; }
  59. public bool? HasImdbId { get; set; }
  60. public bool? HasOverview { get; set; }
  61. public bool? HasTmdbId { get; set; }
  62. public bool? HasOfficialRating { get; set; }
  63. public bool? HasTvdbId { get; set; }
  64. public bool? HasThemeSong { get; set; }
  65. public bool? HasThemeVideo { get; set; }
  66. public bool? HasSubtitles { get; set; }
  67. public bool? HasSpecialFeature { get; set; }
  68. public bool? HasTrailer { get; set; }
  69. public bool? HasParentalRating { get; set; }
  70. public string[] StudioIds { get; set; }
  71. public string[] GenreIds { get; set; }
  72. public ImageType[] ImageTypes { get; set; }
  73. public VideoType[] VideoTypes { get; set; }
  74. public UnratedItem[] BlockUnratedItems { get; set; }
  75. public int[] Years { get; set; }
  76. public string[] Tags { get; set; }
  77. public string[] OfficialRatings { get; set; }
  78. public DateTime? MinPremiereDate { get; set; }
  79. public DateTime? MaxPremiereDate { get; set; }
  80. public DateTime? MinStartDate { get; set; }
  81. public DateTime? MaxStartDate { get; set; }
  82. public DateTime? MinEndDate { get; set; }
  83. public DateTime? MaxEndDate { get; set; }
  84. public bool? IsAiring { get; set; }
  85. public bool? IsMovie { get; set; }
  86. public bool? IsSports { get; set; }
  87. public bool? IsKids { get; set; }
  88. public bool? IsNews { get; set; }
  89. public bool? IsSeries { get; set; }
  90. public int? MinPlayers { get; set; }
  91. public int? MaxPlayers { get; set; }
  92. public int? MinIndexNumber { get; set; }
  93. public int? AiredDuringSeason { get; set; }
  94. public double? MinCriticRating { get; set; }
  95. public double? MinCommunityRating { get; set; }
  96. public string[] ChannelIds { get; set; }
  97. internal List<Guid> ItemIdsFromPersonFilters { get; set; }
  98. public int? ParentIndexNumber { get; set; }
  99. public int? ParentIndexNumberNotEquals { get; set; }
  100. public int? IndexNumber { get; set; }
  101. public int? MinParentalRating { get; set; }
  102. public int? MaxParentalRating { get; set; }
  103. public bool? HasDeadParentId { get; set; }
  104. public bool? IsVirtualItem { get; set; }
  105. public Guid? ParentId { get; set; }
  106. public string[] AncestorIds { get; set; }
  107. public string[] TopParentIds { get; set; }
  108. public string[] PresetViews { get; set; }
  109. public SourceType[] SourceTypes { get; set; }
  110. public SourceType[] ExcludeSourceTypes { get; set; }
  111. public TrailerType[] TrailerTypes { get; set; }
  112. public DayOfWeek[] AirDays { get; set; }
  113. public SeriesStatus[] SeriesStatuses { get; set; }
  114. public string AlbumArtistStartsWithOrGreater { get; set; }
  115. public string ExternalSeriesId { get; set; }
  116. public string ExternalId { get; set; }
  117. public string[] AlbumIds { get; set; }
  118. public string[] ArtistIds { get; set; }
  119. public string[] ExcludeArtistIds { get; set; }
  120. public string AncestorWithPresentationUniqueKey { get; set; }
  121. public string SeriesPresentationUniqueKey { get; set; }
  122. public bool GroupByPresentationUniqueKey { get; set; }
  123. public bool EnableTotalRecordCount { get; set; }
  124. public bool ForceDirect { get; set; }
  125. public Dictionary<string, string> ExcludeProviderIds { get; set; }
  126. public bool EnableGroupByMetadataKey { get; set; }
  127. public List<Tuple<string, SortOrder>> OrderBy { get; set; }
  128. public DateTime? MinDateCreated { get; set; }
  129. public DateTime? MinDateLastSaved { get; set; }
  130. public DtoOptions DtoOptions { get; set; }
  131. public int MinSimilarityScore { get; set; }
  132. public bool HasField(ItemFields name)
  133. {
  134. var fields = DtoOptions.Fields;
  135. switch (name)
  136. {
  137. case ItemFields.ThemeSongIds:
  138. case ItemFields.ThemeVideoIds:
  139. case ItemFields.ProductionLocations:
  140. case ItemFields.Keywords:
  141. case ItemFields.Taglines:
  142. case ItemFields.CustomRating:
  143. case ItemFields.DateCreated:
  144. case ItemFields.SortName:
  145. case ItemFields.Overview:
  146. case ItemFields.HomePageUrl:
  147. case ItemFields.VoteCount:
  148. case ItemFields.DisplayMediaType:
  149. //case ItemFields.ServiceName:
  150. case ItemFields.Genres:
  151. case ItemFields.Studios:
  152. case ItemFields.Settings:
  153. case ItemFields.OriginalTitle:
  154. case ItemFields.Tags:
  155. case ItemFields.DateLastMediaAdded:
  156. return fields.Count == 0 || fields.Contains(name);
  157. default:
  158. return true;
  159. }
  160. }
  161. public InternalItemsQuery()
  162. {
  163. MinSimilarityScore = 20;
  164. GroupByPresentationUniqueKey = true;
  165. EnableTotalRecordCount = true;
  166. DtoOptions = new DtoOptions();
  167. AlbumIds = new string[] { };
  168. ArtistIds = new string[] { };
  169. ExcludeArtistIds = new string[] { };
  170. ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  171. BlockUnratedItems = new UnratedItem[] { };
  172. Tags = new string[] { };
  173. OfficialRatings = new string[] { };
  174. SortBy = new string[] { };
  175. MediaTypes = new string[] { };
  176. Keywords = new string[] { };
  177. IncludeItemTypes = new string[] { };
  178. ExcludeItemTypes = new string[] { };
  179. Genres = new string[] { };
  180. StudioIds = new string[] { };
  181. GenreIds = new string[] { };
  182. ImageTypes = new ImageType[] { };
  183. VideoTypes = new VideoType[] { };
  184. Years = new int[] { };
  185. PersonTypes = new string[] { };
  186. PersonIds = new string[] { };
  187. ChannelIds = new string[] { };
  188. ItemIds = new string[] { };
  189. ExcludeItemIds = new string[] { };
  190. AncestorIds = new string[] { };
  191. TopParentIds = new string[] { };
  192. ExcludeTags = new string[] { };
  193. ExcludeInheritedTags = new string[] { };
  194. PresetViews = new string[] { };
  195. SourceTypes = new SourceType[] { };
  196. ExcludeSourceTypes = new SourceType[] { };
  197. TrailerTypes = new TrailerType[] { };
  198. AirDays = new DayOfWeek[] { };
  199. SeriesStatuses = new SeriesStatus[] { };
  200. OrderBy = new List<Tuple<string, SortOrder>>();
  201. }
  202. public InternalItemsQuery(User user)
  203. : this()
  204. {
  205. SetUser(user);
  206. }
  207. public void SetUser(User user)
  208. {
  209. if (user != null)
  210. {
  211. var policy = user.Policy;
  212. MaxParentalRating = policy.MaxParentalRating;
  213. if (policy.MaxParentalRating.HasValue)
  214. {
  215. BlockUnratedItems = policy.BlockUnratedItems;
  216. }
  217. ExcludeInheritedTags = policy.BlockedTags;
  218. User = user;
  219. }
  220. }
  221. }
  222. }