InternalItemsQuery.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. #pragma warning disable CA1044, CA1819, CA2227, CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using Jellyfin.Data.Entities;
  6. using Jellyfin.Data.Enums;
  7. using MediaBrowser.Controller.Dto;
  8. using MediaBrowser.Model.Entities;
  9. namespace MediaBrowser.Controller.Entities
  10. {
  11. public class InternalItemsQuery
  12. {
  13. public InternalItemsQuery()
  14. {
  15. AlbumArtistIds = Array.Empty<Guid>();
  16. AlbumIds = Array.Empty<Guid>();
  17. AncestorIds = Array.Empty<Guid>();
  18. ArtistIds = Array.Empty<Guid>();
  19. BlockUnratedItems = Array.Empty<UnratedItem>();
  20. BoxSetLibraryFolders = Array.Empty<Guid>();
  21. ChannelIds = Array.Empty<Guid>();
  22. ContributingArtistIds = Array.Empty<Guid>();
  23. DtoOptions = new DtoOptions();
  24. EnableTotalRecordCount = true;
  25. ExcludeArtistIds = Array.Empty<Guid>();
  26. ExcludeInheritedTags = Array.Empty<string>();
  27. ExcludeItemIds = Array.Empty<Guid>();
  28. ExcludeItemTypes = Array.Empty<BaseItemKind>();
  29. ExcludeTags = Array.Empty<string>();
  30. GenreIds = Array.Empty<Guid>();
  31. Genres = Array.Empty<string>();
  32. GroupByPresentationUniqueKey = true;
  33. ImageTypes = Array.Empty<ImageType>();
  34. IncludeItemTypes = Array.Empty<BaseItemKind>();
  35. ItemIds = Array.Empty<Guid>();
  36. MediaTypes = Array.Empty<string>();
  37. MinSimilarityScore = 20;
  38. OfficialRatings = Array.Empty<string>();
  39. OrderBy = Array.Empty<(string, SortOrder)>();
  40. PersonIds = Array.Empty<Guid>();
  41. PersonTypes = Array.Empty<string>();
  42. PresetViews = Array.Empty<string>();
  43. SeriesStatuses = Array.Empty<SeriesStatus>();
  44. SourceTypes = Array.Empty<SourceType>();
  45. StudioIds = Array.Empty<Guid>();
  46. Tags = Array.Empty<string>();
  47. TopParentIds = Array.Empty<Guid>();
  48. TrailerTypes = Array.Empty<TrailerType>();
  49. VideoTypes = Array.Empty<VideoType>();
  50. Years = Array.Empty<int>();
  51. }
  52. public InternalItemsQuery(User? user)
  53. : this()
  54. {
  55. if (user != null)
  56. {
  57. SetUser(user);
  58. }
  59. }
  60. public bool Recursive { get; set; }
  61. public int? StartIndex { get; set; }
  62. public int? Limit { get; set; }
  63. public User? User { get; set; }
  64. public BaseItem? SimilarTo { get; set; }
  65. public bool? IsFolder { get; set; }
  66. public bool? IsFavorite { get; set; }
  67. public bool? IsFavoriteOrLiked { get; set; }
  68. public bool? IsLiked { get; set; }
  69. public bool? IsPlayed { get; set; }
  70. public bool? IsResumable { get; set; }
  71. public bool? IncludeItemsByName { get; set; }
  72. public string[] MediaTypes { get; set; }
  73. public BaseItemKind[] IncludeItemTypes { get; set; }
  74. public BaseItemKind[] ExcludeItemTypes { get; set; }
  75. public string[] ExcludeTags { get; set; }
  76. public string[] ExcludeInheritedTags { get; set; }
  77. public IReadOnlyList<string> Genres { get; set; }
  78. public bool? IsSpecialSeason { get; set; }
  79. public bool? IsMissing { get; set; }
  80. public bool? IsUnaired { get; set; }
  81. public bool? CollapseBoxSetItems { get; set; }
  82. public string? NameStartsWithOrGreater { get; set; }
  83. public string? NameStartsWith { get; set; }
  84. public string? NameLessThan { get; set; }
  85. public string? NameContains { get; set; }
  86. public string? MinSortName { get; set; }
  87. public string? PresentationUniqueKey { get; set; }
  88. public string? Path { get; set; }
  89. public string? Name { get; set; }
  90. public string? Person { get; set; }
  91. public Guid[] PersonIds { get; set; }
  92. public Guid[] ItemIds { get; set; }
  93. public Guid[] ExcludeItemIds { get; set; }
  94. public string? AdjacentTo { get; set; }
  95. public string[] PersonTypes { get; set; }
  96. public bool? Is3D { get; set; }
  97. public bool? IsHD { get; set; }
  98. public bool? IsLocked { get; set; }
  99. public bool? IsPlaceHolder { get; set; }
  100. public bool? HasImdbId { get; set; }
  101. public bool? HasOverview { get; set; }
  102. public bool? HasTmdbId { get; set; }
  103. public bool? HasOfficialRating { get; set; }
  104. public bool? HasTvdbId { get; set; }
  105. public bool? HasThemeSong { get; set; }
  106. public bool? HasThemeVideo { get; set; }
  107. public bool? HasSubtitles { get; set; }
  108. public bool? HasSpecialFeature { get; set; }
  109. public bool? HasTrailer { get; set; }
  110. public bool? HasParentalRating { get; set; }
  111. public Guid[] StudioIds { get; set; }
  112. public IReadOnlyList<Guid> GenreIds { get; set; }
  113. public ImageType[] ImageTypes { get; set; }
  114. public VideoType[] VideoTypes { get; set; }
  115. public UnratedItem[] BlockUnratedItems { get; set; }
  116. public int[] Years { get; set; }
  117. public string[] Tags { get; set; }
  118. public string[] OfficialRatings { get; set; }
  119. public DateTime? MinPremiereDate { get; set; }
  120. public DateTime? MaxPremiereDate { get; set; }
  121. public DateTime? MinStartDate { get; set; }
  122. public DateTime? MaxStartDate { get; set; }
  123. public DateTime? MinEndDate { get; set; }
  124. public DateTime? MaxEndDate { get; set; }
  125. public bool? IsAiring { get; set; }
  126. public bool? IsMovie { get; set; }
  127. public bool? IsSports { get; set; }
  128. public bool? IsKids { get; set; }
  129. public bool? IsNews { get; set; }
  130. public bool? IsSeries { get; set; }
  131. public int? MinIndexNumber { get; set; }
  132. public int? AiredDuringSeason { get; set; }
  133. public double? MinCriticRating { get; set; }
  134. public double? MinCommunityRating { get; set; }
  135. public IReadOnlyList<Guid> ChannelIds { get; set; }
  136. public int? ParentIndexNumber { get; set; }
  137. public int? ParentIndexNumberNotEquals { get; set; }
  138. public int? IndexNumber { get; set; }
  139. public int? MinParentalRating { get; set; }
  140. public int? MaxParentalRating { get; set; }
  141. public bool? HasDeadParentId { get; set; }
  142. public bool? IsVirtualItem { get; set; }
  143. public Guid ParentId { get; set; }
  144. public BaseItemKind? ParentType { get; set; }
  145. public Guid[] AncestorIds { get; set; }
  146. public Guid[] TopParentIds { get; set; }
  147. public string[] PresetViews { get; set; }
  148. public TrailerType[] TrailerTypes { get; set; }
  149. public SourceType[] SourceTypes { get; set; }
  150. public SeriesStatus[] SeriesStatuses { get; set; }
  151. public string? ExternalSeriesId { get; set; }
  152. public string? ExternalId { get; set; }
  153. public Guid[] AlbumIds { get; set; }
  154. public Guid[] ArtistIds { get; set; }
  155. public Guid[] ExcludeArtistIds { get; set; }
  156. public string? AncestorWithPresentationUniqueKey { get; set; }
  157. public string? SeriesPresentationUniqueKey { get; set; }
  158. public bool GroupByPresentationUniqueKey { get; set; }
  159. public bool GroupBySeriesPresentationUniqueKey { get; set; }
  160. public bool EnableTotalRecordCount { get; set; }
  161. public bool ForceDirect { get; set; }
  162. public Dictionary<string, string>? ExcludeProviderIds { get; set; }
  163. public bool EnableGroupByMetadataKey { get; set; }
  164. public bool? HasChapterImages { get; set; }
  165. public IReadOnlyList<(string OrderBy, SortOrder SortOrder)> OrderBy { get; set; }
  166. public DateTime? MinDateCreated { get; set; }
  167. public DateTime? MinDateLastSaved { get; set; }
  168. public DateTime? MinDateLastSavedForUser { get; set; }
  169. public DtoOptions DtoOptions { get; set; }
  170. public int MinSimilarityScore { get; set; }
  171. public string? HasNoAudioTrackWithLanguage { get; set; }
  172. public string? HasNoInternalSubtitleTrackWithLanguage { get; set; }
  173. public string? HasNoExternalSubtitleTrackWithLanguage { get; set; }
  174. public string? HasNoSubtitleTrackWithLanguage { get; set; }
  175. public bool? IsDeadArtist { get; set; }
  176. public bool? IsDeadStudio { get; set; }
  177. public bool? IsDeadPerson { get; set; }
  178. /// <summary>
  179. /// Gets or sets a value indicating whether album sub-folders should be returned if they exist.
  180. /// </summary>
  181. public bool? DisplayAlbumFolders { get; set; }
  182. public BaseItem? Parent
  183. {
  184. set
  185. {
  186. if (value == null)
  187. {
  188. ParentId = Guid.Empty;
  189. ParentType = null;
  190. }
  191. else
  192. {
  193. ParentId = value.Id;
  194. ParentType = value.GetBaseItemKind();
  195. }
  196. }
  197. }
  198. public Dictionary<string, string>? HasAnyProviderId { get; set; }
  199. public Guid[] AlbumArtistIds { get; set; }
  200. public Guid[] BoxSetLibraryFolders { get; set; }
  201. public Guid[] ContributingArtistIds { get; set; }
  202. public bool? HasAired { get; set; }
  203. public bool? HasOwnerId { get; set; }
  204. public bool? Is4K { get; set; }
  205. public int? MaxHeight { get; set; }
  206. public int? MaxWidth { get; set; }
  207. public int? MinHeight { get; set; }
  208. public int? MinWidth { get; set; }
  209. public string? SearchTerm { get; set; }
  210. public string? SeriesTimerId { get; set; }
  211. public void SetUser(User user)
  212. {
  213. MaxParentalRating = user.MaxParentalAgeRating;
  214. if (MaxParentalRating.HasValue)
  215. {
  216. string other = UnratedItem.Other.ToString();
  217. BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
  218. .Where(i => i != other)
  219. .Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
  220. }
  221. ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);
  222. User = user;
  223. }
  224. }
  225. }