| | | 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 | | using MediaBrowser.Model.Querying; |
| | | 14 | | |
| | | 15 | | namespace MediaBrowser.Controller.Entities |
| | | 16 | | { |
| | | 17 | | public class InternalItemsQuery |
| | | 18 | | { |
| | | 19 | | public InternalItemsQuery() |
| | | 20 | | { |
| | 572 | 21 | | AlbumArtistIds = []; |
| | 572 | 22 | | AlbumIds = []; |
| | 572 | 23 | | AncestorIds = []; |
| | 572 | 24 | | LinkedChildAncestorIds = []; |
| | 572 | 25 | | ArtistIds = []; |
| | 572 | 26 | | BlockUnratedItems = []; |
| | 572 | 27 | | BoxSetLibraryFolders = []; |
| | 572 | 28 | | ChannelIds = []; |
| | 572 | 29 | | ContributingArtistIds = []; |
| | 572 | 30 | | DtoOptions = new DtoOptions(); |
| | 572 | 31 | | EnableTotalRecordCount = true; |
| | 572 | 32 | | ExcludeArtistIds = []; |
| | 572 | 33 | | ExcludeInheritedTags = []; |
| | 572 | 34 | | IncludeInheritedTags = []; |
| | 572 | 35 | | ExcludeItemIds = []; |
| | 572 | 36 | | ExcludeItemTypes = []; |
| | 572 | 37 | | ExcludeTags = []; |
| | 572 | 38 | | GenreIds = []; |
| | 572 | 39 | | Genres = []; |
| | 572 | 40 | | GroupByPresentationUniqueKey = true; |
| | 572 | 41 | | ImageTypes = []; |
| | 572 | 42 | | IncludeItemTypes = []; |
| | 572 | 43 | | ItemIds = []; |
| | 572 | 44 | | OwnerIds = []; |
| | 572 | 45 | | ExtraTypes = []; |
| | 572 | 46 | | MediaTypes = []; |
| | 572 | 47 | | OfficialRatings = []; |
| | 572 | 48 | | OrderBy = []; |
| | 572 | 49 | | OwnerIds = []; |
| | 572 | 50 | | PersonIds = []; |
| | 572 | 51 | | PersonTypes = []; |
| | 572 | 52 | | PresetViews = []; |
| | 572 | 53 | | SeriesStatuses = []; |
| | 572 | 54 | | SourceTypes = []; |
| | 572 | 55 | | StudioIds = []; |
| | 572 | 56 | | Tags = []; |
| | 572 | 57 | | TopParentIds = []; |
| | 572 | 58 | | TrailerTypes = []; |
| | 572 | 59 | | VideoTypes = []; |
| | 572 | 60 | | Years = []; |
| | 572 | 61 | | SkipDeserialization = false; |
| | 572 | 62 | | AudioLanguages = []; |
| | 572 | 63 | | SubtitleLanguages = []; |
| | 572 | 64 | | } |
| | | 65 | | |
| | | 66 | | public InternalItemsQuery(User? user) |
| | 11 | 67 | | : this() |
| | | 68 | | { |
| | 11 | 69 | | if (user is not null) |
| | | 70 | | { |
| | 5 | 71 | | SetUser(user); |
| | | 72 | | } |
| | 11 | 73 | | } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Gets a value indicating whether the query carries any criteria that narrows the |
| | | 77 | | /// result set, as opposed to user context, pagination, sorting or DTO options. |
| | | 78 | | /// </summary> |
| | | 79 | | public bool HasFilters => |
| | 3 | 80 | | IncludeItemTypes.Length > 0 |
| | 3 | 81 | | || ExcludeItemTypes.Length > 0 |
| | 3 | 82 | | || Genres.Count > 0 |
| | 3 | 83 | | || GenreIds.Count > 0 |
| | 3 | 84 | | || Years.Length > 0 |
| | 3 | 85 | | || Tags.Length > 0 |
| | 3 | 86 | | || ExcludeTags.Length > 0 |
| | 3 | 87 | | || OfficialRatings.Length > 0 |
| | 3 | 88 | | || StudioIds.Length > 0 |
| | 3 | 89 | | || ArtistIds.Length > 0 |
| | 3 | 90 | | || AlbumArtistIds.Length > 0 |
| | 3 | 91 | | || ContributingArtistIds.Length > 0 |
| | 3 | 92 | | || ExcludeArtistIds.Length > 0 |
| | 3 | 93 | | || AlbumIds.Length > 0 |
| | 3 | 94 | | || PersonIds.Length > 0 |
| | 3 | 95 | | || PersonTypes.Length > 0 |
| | 3 | 96 | | || MediaTypes.Length > 0 |
| | 3 | 97 | | || VideoTypes.Length > 0 |
| | 3 | 98 | | || ImageTypes.Length > 0 |
| | 3 | 99 | | || SeriesStatuses.Length > 0 |
| | 3 | 100 | | || ItemIds.Length > 0 |
| | 3 | 101 | | || ExcludeItemIds.Length > 0 |
| | 3 | 102 | | || AudioLanguages.Count > 0 |
| | 3 | 103 | | || SubtitleLanguages.Count > 0 |
| | 3 | 104 | | || LinkedChildAncestorIds.Length > 0 |
| | 3 | 105 | | || AncestorIds.Length > 0 |
| | 3 | 106 | | || IsFavorite.HasValue |
| | 3 | 107 | | || IsFavoriteOrLiked.HasValue |
| | 3 | 108 | | || IsLiked.HasValue |
| | 3 | 109 | | || IsPlayed.HasValue |
| | 3 | 110 | | || IsResumable.HasValue |
| | 3 | 111 | | || IsFolder.HasValue |
| | 3 | 112 | | || IsMissing.HasValue |
| | 3 | 113 | | || IsUnaired.HasValue |
| | 3 | 114 | | || IsSpecialSeason.HasValue |
| | 3 | 115 | | || Is3D.HasValue |
| | 3 | 116 | | || IsHD.HasValue |
| | 3 | 117 | | || Is4K.HasValue |
| | 3 | 118 | | || IsLocked.HasValue |
| | 3 | 119 | | || IsPlaceHolder.HasValue |
| | 3 | 120 | | || IsMovie.HasValue |
| | 3 | 121 | | || IsSports.HasValue |
| | 3 | 122 | | || IsKids.HasValue |
| | 3 | 123 | | || IsNews.HasValue |
| | 3 | 124 | | || IsSeries.HasValue |
| | 3 | 125 | | || IsAiring.HasValue |
| | 3 | 126 | | || IsVirtualItem.HasValue |
| | 3 | 127 | | || HasImdbId.HasValue |
| | 3 | 128 | | || HasTmdbId.HasValue |
| | 3 | 129 | | || HasTvdbId.HasValue |
| | 3 | 130 | | || HasOverview.HasValue |
| | 3 | 131 | | || HasOfficialRating.HasValue |
| | 3 | 132 | | || HasParentalRating.HasValue |
| | 3 | 133 | | || HasThemeSong.HasValue |
| | 3 | 134 | | || HasThemeVideo.HasValue |
| | 3 | 135 | | || HasSubtitles.HasValue |
| | 3 | 136 | | || HasSpecialFeature.HasValue |
| | 3 | 137 | | || HasTrailer.HasValue |
| | 3 | 138 | | || HasChapterImages.HasValue |
| | 3 | 139 | | || MinCriticRating.HasValue |
| | 3 | 140 | | || MinCommunityRating.HasValue |
| | 3 | 141 | | || MinParentalRating is not null |
| | 3 | 142 | | || MinIndexNumber.HasValue |
| | 3 | 143 | | || MinParentAndIndexNumber.HasValue |
| | 3 | 144 | | || IndexNumber.HasValue |
| | 3 | 145 | | || ParentIndexNumber.HasValue |
| | 3 | 146 | | || AiredDuringSeason.HasValue |
| | 3 | 147 | | || MinWidth.HasValue |
| | 3 | 148 | | || MinHeight.HasValue |
| | 3 | 149 | | || MaxWidth.HasValue |
| | 3 | 150 | | || MaxHeight.HasValue |
| | 3 | 151 | | || MinPremiereDate.HasValue |
| | 3 | 152 | | || MaxPremiereDate.HasValue |
| | 3 | 153 | | || MinStartDate.HasValue |
| | 3 | 154 | | || MaxStartDate.HasValue |
| | 3 | 155 | | || MinEndDate.HasValue |
| | 3 | 156 | | || MaxEndDate.HasValue |
| | 3 | 157 | | || MinDateCreated.HasValue |
| | 3 | 158 | | || MinDateLastSaved.HasValue |
| | 3 | 159 | | || MinDateLastSavedForUser.HasValue |
| | 3 | 160 | | || AdjacentTo.HasValue |
| | 3 | 161 | | || !string.IsNullOrEmpty(NameStartsWith) |
| | 3 | 162 | | || !string.IsNullOrEmpty(NameStartsWithOrGreater) |
| | 3 | 163 | | || !string.IsNullOrEmpty(NameLessThan) |
| | 3 | 164 | | || !string.IsNullOrEmpty(NameContains) |
| | 3 | 165 | | || !string.IsNullOrEmpty(MinSortName) |
| | 3 | 166 | | || !string.IsNullOrEmpty(Name) |
| | 3 | 167 | | || !string.IsNullOrEmpty(Person) |
| | 3 | 168 | | || !string.IsNullOrEmpty(SearchTerm) |
| | 3 | 169 | | || !string.IsNullOrEmpty(Path); |
| | | 170 | | |
| | | 171 | | public bool Recursive { get; set; } |
| | | 172 | | |
| | | 173 | | public int? StartIndex { get; set; } |
| | | 174 | | |
| | | 175 | | public int? Limit { get; set; } |
| | | 176 | | |
| | | 177 | | public User? User { get; set; } |
| | | 178 | | |
| | | 179 | | public bool? IsFolder { get; set; } |
| | | 180 | | |
| | | 181 | | public bool? IsFavorite { get; set; } |
| | | 182 | | |
| | | 183 | | public bool? IsFavoriteOrLiked { get; set; } |
| | | 184 | | |
| | | 185 | | public bool? IsLiked { get; set; } |
| | | 186 | | |
| | | 187 | | public bool? IsPlayed { get; set; } |
| | | 188 | | |
| | | 189 | | public bool? IsResumable { get; set; } |
| | | 190 | | |
| | | 191 | | public bool? IncludeItemsByName { get; set; } |
| | | 192 | | |
| | | 193 | | public MediaType[] MediaTypes { get; set; } |
| | | 194 | | |
| | | 195 | | public BaseItemKind[] IncludeItemTypes { get; set; } |
| | | 196 | | |
| | | 197 | | public BaseItemKind[] ExcludeItemTypes { get; set; } |
| | | 198 | | |
| | | 199 | | public string[] ExcludeTags { get; set; } |
| | | 200 | | |
| | | 201 | | public string[] ExcludeInheritedTags { get; set; } |
| | | 202 | | |
| | | 203 | | public string[] IncludeInheritedTags { get; set; } |
| | | 204 | | |
| | | 205 | | public IReadOnlyList<string> Genres { get; set; } |
| | | 206 | | |
| | | 207 | | public bool? IsSpecialSeason { get; set; } |
| | | 208 | | |
| | | 209 | | public bool? IsMissing { get; set; } |
| | | 210 | | |
| | | 211 | | public bool? IsUnaired { get; set; } |
| | | 212 | | |
| | | 213 | | public bool? CollapseBoxSetItems { get; set; } |
| | | 214 | | |
| | | 215 | | /// <summary> |
| | | 216 | | /// Gets or sets the item types that should be collapsed into box sets. |
| | | 217 | | /// When empty, all types are collapsed. When set, only items of these types are replaced by their parent box se |
| | | 218 | | /// </summary> |
| | | 219 | | public BaseItemKind[] CollapseBoxSetItemTypes { get; set; } = []; |
| | | 220 | | |
| | | 221 | | public string? NameStartsWithOrGreater { get; set; } |
| | | 222 | | |
| | | 223 | | public string? NameStartsWith { get; set; } |
| | | 224 | | |
| | | 225 | | public string? NameLessThan { get; set; } |
| | | 226 | | |
| | | 227 | | public string? NameContains { get; set; } |
| | | 228 | | |
| | | 229 | | public string? MinSortName { get; set; } |
| | | 230 | | |
| | | 231 | | public string? PresentationUniqueKey { get; set; } |
| | | 232 | | |
| | | 233 | | public string? Path { get; set; } |
| | | 234 | | |
| | | 235 | | public string? Name { get; set; } |
| | | 236 | | |
| | | 237 | | public bool? UseRawName { get; set; } |
| | | 238 | | |
| | | 239 | | public string? Person { get; set; } |
| | | 240 | | |
| | | 241 | | public Guid[] PersonIds { get; set; } |
| | | 242 | | |
| | | 243 | | public Guid[] ItemIds { get; set; } |
| | | 244 | | |
| | | 245 | | public Guid[] OwnerIds { get; set; } |
| | | 246 | | |
| | | 247 | | public ExtraType[] ExtraTypes { get; set; } |
| | | 248 | | |
| | | 249 | | public Guid[] ExcludeItemIds { get; set; } |
| | | 250 | | |
| | | 251 | | public Guid? AdjacentTo { get; set; } |
| | | 252 | | |
| | | 253 | | public string[] PersonTypes { get; set; } |
| | | 254 | | |
| | | 255 | | public bool? Is3D { get; set; } |
| | | 256 | | |
| | | 257 | | public bool? IsHD { get; set; } |
| | | 258 | | |
| | | 259 | | public bool? IsLocked { get; set; } |
| | | 260 | | |
| | | 261 | | public bool? IsPlaceHolder { get; set; } |
| | | 262 | | |
| | | 263 | | public bool? HasImdbId { get; set; } |
| | | 264 | | |
| | | 265 | | public bool? HasOverview { get; set; } |
| | | 266 | | |
| | | 267 | | public bool? HasTmdbId { get; set; } |
| | | 268 | | |
| | | 269 | | public bool? HasOfficialRating { get; set; } |
| | | 270 | | |
| | | 271 | | public bool? HasTvdbId { get; set; } |
| | | 272 | | |
| | | 273 | | public bool? HasThemeSong { get; set; } |
| | | 274 | | |
| | | 275 | | public bool? HasThemeVideo { get; set; } |
| | | 276 | | |
| | | 277 | | public bool? HasSubtitles { get; set; } |
| | | 278 | | |
| | | 279 | | public bool? HasSpecialFeature { get; set; } |
| | | 280 | | |
| | | 281 | | public bool? HasTrailer { get; set; } |
| | | 282 | | |
| | | 283 | | public bool? HasParentalRating { get; set; } |
| | | 284 | | |
| | | 285 | | public Guid[] StudioIds { get; set; } |
| | | 286 | | |
| | | 287 | | public IReadOnlyList<Guid> GenreIds { get; set; } |
| | | 288 | | |
| | | 289 | | public ImageType[] ImageTypes { get; set; } |
| | | 290 | | |
| | | 291 | | public VideoType[] VideoTypes { get; set; } |
| | | 292 | | |
| | | 293 | | public UnratedItem[] BlockUnratedItems { get; set; } |
| | | 294 | | |
| | | 295 | | public int[] Years { get; set; } |
| | | 296 | | |
| | | 297 | | public string[] Tags { get; set; } |
| | | 298 | | |
| | | 299 | | public string[] OfficialRatings { get; set; } |
| | | 300 | | |
| | | 301 | | public DateTime? MinPremiereDate { get; set; } |
| | | 302 | | |
| | | 303 | | public DateTime? MaxPremiereDate { get; set; } |
| | | 304 | | |
| | | 305 | | public DateTime? MinStartDate { get; set; } |
| | | 306 | | |
| | | 307 | | public DateTime? MaxStartDate { get; set; } |
| | | 308 | | |
| | | 309 | | public DateTime? MinEndDate { get; set; } |
| | | 310 | | |
| | | 311 | | public DateTime? MaxEndDate { get; set; } |
| | | 312 | | |
| | | 313 | | public bool? IsAiring { get; set; } |
| | | 314 | | |
| | | 315 | | public bool? IsMovie { get; set; } |
| | | 316 | | |
| | | 317 | | public bool? IsSports { get; set; } |
| | | 318 | | |
| | | 319 | | public bool? IsKids { get; set; } |
| | | 320 | | |
| | | 321 | | public bool? IsNews { get; set; } |
| | | 322 | | |
| | | 323 | | public bool? IsSeries { get; set; } |
| | | 324 | | |
| | | 325 | | public int? MinIndexNumber { get; set; } |
| | | 326 | | |
| | | 327 | | /// <summary> |
| | | 328 | | /// Gets or sets the minimum ParentIndexNumber and IndexNumber. |
| | | 329 | | /// </summary> |
| | | 330 | | /// <remarks> |
| | | 331 | | /// It produces this where clause: |
| | | 332 | | /// <para>(ParentIndexNumber = X and IndexNumber >= Y) or ParentIndexNumber > X. |
| | | 333 | | /// </para> |
| | | 334 | | /// </remarks> |
| | | 335 | | public (int ParentIndexNumber, int IndexNumber)? MinParentAndIndexNumber { get; set; } |
| | | 336 | | |
| | | 337 | | public int? AiredDuringSeason { get; set; } |
| | | 338 | | |
| | | 339 | | public double? MinCriticRating { get; set; } |
| | | 340 | | |
| | | 341 | | public double? MinCommunityRating { get; set; } |
| | | 342 | | |
| | | 343 | | public IReadOnlyList<Guid> ChannelIds { get; set; } |
| | | 344 | | |
| | | 345 | | public int? ParentIndexNumber { get; set; } |
| | | 346 | | |
| | | 347 | | public int? ParentIndexNumberNotEquals { get; set; } |
| | | 348 | | |
| | | 349 | | public int? IndexNumber { get; set; } |
| | | 350 | | |
| | | 351 | | public ParentalRatingScore? MinParentalRating { get; set; } |
| | | 352 | | |
| | | 353 | | public ParentalRatingScore? MaxParentalRating { get; set; } |
| | | 354 | | |
| | | 355 | | public bool? HasDeadParentId { get; set; } |
| | | 356 | | |
| | | 357 | | public bool? IsVirtualItem { get; set; } |
| | | 358 | | |
| | | 359 | | public Guid ParentId { get; set; } |
| | | 360 | | |
| | | 361 | | public BaseItemKind? ParentType { get; set; } |
| | | 362 | | |
| | | 363 | | public Guid[] AncestorIds { get; set; } |
| | | 364 | | |
| | | 365 | | /// <summary> |
| | | 366 | | /// Gets or sets a list of ancestor ids that the item's linked children must descend from. |
| | | 367 | | /// Useful for filtering BoxSets/Playlists to only those that contain items from a specific library. |
| | | 368 | | /// </summary> |
| | | 369 | | public Guid[] LinkedChildAncestorIds { get; set; } |
| | | 370 | | |
| | | 371 | | public Guid[] TopParentIds { get; set; } |
| | | 372 | | |
| | | 373 | | public CollectionType?[] PresetViews { get; set; } |
| | | 374 | | |
| | | 375 | | public TrailerType[] TrailerTypes { get; set; } |
| | | 376 | | |
| | | 377 | | public SourceType[] SourceTypes { get; set; } |
| | | 378 | | |
| | | 379 | | public SeriesStatus[] SeriesStatuses { get; set; } |
| | | 380 | | |
| | | 381 | | public string? ExternalSeriesId { get; set; } |
| | | 382 | | |
| | | 383 | | public string? ExternalId { get; set; } |
| | | 384 | | |
| | | 385 | | public Guid[] AlbumIds { get; set; } |
| | | 386 | | |
| | | 387 | | public Guid[] ArtistIds { get; set; } |
| | | 388 | | |
| | | 389 | | public Guid[] ExcludeArtistIds { get; set; } |
| | | 390 | | |
| | | 391 | | public string? AncestorWithPresentationUniqueKey { get; set; } |
| | | 392 | | |
| | | 393 | | public string? SeriesPresentationUniqueKey { get; set; } |
| | | 394 | | |
| | | 395 | | public bool GroupByPresentationUniqueKey { get; set; } |
| | | 396 | | |
| | | 397 | | public bool GroupBySeriesPresentationUniqueKey { get; set; } |
| | | 398 | | |
| | | 399 | | public bool EnableTotalRecordCount { get; set; } |
| | | 400 | | |
| | | 401 | | public bool ForceDirect { get; set; } |
| | | 402 | | |
| | | 403 | | public Dictionary<string, string>? ExcludeProviderIds { get; set; } |
| | | 404 | | |
| | | 405 | | public bool EnableGroupByMetadataKey { get; set; } |
| | | 406 | | |
| | | 407 | | public bool? HasChapterImages { get; set; } |
| | | 408 | | |
| | | 409 | | public IReadOnlyList<(ItemSortBy OrderBy, SortOrder SortOrder)> OrderBy { get; set; } |
| | | 410 | | |
| | | 411 | | public DateTime? MinDateCreated { get; set; } |
| | | 412 | | |
| | | 413 | | public DateTime? MinDateLastSaved { get; set; } |
| | | 414 | | |
| | | 415 | | public DateTime? MinDateLastSavedForUser { get; set; } |
| | | 416 | | |
| | | 417 | | public DtoOptions DtoOptions { get; set; } |
| | | 418 | | |
| | | 419 | | public string? HasNoAudioTrackWithLanguage { get; set; } |
| | | 420 | | |
| | | 421 | | public string? HasNoInternalSubtitleTrackWithLanguage { get; set; } |
| | | 422 | | |
| | | 423 | | public string? HasNoExternalSubtitleTrackWithLanguage { get; set; } |
| | | 424 | | |
| | | 425 | | public string? HasNoSubtitleTrackWithLanguage { get; set; } |
| | | 426 | | |
| | | 427 | | public bool? IsDeadArtist { get; set; } |
| | | 428 | | |
| | | 429 | | public bool? IsDeadStudio { get; set; } |
| | | 430 | | |
| | | 431 | | public bool? IsDeadGenre { get; set; } |
| | | 432 | | |
| | | 433 | | public bool? IsDeadPerson { get; set; } |
| | | 434 | | |
| | | 435 | | /// <summary> |
| | | 436 | | /// Gets or sets a value indicating whether album sub-folders should be returned if they exist. |
| | | 437 | | /// </summary> |
| | | 438 | | public bool? DisplayAlbumFolders { get; set; } |
| | | 439 | | |
| | | 440 | | public BaseItem? Parent |
| | | 441 | | { |
| | | 442 | | set |
| | | 443 | | { |
| | 258 | 444 | | if (value is null) |
| | | 445 | | { |
| | 60 | 446 | | ParentId = Guid.Empty; |
| | 60 | 447 | | ParentType = null; |
| | | 448 | | } |
| | | 449 | | else |
| | | 450 | | { |
| | 198 | 451 | | ParentId = value.Id; |
| | 198 | 452 | | ParentType = value.GetBaseItemKind(); |
| | | 453 | | } |
| | 198 | 454 | | } |
| | | 455 | | } |
| | | 456 | | |
| | | 457 | | public Dictionary<string, string>? HasAnyProviderId { get; set; } |
| | | 458 | | |
| | | 459 | | public Dictionary<string, string[]>? HasAnyProviderIds { get; set; } |
| | | 460 | | |
| | | 461 | | public Guid[] AlbumArtistIds { get; set; } |
| | | 462 | | |
| | | 463 | | public Guid[] BoxSetLibraryFolders { get; set; } |
| | | 464 | | |
| | | 465 | | public Guid[] ContributingArtistIds { get; set; } |
| | | 466 | | |
| | | 467 | | public bool? HasAired { get; set; } |
| | | 468 | | |
| | | 469 | | public bool? HasOwnerId { get; set; } |
| | | 470 | | |
| | | 471 | | /// <summary> |
| | | 472 | | /// Gets or sets a value indicating whether to include items with an OwnerId |
| | | 473 | | /// (additional parts, alternate versions) that are normally excluded from general queries. |
| | | 474 | | /// </summary> |
| | | 475 | | public bool IncludeOwnedItems { get; set; } |
| | | 476 | | |
| | | 477 | | public bool? Is4K { get; set; } |
| | | 478 | | |
| | | 479 | | public int? MaxHeight { get; set; } |
| | | 480 | | |
| | | 481 | | public int? MaxWidth { get; set; } |
| | | 482 | | |
| | | 483 | | public int? MinHeight { get; set; } |
| | | 484 | | |
| | | 485 | | public int? MinWidth { get; set; } |
| | | 486 | | |
| | | 487 | | public string? SearchTerm { get; set; } |
| | | 488 | | |
| | | 489 | | public string? SeriesTimerId { get; set; } |
| | | 490 | | |
| | | 491 | | public bool SkipDeserialization { get; set; } |
| | | 492 | | |
| | | 493 | | public bool IncludeExtras { get; set; } |
| | | 494 | | |
| | | 495 | | public IReadOnlyList<string> AudioLanguages { get; set; } |
| | | 496 | | |
| | | 497 | | public IReadOnlyList<string> SubtitleLanguages { get; set; } |
| | | 498 | | |
| | | 499 | | public void SetUser(User user) |
| | | 500 | | { |
| | 5 | 501 | | var maxRating = user.MaxParentalRatingScore; |
| | 5 | 502 | | if (maxRating.HasValue) |
| | | 503 | | { |
| | 0 | 504 | | MaxParentalRating = new(maxRating.Value, user.MaxParentalRatingSubScore); |
| | | 505 | | } |
| | | 506 | | |
| | 5 | 507 | | var other = UnratedItem.Other.ToString(); |
| | 5 | 508 | | BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems) |
| | 5 | 509 | | .Where(i => i != other) |
| | 5 | 510 | | .Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray(); |
| | | 511 | | |
| | 5 | 512 | | ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags) |
| | 5 | 513 | | .Where(tag => !string.IsNullOrWhiteSpace(tag)) |
| | 5 | 514 | | .Select(tag => tag.RemoveDiacritics().ToLowerInvariant()) |
| | 5 | 515 | | .ToArray(); |
| | | 516 | | |
| | 5 | 517 | | IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags) |
| | 5 | 518 | | .Where(tag => !string.IsNullOrWhiteSpace(tag)) |
| | 5 | 519 | | .Select(tag => tag.RemoveDiacritics().ToLowerInvariant()) |
| | 5 | 520 | | .ToArray(); |
| | | 521 | | |
| | 5 | 522 | | User = user; |
| | 5 | 523 | | } |
| | | 524 | | |
| | | 525 | | public void ApplyFilters(ItemFilter[] filters) |
| | | 526 | | { |
| | | 527 | | static void ThrowConflictingFilters() |
| | | 528 | | => throw new ArgumentException("Conflicting filters", nameof(filters)); |
| | | 529 | | |
| | 15 | 530 | | foreach (var filter in filters) |
| | | 531 | | { |
| | | 532 | | switch (filter) |
| | | 533 | | { |
| | | 534 | | case ItemFilter.IsFolder: |
| | 1 | 535 | | if (filters.Contains(ItemFilter.IsNotFolder)) |
| | | 536 | | { |
| | 1 | 537 | | ThrowConflictingFilters(); |
| | | 538 | | } |
| | | 539 | | |
| | 0 | 540 | | IsFolder = true; |
| | 0 | 541 | | break; |
| | | 542 | | case ItemFilter.IsNotFolder: |
| | 0 | 543 | | if (filters.Contains(ItemFilter.IsFolder)) |
| | | 544 | | { |
| | 0 | 545 | | ThrowConflictingFilters(); |
| | | 546 | | } |
| | | 547 | | |
| | 0 | 548 | | IsFolder = false; |
| | 0 | 549 | | break; |
| | | 550 | | case ItemFilter.IsUnplayed: |
| | 0 | 551 | | if (filters.Contains(ItemFilter.IsPlayed)) |
| | | 552 | | { |
| | 0 | 553 | | ThrowConflictingFilters(); |
| | | 554 | | } |
| | | 555 | | |
| | 0 | 556 | | IsPlayed = false; |
| | 0 | 557 | | break; |
| | | 558 | | case ItemFilter.IsPlayed: |
| | 1 | 559 | | if (filters.Contains(ItemFilter.IsUnplayed)) |
| | | 560 | | { |
| | 1 | 561 | | ThrowConflictingFilters(); |
| | | 562 | | } |
| | | 563 | | |
| | 0 | 564 | | IsPlayed = true; |
| | 0 | 565 | | break; |
| | | 566 | | case ItemFilter.IsFavorite: |
| | 0 | 567 | | IsFavorite = true; |
| | 0 | 568 | | break; |
| | | 569 | | case ItemFilter.IsResumable: |
| | 0 | 570 | | IsResumable = true; |
| | 0 | 571 | | break; |
| | | 572 | | case ItemFilter.Likes: |
| | 1 | 573 | | if (filters.Contains(ItemFilter.Dislikes)) |
| | | 574 | | { |
| | 1 | 575 | | ThrowConflictingFilters(); |
| | | 576 | | } |
| | | 577 | | |
| | 0 | 578 | | IsLiked = true; |
| | 0 | 579 | | break; |
| | | 580 | | case ItemFilter.Dislikes: |
| | 0 | 581 | | if (filters.Contains(ItemFilter.Likes)) |
| | | 582 | | { |
| | 0 | 583 | | ThrowConflictingFilters(); |
| | | 584 | | } |
| | | 585 | | |
| | 0 | 586 | | IsLiked = false; |
| | 0 | 587 | | break; |
| | | 588 | | case ItemFilter.IsFavoriteOrLikes: |
| | 0 | 589 | | IsFavoriteOrLiked = true; |
| | | 590 | | break; |
| | | 591 | | } |
| | | 592 | | } |
| | 3 | 593 | | } |
| | | 594 | | } |
| | | 595 | | } |