InternalItemsQuery.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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.ProductionLocations:
  138. case ItemFields.Keywords:
  139. case ItemFields.Taglines:
  140. case ItemFields.ShortOverview:
  141. case ItemFields.CustomRating:
  142. case ItemFields.DateCreated:
  143. case ItemFields.SortName:
  144. case ItemFields.Overview:
  145. case ItemFields.OfficialRatingDescription:
  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. case ItemFields.CriticRatingSummary:
  157. return Fields.Count == 0 || Fields.Contains(name);
  158. default:
  159. return true;
  160. }
  161. }
  162. public InternalItemsQuery()
  163. {
  164. GroupByPresentationUniqueKey = true;
  165. EnableTotalRecordCount = true;
  166. Fields = new List<ItemFields>();
  167. AlbumNames = new string[] { };
  168. ArtistNames = 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. Studios = new string[] { };
  181. StudioIds = new string[] { };
  182. GenreIds = new string[] { };
  183. ImageTypes = new ImageType[] { };
  184. VideoTypes = new VideoType[] { };
  185. Years = new int[] { };
  186. PersonTypes = new string[] { };
  187. PersonIds = new string[] { };
  188. ChannelIds = new string[] { };
  189. ItemIds = new string[] { };
  190. ExcludeItemIds = new string[] { };
  191. AncestorIds = new string[] { };
  192. TopParentIds = new string[] { };
  193. ExcludeTags = new string[] { };
  194. ExcludeInheritedTags = new string[] { };
  195. LocationTypes = new LocationType[] { };
  196. ExcludeLocationTypes = new LocationType[] { };
  197. PresetViews = new string[] { };
  198. SourceTypes = new SourceType[] { };
  199. ExcludeSourceTypes = new SourceType[] { };
  200. TrailerTypes = new TrailerType[] { };
  201. AirDays = new DayOfWeek[] { };
  202. SeriesStatuses = new SeriesStatus[] { };
  203. OrderBy = new List<Tuple<string, SortOrder>>();
  204. }
  205. public InternalItemsQuery(User user)
  206. : this()
  207. {
  208. SetUser(user);
  209. }
  210. public void SetUser(User user)
  211. {
  212. if (user != null)
  213. {
  214. var policy = user.Policy;
  215. MaxParentalRating = policy.MaxParentalRating;
  216. if (policy.MaxParentalRating.HasValue)
  217. {
  218. BlockUnratedItems = policy.BlockUnratedItems;
  219. }
  220. ExcludeInheritedTags = policy.BlockedTags;
  221. User = user;
  222. }
  223. }
  224. }
  225. }