InternalItemsQuery.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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[] Studios { get; set; }
  71. public string[] StudioIds { get; set; }
  72. public string[] GenreIds { get; set; }
  73. public ImageType[] ImageTypes { get; set; }
  74. public VideoType[] VideoTypes { get; set; }
  75. public UnratedItem[] BlockUnratedItems { get; set; }
  76. public int[] Years { get; set; }
  77. public string[] Tags { get; set; }
  78. public string[] OfficialRatings { get; set; }
  79. public DateTime? MinPremiereDate { get; set; }
  80. public DateTime? MaxPremiereDate { get; set; }
  81. public DateTime? MinStartDate { get; set; }
  82. public DateTime? MaxStartDate { get; set; }
  83. public DateTime? MinEndDate { get; set; }
  84. public DateTime? MaxEndDate { get; set; }
  85. public bool? IsAiring { get; set; }
  86. public bool? IsMovie { get; set; }
  87. public bool? IsSports { get; set; }
  88. public bool? IsKids { get; set; }
  89. public bool? IsNews { get; set; }
  90. public bool? IsSeries { get; set; }
  91. public int? MinPlayers { get; set; }
  92. public int? MaxPlayers { get; set; }
  93. public int? MinIndexNumber { get; set; }
  94. public int? AiredDuringSeason { get; set; }
  95. public double? MinCriticRating { get; set; }
  96. public double? MinCommunityRating { get; set; }
  97. public string[] ChannelIds { get; set; }
  98. internal List<Guid> ItemIdsFromPersonFilters { get; set; }
  99. public int? ParentIndexNumber { get; set; }
  100. public int? ParentIndexNumberNotEquals { get; set; }
  101. public int? IndexNumber { get; set; }
  102. public int? MinParentalRating { get; set; }
  103. public int? MaxParentalRating { get; set; }
  104. public bool? IsCurrentSchema { get; set; }
  105. public bool? HasDeadParentId { get; set; }
  106. public bool? IsOffline { get; set; }
  107. public bool? IsVirtualItem { get; set; }
  108. public Guid? ParentId { get; set; }
  109. public string[] AncestorIds { get; set; }
  110. public string[] TopParentIds { get; set; }
  111. public LocationType[] LocationTypes { get; set; }
  112. public LocationType[] ExcludeLocationTypes { get; set; }
  113. public string[] PresetViews { get; set; }
  114. public SourceType[] SourceTypes { get; set; }
  115. public SourceType[] ExcludeSourceTypes { get; set; }
  116. public TrailerType[] TrailerTypes { get; set; }
  117. public DayOfWeek[] AirDays { get; set; }
  118. public SeriesStatus[] SeriesStatuses { get; set; }
  119. public string AlbumArtistStartsWithOrGreater { get; set; }
  120. public string ExternalSeriesId { get; set; }
  121. public string[] AlbumNames { get; set; }
  122. public string[] ArtistNames { get; set; }
  123. public string[] ExcludeArtistIds { get; set; }
  124. public string AncestorWithPresentationUniqueKey { get; set; }
  125. public bool GroupByPresentationUniqueKey { get; set; }
  126. public bool EnableTotalRecordCount { get; set; }
  127. public bool ForceDirect { get; set; }
  128. public Dictionary<string, string> ExcludeProviderIds { get; set; }
  129. public bool EnableGroupByMetadataKey { get; set; }
  130. public List<Tuple<string, SortOrder>> OrderBy { get; set; }
  131. public DateTime? MinDateCreated { get; set; }
  132. public DateTime? MinDateLastSaved { get; set; }
  133. public DtoOptions DtoOptions { get; set; }
  134. public bool HasField(ItemFields name)
  135. {
  136. var fields = DtoOptions.Fields;
  137. switch (name)
  138. {
  139. case ItemFields.ProductionLocations:
  140. case ItemFields.Keywords:
  141. case ItemFields.Taglines:
  142. case ItemFields.ShortOverview:
  143. case ItemFields.CustomRating:
  144. case ItemFields.DateCreated:
  145. case ItemFields.SortName:
  146. case ItemFields.Overview:
  147. case ItemFields.OfficialRatingDescription:
  148. case ItemFields.HomePageUrl:
  149. case ItemFields.VoteCount:
  150. case ItemFields.DisplayMediaType:
  151. case ItemFields.ServiceName:
  152. case ItemFields.Genres:
  153. case ItemFields.Studios:
  154. case ItemFields.Settings:
  155. case ItemFields.OriginalTitle:
  156. case ItemFields.Tags:
  157. case ItemFields.DateLastMediaAdded:
  158. case ItemFields.CriticRatingSummary:
  159. return fields.Count == 0 || fields.Contains(name);
  160. default:
  161. return true;
  162. }
  163. }
  164. public InternalItemsQuery()
  165. {
  166. GroupByPresentationUniqueKey = true;
  167. EnableTotalRecordCount = true;
  168. DtoOptions = new DtoOptions();
  169. AlbumNames = new string[] { };
  170. ArtistNames = new string[] { };
  171. ExcludeArtistIds = new string[] { };
  172. ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  173. BlockUnratedItems = new UnratedItem[] { };
  174. Tags = new string[] { };
  175. OfficialRatings = new string[] { };
  176. SortBy = new string[] { };
  177. MediaTypes = new string[] { };
  178. Keywords = new string[] { };
  179. IncludeItemTypes = new string[] { };
  180. ExcludeItemTypes = new string[] { };
  181. Genres = new string[] { };
  182. Studios = new string[] { };
  183. StudioIds = new string[] { };
  184. GenreIds = new string[] { };
  185. ImageTypes = new ImageType[] { };
  186. VideoTypes = new VideoType[] { };
  187. Years = new int[] { };
  188. PersonTypes = new string[] { };
  189. PersonIds = new string[] { };
  190. ChannelIds = new string[] { };
  191. ItemIds = new string[] { };
  192. ExcludeItemIds = new string[] { };
  193. AncestorIds = new string[] { };
  194. TopParentIds = new string[] { };
  195. ExcludeTags = new string[] { };
  196. ExcludeInheritedTags = new string[] { };
  197. LocationTypes = new LocationType[] { };
  198. ExcludeLocationTypes = new LocationType[] { };
  199. PresetViews = new string[] { };
  200. SourceTypes = new SourceType[] { };
  201. ExcludeSourceTypes = new SourceType[] { };
  202. TrailerTypes = new TrailerType[] { };
  203. AirDays = new DayOfWeek[] { };
  204. SeriesStatuses = new SeriesStatus[] { };
  205. OrderBy = new List<Tuple<string, SortOrder>>();
  206. }
  207. public InternalItemsQuery(User user)
  208. : this()
  209. {
  210. SetUser(user);
  211. }
  212. public void SetUser(User user)
  213. {
  214. if (user != null)
  215. {
  216. var policy = user.Policy;
  217. MaxParentalRating = policy.MaxParentalRating;
  218. if (policy.MaxParentalRating.HasValue)
  219. {
  220. BlockUnratedItems = policy.BlockUnratedItems;
  221. }
  222. ExcludeInheritedTags = policy.BlockedTags;
  223. User = user;
  224. }
  225. }
  226. }
  227. }