|  |  | 1 |  | #pragma warning disable CA1044, CA1819, CA2227, CS1591 | 
|  |  | 2 |  |  | 
|  |  | 3 |  | using System; | 
|  |  | 4 |  | using System.Collections.Generic; | 
|  |  | 5 |  | using System.Linq; | 
|  |  | 6 |  | using Diacritics.Extensions; | 
|  |  | 7 |  | using Jellyfin.Data; | 
|  |  | 8 |  | using Jellyfin.Data.Enums; | 
|  |  | 9 |  | using Jellyfin.Database.Implementations.Entities; | 
|  |  | 10 |  | using Jellyfin.Database.Implementations.Enums; | 
|  |  | 11 |  | using MediaBrowser.Controller.Dto; | 
|  |  | 12 |  | using MediaBrowser.Model.Entities; | 
|  |  | 13 |  |  | 
|  |  | 14 |  | namespace MediaBrowser.Controller.Entities | 
|  |  | 15 |  | { | 
|  |  | 16 |  |     public class InternalItemsQuery | 
|  |  | 17 |  |     { | 
|  |  | 18 |  |         public InternalItemsQuery() | 
|  |  | 19 |  |         { | 
|  | 421 | 20 |  |             AlbumArtistIds = Array.Empty<Guid>(); | 
|  | 421 | 21 |  |             AlbumIds = Array.Empty<Guid>(); | 
|  | 421 | 22 |  |             AncestorIds = Array.Empty<Guid>(); | 
|  | 421 | 23 |  |             ArtistIds = Array.Empty<Guid>(); | 
|  | 421 | 24 |  |             BlockUnratedItems = Array.Empty<UnratedItem>(); | 
|  | 421 | 25 |  |             BoxSetLibraryFolders = Array.Empty<Guid>(); | 
|  | 421 | 26 |  |             ChannelIds = Array.Empty<Guid>(); | 
|  | 421 | 27 |  |             ContributingArtistIds = Array.Empty<Guid>(); | 
|  | 421 | 28 |  |             DtoOptions = new DtoOptions(); | 
|  | 421 | 29 |  |             EnableTotalRecordCount = true; | 
|  | 421 | 30 |  |             ExcludeArtistIds = Array.Empty<Guid>(); | 
|  | 421 | 31 |  |             ExcludeInheritedTags = Array.Empty<string>(); | 
|  | 421 | 32 |  |             IncludeInheritedTags = Array.Empty<string>(); | 
|  | 421 | 33 |  |             ExcludeItemIds = Array.Empty<Guid>(); | 
|  | 421 | 34 |  |             ExcludeItemTypes = Array.Empty<BaseItemKind>(); | 
|  | 421 | 35 |  |             ExcludeTags = Array.Empty<string>(); | 
|  | 421 | 36 |  |             GenreIds = Array.Empty<Guid>(); | 
|  | 421 | 37 |  |             Genres = Array.Empty<string>(); | 
|  | 421 | 38 |  |             GroupByPresentationUniqueKey = true; | 
|  | 421 | 39 |  |             ImageTypes = Array.Empty<ImageType>(); | 
|  | 421 | 40 |  |             IncludeItemTypes = Array.Empty<BaseItemKind>(); | 
|  | 421 | 41 |  |             ItemIds = Array.Empty<Guid>(); | 
|  | 421 | 42 |  |             MediaTypes = Array.Empty<MediaType>(); | 
|  | 421 | 43 |  |             OfficialRatings = Array.Empty<string>(); | 
|  | 421 | 44 |  |             OrderBy = Array.Empty<(ItemSortBy, SortOrder)>(); | 
|  | 421 | 45 |  |             PersonIds = Array.Empty<Guid>(); | 
|  | 421 | 46 |  |             PersonTypes = Array.Empty<string>(); | 
|  | 421 | 47 |  |             PresetViews = Array.Empty<CollectionType?>(); | 
|  | 421 | 48 |  |             SeriesStatuses = Array.Empty<SeriesStatus>(); | 
|  | 421 | 49 |  |             SourceTypes = Array.Empty<SourceType>(); | 
|  | 421 | 50 |  |             StudioIds = Array.Empty<Guid>(); | 
|  | 421 | 51 |  |             Tags = Array.Empty<string>(); | 
|  | 421 | 52 |  |             TopParentIds = Array.Empty<Guid>(); | 
|  | 421 | 53 |  |             TrailerTypes = Array.Empty<TrailerType>(); | 
|  | 421 | 54 |  |             VideoTypes = Array.Empty<VideoType>(); | 
|  | 421 | 55 |  |             Years = Array.Empty<int>(); | 
|  | 421 | 56 |  |             SkipDeserialization = false; | 
|  | 421 | 57 |  |         } | 
|  |  | 58 |  |  | 
|  |  | 59 |  |         public InternalItemsQuery(User? user) | 
|  | 2 | 60 |  |             : this() | 
|  |  | 61 |  |         { | 
|  | 2 | 62 |  |             if (user is not null) | 
|  |  | 63 |  |             { | 
|  | 2 | 64 |  |                 SetUser(user); | 
|  |  | 65 |  |             } | 
|  | 2 | 66 |  |         } | 
|  |  | 67 |  |  | 
|  |  | 68 |  |         public bool Recursive { get; set; } | 
|  |  | 69 |  |  | 
|  |  | 70 |  |         public int? StartIndex { get; set; } | 
|  |  | 71 |  |  | 
|  |  | 72 |  |         public int? Limit { get; set; } | 
|  |  | 73 |  |  | 
|  |  | 74 |  |         public User? User { get; set; } | 
|  |  | 75 |  |  | 
|  |  | 76 |  |         public bool? IsFolder { get; set; } | 
|  |  | 77 |  |  | 
|  |  | 78 |  |         public bool? IsFavorite { get; set; } | 
|  |  | 79 |  |  | 
|  |  | 80 |  |         public bool? IsFavoriteOrLiked { get; set; } | 
|  |  | 81 |  |  | 
|  |  | 82 |  |         public bool? IsLiked { get; set; } | 
|  |  | 83 |  |  | 
|  |  | 84 |  |         public bool? IsPlayed { get; set; } | 
|  |  | 85 |  |  | 
|  |  | 86 |  |         public bool? IsResumable { get; set; } | 
|  |  | 87 |  |  | 
|  |  | 88 |  |         public bool? IncludeItemsByName { get; set; } | 
|  |  | 89 |  |  | 
|  |  | 90 |  |         public MediaType[] MediaTypes { get; set; } | 
|  |  | 91 |  |  | 
|  |  | 92 |  |         public BaseItemKind[] IncludeItemTypes { get; set; } | 
|  |  | 93 |  |  | 
|  |  | 94 |  |         public BaseItemKind[] ExcludeItemTypes { get; set; } | 
|  |  | 95 |  |  | 
|  |  | 96 |  |         public string[] ExcludeTags { get; set; } | 
|  |  | 97 |  |  | 
|  |  | 98 |  |         public string[] ExcludeInheritedTags { get; set; } | 
|  |  | 99 |  |  | 
|  |  | 100 |  |         public string[] IncludeInheritedTags { get; set; } | 
|  |  | 101 |  |  | 
|  |  | 102 |  |         public IReadOnlyList<string> Genres { get; set; } | 
|  |  | 103 |  |  | 
|  |  | 104 |  |         public bool? IsSpecialSeason { get; set; } | 
|  |  | 105 |  |  | 
|  |  | 106 |  |         public bool? IsMissing { get; set; } | 
|  |  | 107 |  |  | 
|  |  | 108 |  |         public bool? IsUnaired { get; set; } | 
|  |  | 109 |  |  | 
|  |  | 110 |  |         public bool? CollapseBoxSetItems { get; set; } | 
|  |  | 111 |  |  | 
|  |  | 112 |  |         public string? NameStartsWithOrGreater { get; set; } | 
|  |  | 113 |  |  | 
|  |  | 114 |  |         public string? NameStartsWith { get; set; } | 
|  |  | 115 |  |  | 
|  |  | 116 |  |         public string? NameLessThan { get; set; } | 
|  |  | 117 |  |  | 
|  |  | 118 |  |         public string? NameContains { get; set; } | 
|  |  | 119 |  |  | 
|  |  | 120 |  |         public string? MinSortName { get; set; } | 
|  |  | 121 |  |  | 
|  |  | 122 |  |         public string? PresentationUniqueKey { get; set; } | 
|  |  | 123 |  |  | 
|  |  | 124 |  |         public string? Path { get; set; } | 
|  |  | 125 |  |  | 
|  |  | 126 |  |         public string? Name { get; set; } | 
|  |  | 127 |  |  | 
|  |  | 128 |  |         public string? Person { get; set; } | 
|  |  | 129 |  |  | 
|  |  | 130 |  |         public Guid[] PersonIds { get; set; } | 
|  |  | 131 |  |  | 
|  |  | 132 |  |         public Guid[] ItemIds { get; set; } | 
|  |  | 133 |  |  | 
|  |  | 134 |  |         public Guid[] ExcludeItemIds { get; set; } | 
|  |  | 135 |  |  | 
|  |  | 136 |  |         public Guid? AdjacentTo { get; set; } | 
|  |  | 137 |  |  | 
|  |  | 138 |  |         public string[] PersonTypes { get; set; } | 
|  |  | 139 |  |  | 
|  |  | 140 |  |         public bool? Is3D { get; set; } | 
|  |  | 141 |  |  | 
|  |  | 142 |  |         public bool? IsHD { get; set; } | 
|  |  | 143 |  |  | 
|  |  | 144 |  |         public bool? IsLocked { get; set; } | 
|  |  | 145 |  |  | 
|  |  | 146 |  |         public bool? IsPlaceHolder { get; set; } | 
|  |  | 147 |  |  | 
|  |  | 148 |  |         public bool? HasImdbId { get; set; } | 
|  |  | 149 |  |  | 
|  |  | 150 |  |         public bool? HasOverview { get; set; } | 
|  |  | 151 |  |  | 
|  |  | 152 |  |         public bool? HasTmdbId { get; set; } | 
|  |  | 153 |  |  | 
|  |  | 154 |  |         public bool? HasOfficialRating { get; set; } | 
|  |  | 155 |  |  | 
|  |  | 156 |  |         public bool? HasTvdbId { get; set; } | 
|  |  | 157 |  |  | 
|  |  | 158 |  |         public bool? HasThemeSong { get; set; } | 
|  |  | 159 |  |  | 
|  |  | 160 |  |         public bool? HasThemeVideo { get; set; } | 
|  |  | 161 |  |  | 
|  |  | 162 |  |         public bool? HasSubtitles { get; set; } | 
|  |  | 163 |  |  | 
|  |  | 164 |  |         public bool? HasSpecialFeature { get; set; } | 
|  |  | 165 |  |  | 
|  |  | 166 |  |         public bool? HasTrailer { get; set; } | 
|  |  | 167 |  |  | 
|  |  | 168 |  |         public bool? HasParentalRating { get; set; } | 
|  |  | 169 |  |  | 
|  |  | 170 |  |         public Guid[] StudioIds { get; set; } | 
|  |  | 171 |  |  | 
|  |  | 172 |  |         public IReadOnlyList<Guid> GenreIds { get; set; } | 
|  |  | 173 |  |  | 
|  |  | 174 |  |         public ImageType[] ImageTypes { get; set; } | 
|  |  | 175 |  |  | 
|  |  | 176 |  |         public VideoType[] VideoTypes { get; set; } | 
|  |  | 177 |  |  | 
|  |  | 178 |  |         public UnratedItem[] BlockUnratedItems { get; set; } | 
|  |  | 179 |  |  | 
|  |  | 180 |  |         public int[] Years { get; set; } | 
|  |  | 181 |  |  | 
|  |  | 182 |  |         public string[] Tags { get; set; } | 
|  |  | 183 |  |  | 
|  |  | 184 |  |         public string[] OfficialRatings { get; set; } | 
|  |  | 185 |  |  | 
|  |  | 186 |  |         public DateTime? MinPremiereDate { get; set; } | 
|  |  | 187 |  |  | 
|  |  | 188 |  |         public DateTime? MaxPremiereDate { get; set; } | 
|  |  | 189 |  |  | 
|  |  | 190 |  |         public DateTime? MinStartDate { get; set; } | 
|  |  | 191 |  |  | 
|  |  | 192 |  |         public DateTime? MaxStartDate { get; set; } | 
|  |  | 193 |  |  | 
|  |  | 194 |  |         public DateTime? MinEndDate { get; set; } | 
|  |  | 195 |  |  | 
|  |  | 196 |  |         public DateTime? MaxEndDate { get; set; } | 
|  |  | 197 |  |  | 
|  |  | 198 |  |         public bool? IsAiring { get; set; } | 
|  |  | 199 |  |  | 
|  |  | 200 |  |         public bool? IsMovie { get; set; } | 
|  |  | 201 |  |  | 
|  |  | 202 |  |         public bool? IsSports { get; set; } | 
|  |  | 203 |  |  | 
|  |  | 204 |  |         public bool? IsKids { get; set; } | 
|  |  | 205 |  |  | 
|  |  | 206 |  |         public bool? IsNews { get; set; } | 
|  |  | 207 |  |  | 
|  |  | 208 |  |         public bool? IsSeries { get; set; } | 
|  |  | 209 |  |  | 
|  |  | 210 |  |         public int? MinIndexNumber { get; set; } | 
|  |  | 211 |  |  | 
|  |  | 212 |  |         /// <summary> | 
|  |  | 213 |  |         /// Gets or sets the minimum ParentIndexNumber and IndexNumber. | 
|  |  | 214 |  |         /// </summary> | 
|  |  | 215 |  |         /// <remarks> | 
|  |  | 216 |  |         /// It produces this where clause: | 
|  |  | 217 |  |         /// <para>(ParentIndexNumber = X and IndexNumber >= Y) or ParentIndexNumber > X. | 
|  |  | 218 |  |         /// </para> | 
|  |  | 219 |  |         /// </remarks> | 
|  |  | 220 |  |         public (int ParentIndexNumber, int IndexNumber)? MinParentAndIndexNumber { get; set; } | 
|  |  | 221 |  |  | 
|  |  | 222 |  |         public int? AiredDuringSeason { get; set; } | 
|  |  | 223 |  |  | 
|  |  | 224 |  |         public double? MinCriticRating { get; set; } | 
|  |  | 225 |  |  | 
|  |  | 226 |  |         public double? MinCommunityRating { get; set; } | 
|  |  | 227 |  |  | 
|  |  | 228 |  |         public IReadOnlyList<Guid> ChannelIds { get; set; } | 
|  |  | 229 |  |  | 
|  |  | 230 |  |         public int? ParentIndexNumber { get; set; } | 
|  |  | 231 |  |  | 
|  |  | 232 |  |         public int? ParentIndexNumberNotEquals { get; set; } | 
|  |  | 233 |  |  | 
|  |  | 234 |  |         public int? IndexNumber { get; set; } | 
|  |  | 235 |  |  | 
|  |  | 236 |  |         public ParentalRatingScore? MinParentalRating { get; set; } | 
|  |  | 237 |  |  | 
|  |  | 238 |  |         public ParentalRatingScore? MaxParentalRating { get; set; } | 
|  |  | 239 |  |  | 
|  |  | 240 |  |         public bool? HasDeadParentId { get; set; } | 
|  |  | 241 |  |  | 
|  |  | 242 |  |         public bool? IsVirtualItem { get; set; } | 
|  |  | 243 |  |  | 
|  |  | 244 |  |         public Guid ParentId { get; set; } | 
|  |  | 245 |  |  | 
|  |  | 246 |  |         public BaseItemKind? ParentType { get; set; } | 
|  |  | 247 |  |  | 
|  |  | 248 |  |         public Guid[] AncestorIds { get; set; } | 
|  |  | 249 |  |  | 
|  |  | 250 |  |         public Guid[] TopParentIds { get; set; } | 
|  |  | 251 |  |  | 
|  |  | 252 |  |         public CollectionType?[] PresetViews { get; set; } | 
|  |  | 253 |  |  | 
|  |  | 254 |  |         public TrailerType[] TrailerTypes { get; set; } | 
|  |  | 255 |  |  | 
|  |  | 256 |  |         public SourceType[] SourceTypes { get; set; } | 
|  |  | 257 |  |  | 
|  |  | 258 |  |         public SeriesStatus[] SeriesStatuses { get; set; } | 
|  |  | 259 |  |  | 
|  |  | 260 |  |         public string? ExternalSeriesId { get; set; } | 
|  |  | 261 |  |  | 
|  |  | 262 |  |         public string? ExternalId { get; set; } | 
|  |  | 263 |  |  | 
|  |  | 264 |  |         public Guid[] AlbumIds { get; set; } | 
|  |  | 265 |  |  | 
|  |  | 266 |  |         public Guid[] ArtistIds { get; set; } | 
|  |  | 267 |  |  | 
|  |  | 268 |  |         public Guid[] ExcludeArtistIds { get; set; } | 
|  |  | 269 |  |  | 
|  |  | 270 |  |         public string? AncestorWithPresentationUniqueKey { get; set; } | 
|  |  | 271 |  |  | 
|  |  | 272 |  |         public string? SeriesPresentationUniqueKey { get; set; } | 
|  |  | 273 |  |  | 
|  |  | 274 |  |         public bool GroupByPresentationUniqueKey { get; set; } | 
|  |  | 275 |  |  | 
|  |  | 276 |  |         public bool GroupBySeriesPresentationUniqueKey { get; set; } | 
|  |  | 277 |  |  | 
|  |  | 278 |  |         public bool EnableTotalRecordCount { get; set; } | 
|  |  | 279 |  |  | 
|  |  | 280 |  |         public bool ForceDirect { get; set; } | 
|  |  | 281 |  |  | 
|  |  | 282 |  |         public Dictionary<string, string>? ExcludeProviderIds { get; set; } | 
|  |  | 283 |  |  | 
|  |  | 284 |  |         public bool EnableGroupByMetadataKey { get; set; } | 
|  |  | 285 |  |  | 
|  |  | 286 |  |         public bool? HasChapterImages { get; set; } | 
|  |  | 287 |  |  | 
|  |  | 288 |  |         public IReadOnlyList<(ItemSortBy OrderBy, SortOrder SortOrder)> OrderBy { get; set; } | 
|  |  | 289 |  |  | 
|  |  | 290 |  |         public DateTime? MinDateCreated { get; set; } | 
|  |  | 291 |  |  | 
|  |  | 292 |  |         public DateTime? MinDateLastSaved { get; set; } | 
|  |  | 293 |  |  | 
|  |  | 294 |  |         public DateTime? MinDateLastSavedForUser { get; set; } | 
|  |  | 295 |  |  | 
|  |  | 296 |  |         public DtoOptions DtoOptions { get; set; } | 
|  |  | 297 |  |  | 
|  |  | 298 |  |         public string? HasNoAudioTrackWithLanguage { get; set; } | 
|  |  | 299 |  |  | 
|  |  | 300 |  |         public string? HasNoInternalSubtitleTrackWithLanguage { get; set; } | 
|  |  | 301 |  |  | 
|  |  | 302 |  |         public string? HasNoExternalSubtitleTrackWithLanguage { get; set; } | 
|  |  | 303 |  |  | 
|  |  | 304 |  |         public string? HasNoSubtitleTrackWithLanguage { get; set; } | 
|  |  | 305 |  |  | 
|  |  | 306 |  |         public bool? IsDeadArtist { get; set; } | 
|  |  | 307 |  |  | 
|  |  | 308 |  |         public bool? IsDeadStudio { get; set; } | 
|  |  | 309 |  |  | 
|  |  | 310 |  |         public bool? IsDeadGenre { get; set; } | 
|  |  | 311 |  |  | 
|  |  | 312 |  |         public bool? IsDeadPerson { get; set; } | 
|  |  | 313 |  |  | 
|  |  | 314 |  |         /// <summary> | 
|  |  | 315 |  |         /// Gets or sets a value indicating whether album sub-folders should be returned if they exist. | 
|  |  | 316 |  |         /// </summary> | 
|  |  | 317 |  |         public bool? DisplayAlbumFolders { get; set; } | 
|  |  | 318 |  |  | 
|  |  | 319 |  |         public BaseItem? Parent | 
|  |  | 320 |  |         { | 
|  |  | 321 |  |             set | 
|  |  | 322 |  |             { | 
|  | 235 | 323 |  |                 if (value is null) | 
|  |  | 324 |  |                 { | 
|  | 56 | 325 |  |                     ParentId = Guid.Empty; | 
|  | 56 | 326 |  |                     ParentType = null; | 
|  |  | 327 |  |                 } | 
|  |  | 328 |  |                 else | 
|  |  | 329 |  |                 { | 
|  | 179 | 330 |  |                     ParentId = value.Id; | 
|  | 179 | 331 |  |                     ParentType = value.GetBaseItemKind(); | 
|  |  | 332 |  |                 } | 
|  | 179 | 333 |  |             } | 
|  |  | 334 |  |         } | 
|  |  | 335 |  |  | 
|  |  | 336 |  |         public Dictionary<string, string>? HasAnyProviderId { get; set; } | 
|  |  | 337 |  |  | 
|  |  | 338 |  |         public Guid[] AlbumArtistIds { get; set; } | 
|  |  | 339 |  |  | 
|  |  | 340 |  |         public Guid[] BoxSetLibraryFolders { get; set; } | 
|  |  | 341 |  |  | 
|  |  | 342 |  |         public Guid[] ContributingArtistIds { get; set; } | 
|  |  | 343 |  |  | 
|  |  | 344 |  |         public bool? HasAired { get; set; } | 
|  |  | 345 |  |  | 
|  |  | 346 |  |         public bool? HasOwnerId { get; set; } | 
|  |  | 347 |  |  | 
|  |  | 348 |  |         public bool? Is4K { get; set; } | 
|  |  | 349 |  |  | 
|  |  | 350 |  |         public int? MaxHeight { get; set; } | 
|  |  | 351 |  |  | 
|  |  | 352 |  |         public int? MaxWidth { get; set; } | 
|  |  | 353 |  |  | 
|  |  | 354 |  |         public int? MinHeight { get; set; } | 
|  |  | 355 |  |  | 
|  |  | 356 |  |         public int? MinWidth { get; set; } | 
|  |  | 357 |  |  | 
|  |  | 358 |  |         public string? SearchTerm { get; set; } | 
|  |  | 359 |  |  | 
|  |  | 360 |  |         public string? SeriesTimerId { get; set; } | 
|  |  | 361 |  |  | 
|  |  | 362 |  |         public bool SkipDeserialization { get; set; } | 
|  |  | 363 |  |  | 
|  |  | 364 |  |         public void SetUser(User user) | 
|  |  | 365 |  |         { | 
|  | 2 | 366 |  |             var maxRating = user.MaxParentalRatingScore; | 
|  | 2 | 367 |  |             if (maxRating.HasValue) | 
|  |  | 368 |  |             { | 
|  | 0 | 369 |  |                 MaxParentalRating = new(maxRating.Value, user.MaxParentalRatingSubScore); | 
|  |  | 370 |  |             } | 
|  |  | 371 |  |  | 
|  | 2 | 372 |  |             var other = UnratedItem.Other.ToString(); | 
|  | 2 | 373 |  |             BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems) | 
|  | 2 | 374 |  |                 .Where(i => i != other) | 
|  | 2 | 375 |  |                 .Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray(); | 
|  |  | 376 |  |  | 
|  | 2 | 377 |  |             ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags) | 
|  | 2 | 378 |  |                 .Where(tag => !string.IsNullOrWhiteSpace(tag)) | 
|  | 2 | 379 |  |                 .Select(tag => tag.RemoveDiacritics().ToLowerInvariant()) | 
|  | 2 | 380 |  |                 .ToArray(); | 
|  |  | 381 |  |  | 
|  | 2 | 382 |  |             IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags) | 
|  | 2 | 383 |  |                 .Where(tag => !string.IsNullOrWhiteSpace(tag)) | 
|  | 2 | 384 |  |                 .Select(tag => tag.RemoveDiacritics().ToLowerInvariant()) | 
|  | 2 | 385 |  |                 .ToArray(); | 
|  |  | 386 |  |  | 
|  | 2 | 387 |  |             User = user; | 
|  | 2 | 388 |  |         } | 
|  |  | 389 |  |     } | 
|  |  | 390 |  | } |