mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-04 21:32:53 +01:00
move language filters from QueryFiltersLegacy to QueryFilters
This commit is contained in:
@@ -535,46 +535,12 @@ 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,
|
||||
OfficialRatings = officialRatings,
|
||||
Tags = tags,
|
||||
Genres = genres,
|
||||
SubtitleLanguages = subtitleLanguages,
|
||||
AudioLanguages = audioLanguages
|
||||
Genres = genres
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1078,6 +1078,7 @@ public sealed partial class BaseItemRepository
|
||||
{
|
||||
// Dvds and Blu-rays can either be stored in a folder structure or as an iso file
|
||||
// => to find all matches we need to check both: VideoType and IsoType
|
||||
// alternatively, we could provide specific IsoType filters
|
||||
var videoTypeBs = filter.VideoTypes.Select(vt => $"\"VideoType\":\"{vt}\"").ToArray();
|
||||
var isoTypeBs = filter.VideoTypes.Select(vt => $"\"IsoType\":\"{vt}\"").ToArray();
|
||||
Expression<Func<BaseItemEntity, bool>> hasVideoType = e => videoTypeBs.Any(f => e.Data!.Contains(f)) || isoTypeBs.Any(f => e.Data!.Contains(f));
|
||||
|
||||
@@ -55,6 +55,17 @@ public class MediaStreamRepository : IMediaStreamRepository
|
||||
return TranslateQuery(context.MediaStreamInfos.AsNoTracking(), filter).AsEnumerable().Select(Map).ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<string> GetMediaStreamLanguages(MediaStreamType mediaStreamType)
|
||||
{
|
||||
using var context = _dbProvider.CreateDbContext();
|
||||
return context.MediaStreamInfos
|
||||
.Where(e => e.StreamType == (MediaStreamTypeEntity)mediaStreamType)
|
||||
.Select(s => string.IsNullOrEmpty(s.Language) ? "und" : s.Language) // und = undetermined
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private string? GetPathToSave(string? path)
|
||||
{
|
||||
if (path is null)
|
||||
|
||||
Reference in New Issue
Block a user