InternalItemsQuery.cs 9.9 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.Model.Querying;
  7. namespace MediaBrowser.Controller.Entities
  8. {
  9. public class InternalItemsQuery
  10. {
  11. public bool Recursive { get; set; }
  12. public int? StartIndex { get; set; }
  13. public int? Limit { get; set; }
  14. public string[] SortBy { get; set; }
  15. public SortOrder SortOrder { get; set; }
  16. public User User { get; set; }
  17. public BaseItem SimilarTo { get; set; }
  18. public bool? IsFolder { get; set; }
  19. public bool? IsFavorite { get; set; }
  20. public bool? IsFavoriteOrLiked { get; set; }
  21. public bool? IsLiked { get; set; }
  22. public bool? IsPlayed { get; set; }
  23. public bool? IsResumable { get; set; }
  24. public bool? IncludeItemsByName { get; set; }
  25. public string[] MediaTypes { get; set; }
  26. public string[] IncludeItemTypes { get; set; }
  27. public string[] ExcludeItemTypes { get; set; }
  28. public string[] ExcludeTags { get; set; }
  29. public string[] ExcludeInheritedTags { get; set; }
  30. public string[] Genres { get; set; }
  31. public string[] Keywords { get; set; }
  32. public bool? IsSpecialSeason { get; set; }
  33. public bool? IsMissing { get; set; }
  34. public bool? IsUnaired { get; set; }
  35. public bool? IsVirtualUnaired { get; set; }
  36. public bool? CollapseBoxSetItems { get; set; }
  37. public string NameStartsWithOrGreater { get; set; }
  38. public string NameStartsWith { get; set; }
  39. public string NameLessThan { get; set; }
  40. public string NameContains { get; set; }
  41. public string MinSortName { get; set; }
  42. public string PresentationUniqueKey { get; set; }
  43. public string Path { get; set; }
  44. public string PathNotStartsWith { get; set; }
  45. public string Name { get; set; }
  46. public string SlugName { get; set; }
  47. public string Person { get; set; }
  48. public string[] PersonIds { get; set; }
  49. public string[] ItemIds { get; set; }
  50. public string[] ExcludeItemIds { get; set; }
  51. public string AdjacentTo { get; set; }
  52. public string[] PersonTypes { get; set; }
  53. public bool? Is3D { get; set; }
  54. public bool? IsHD { get; set; }
  55. public bool? IsInBoxSet { get; set; }
  56. public bool? IsLocked { get; set; }
  57. public bool? IsPlaceHolder { get; set; }
  58. public bool? HasImdbId { get; set; }
  59. public bool? HasOverview { get; set; }
  60. public bool? HasTmdbId { get; set; }
  61. public bool? HasOfficialRating { get; set; }
  62. public bool? HasTvdbId { get; set; }
  63. public bool? HasThemeSong { get; set; }
  64. public bool? HasThemeVideo { get; set; }
  65. public bool? HasSubtitles { get; set; }
  66. public bool? HasSpecialFeature { get; set; }
  67. public bool? HasTrailer { get; set; }
  68. public bool? HasParentalRating { get; set; }
  69. public string[] Studios { 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? IsCurrentSchema { get; set; }
  104. public bool? HasDeadParentId { get; set; }
  105. public bool? IsOffline { get; set; }
  106. public bool? IsVirtualItem { get; set; }
  107. public Guid? ParentId { get; set; }
  108. public string[] AncestorIds { get; set; }
  109. public string[] TopParentIds { get; set; }
  110. public LocationType[] LocationTypes { get; set; }
  111. public LocationType[] ExcludeLocationTypes { get; set; }
  112. public string[] PresetViews { get; set; }
  113. public SourceType[] SourceTypes { get; set; }
  114. public SourceType[] ExcludeSourceTypes { get; set; }
  115. public TrailerType[] TrailerTypes { get; set; }
  116. public DayOfWeek[] AirDays { get; set; }
  117. public SeriesStatus[] SeriesStatuses { get; set; }
  118. public string AlbumArtistStartsWithOrGreater { get; set; }
  119. public string ExternalSeriesId { get; set; }
  120. public string[] AlbumNames { get; set; }
  121. public string[] ArtistNames { get; set; }
  122. public string[] ExcludeArtistIds { get; set; }
  123. public string AncestorWithPresentationUniqueKey { get; set; }
  124. public bool GroupByPresentationUniqueKey { get; set; }
  125. public bool EnableTotalRecordCount { get; set; }
  126. public bool ForceDirect { get; set; }
  127. public Dictionary<string, string> ExcludeProviderIds { get; set; }
  128. public bool EnableGroupByMetadataKey { get; set; }
  129. public List<Tuple<string, SortOrder>> OrderBy { get; set; }
  130. public DateTime? MinDateCreated { get; set; }
  131. public DateTime? MinDateLastSaved { get; set; }
  132. public List<ItemFields> Fields { get; set; }
  133. public bool HasField(ItemFields name)
  134. {
  135. switch (name)
  136. {
  137. case ItemFields.Keywords:
  138. case ItemFields.Taglines:
  139. case ItemFields.ShortOverview:
  140. case ItemFields.CustomRating:
  141. case ItemFields.DateCreated:
  142. case ItemFields.SortName:
  143. case ItemFields.Overview:
  144. case ItemFields.OfficialRatingDescription:
  145. case ItemFields.HomePageUrl:
  146. case ItemFields.VoteCount:
  147. case ItemFields.DisplayMediaType:
  148. case ItemFields.ServiceName:
  149. case ItemFields.Genres:
  150. case ItemFields.Studios:
  151. case ItemFields.Settings:
  152. case ItemFields.OriginalTitle:
  153. case ItemFields.Tags:
  154. case ItemFields.DateLastMediaAdded:
  155. case ItemFields.CriticRatingSummary:
  156. return Fields.Count == 0 || Fields.Contains(name);
  157. default:
  158. return true;
  159. }
  160. }
  161. public InternalItemsQuery()
  162. {
  163. GroupByPresentationUniqueKey = true;
  164. EnableTotalRecordCount = true;
  165. Fields = new List<ItemFields>();
  166. AlbumNames = new string[] { };
  167. ArtistNames = new string[] { };
  168. ExcludeArtistIds = new string[] { };
  169. ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  170. BlockUnratedItems = new UnratedItem[] { };
  171. Tags = new string[] { };
  172. OfficialRatings = new string[] { };
  173. SortBy = new string[] { };
  174. MediaTypes = new string[] { };
  175. Keywords = new string[] { };
  176. IncludeItemTypes = new string[] { };
  177. ExcludeItemTypes = new string[] { };
  178. Genres = new string[] { };
  179. Studios = 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. LocationTypes = new LocationType[] { };
  195. ExcludeLocationTypes = new LocationType[] { };
  196. PresetViews = new string[] { };
  197. SourceTypes = new SourceType[] { };
  198. ExcludeSourceTypes = new SourceType[] { };
  199. TrailerTypes = new TrailerType[] { };
  200. AirDays = new DayOfWeek[] { };
  201. SeriesStatuses = new SeriesStatus[] { };
  202. OrderBy = new List<Tuple<string, SortOrder>>();
  203. }
  204. public InternalItemsQuery(User user)
  205. : this()
  206. {
  207. SetUser(user);
  208. }
  209. public void SetUser(User user)
  210. {
  211. if (user != null)
  212. {
  213. var policy = user.Policy;
  214. MaxParentalRating = policy.MaxParentalRating;
  215. if (policy.MaxParentalRating.HasValue)
  216. {
  217. BlockUnratedItems = policy.BlockUnratedItems;
  218. }
  219. ExcludeInheritedTags = policy.BlockedTags;
  220. User = user;
  221. }
  222. }
  223. }
  224. }