diff options
| author | TheMelmacian <76712303+TheMelmacian@users.noreply.github.com> | 2026-05-10 21:40:41 +0200 |
|---|---|---|
| committer | TheMelmacian <76712303+TheMelmacian@users.noreply.github.com> | 2026-05-10 21:40:41 +0200 |
| commit | 5701cdce684dbbcdfdd5cc4c79586fe623e9f2d0 (patch) | |
| tree | 95618c0f97de94ae5937fbda68206867b1f62999 /Jellyfin.Server.Implementations/Item/BaseItemRepository.Querying.cs | |
| parent | a42956c18286e253e4d5dc3c64e39f47490b2b4f (diff) | |
fix: prevent language filters to load in non video libraries
Diffstat (limited to 'Jellyfin.Server.Implementations/Item/BaseItemRepository.Querying.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/BaseItemRepository.Querying.cs | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.Querying.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.Querying.cs index d8fc87ec18..71b46b3cb5 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.Querying.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.Querying.cs @@ -517,20 +517,6 @@ public sealed partial class BaseItemRepository .OrderBy(r => r) .ToArray(); - var subtitleLanguages = context.MediaStreamInfos - .Where(s => s.StreamType == MediaStreamTypeEntity.Subtitle) - .Select(s => string.IsNullOrEmpty(s.Language) ? "und" : s.Language) // und = undetermined - .Distinct() - .OrderBy(l => l) - .ToArray(); - - var audioLanguages = context.MediaStreamInfos - .Where(s => s.StreamType == MediaStreamTypeEntity.Audio) - .Select(s => string.IsNullOrEmpty(s.Language) ? "und" : s.Language) // und = undetermined - .Distinct() - .OrderBy(l => l) - .ToArray(); - var tags = context.ItemValuesMap .Where(ivm => ivm.ItemValue.Type == ItemValueType.Tags) .Where(ivm => matchingItemIds.Contains(ivm.ItemId)) @@ -549,6 +535,28 @@ public sealed partial class BaseItemRepository .OrderBy(g => g) .ToArray(); + // At the moment language filters are only available for video types (Movie and Series libraries). + // They are fetched directly from the MediaStreamInfos table and only filtered by StreamType. + // This is the fastest and most perfomant way to get the list of available languages, + // but the filter values can include language tags that are not linked to any item in the current library. + var subtitleLanguages = IncludesVideoTypes(filter) + ? context.MediaStreamInfos + .Where(s => s.StreamType == MediaStreamTypeEntity.Subtitle) + .Select(s => string.IsNullOrEmpty(s.Language) ? "und" : s.Language) // und = undetermined + .Distinct() + .OrderBy(l => l) + .ToArray() + : []; + + var audioLanguages = IncludesVideoTypes(filter) + ? context.MediaStreamInfos + .Where(s => s.StreamType == MediaStreamTypeEntity.Audio) + .Select(s => string.IsNullOrEmpty(s.Language) ? "und" : s.Language) // und = undetermined + .Distinct() + .OrderBy(l => l) + .ToArray() + : []; + return new QueryFiltersLegacy { Years = years, @@ -559,4 +567,14 @@ public sealed partial class BaseItemRepository AudioLanguages = audioLanguages }; } + + private bool IncludesVideoTypes(InternalItemsQuery filter) + { + return filter.IncludeItemTypes.Contains(BaseItemKind.Movie) + || filter.IncludeItemTypes.Contains(BaseItemKind.Video) + || filter.IncludeItemTypes.Contains(BaseItemKind.Series) + || filter.IncludeItemTypes.Contains(BaseItemKind.Season) + || filter.IncludeItemTypes.Contains(BaseItemKind.Episode) + || filter.IncludeItemTypes.Contains(BaseItemKind.Trailer); + } } |
