mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Fix distinction queries (#14007)
This commit is contained in:
parent
67110b512a
commit
f576783ae1
@ -130,7 +130,7 @@ namespace Emby.Server.Implementations.IO
|
||||
private void ProcessPathChanges(List<string> paths)
|
||||
{
|
||||
IEnumerable<BaseItem> itemsToRefresh = paths
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Distinct()
|
||||
.Select(GetAffectedBaseItem)
|
||||
.Where(item => item is not null)
|
||||
.DistinctBy(x => x!.Id)!; // Removed null values in the previous .Where()
|
||||
|
@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.IO
|
||||
.Where(IsLibraryMonitorEnabled)
|
||||
.OfType<Folder>()
|
||||
.SelectMany(f => f.PhysicalLocations)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Distinct()
|
||||
.Order();
|
||||
|
||||
foreach (var path in paths)
|
||||
|
@ -668,10 +668,10 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var list = originalList.Where(i => i.IsDirectory)
|
||||
.Select(i => Path.TrimEndingDirectorySeparator(i.FullName))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var dupes = list.Where(subPath => !subPath.EndsWith(":\\", StringComparison.OrdinalIgnoreCase) && list.Any(i => _fileSystem.ContainsSubPath(i, subPath)))
|
||||
var dupes = list.Where(subPath => !subPath.EndsWith(":\\", StringComparison.Ordinal) && list.Any(i => _fileSystem.ContainsSubPath(i, subPath)))
|
||||
.ToList();
|
||||
|
||||
foreach (var dupe in dupes)
|
||||
@ -679,7 +679,7 @@ namespace Emby.Server.Implementations.Library
|
||||
_logger.LogInformation("Found duplicate path: {0}", dupe);
|
||||
}
|
||||
|
||||
var newList = list.Except(dupes, StringComparer.OrdinalIgnoreCase).Select(_fileSystem.GetDirectoryInfo).ToList();
|
||||
var newList = list.Except(dupes, StringComparer.Ordinal).Select(_fileSystem.GetDirectoryInfo).ToList();
|
||||
newList.AddRange(originalList.Where(i => !i.IsDirectory));
|
||||
return newList;
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public class ItemUpdateController : BaseJellyfinApiController
|
||||
|
||||
if (!season.LockedFields.Contains(MetadataField.Tags))
|
||||
{
|
||||
season.Tags = season.Tags.Concat(addedTags).Except(removedTags).Distinct().ToArray();
|
||||
season.Tags = season.Tags.Concat(addedTags).Except(removedTags).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
|
||||
season.OnMetadataChanged();
|
||||
@ -316,7 +316,7 @@ public class ItemUpdateController : BaseJellyfinApiController
|
||||
|
||||
if (!ep.LockedFields.Contains(MetadataField.Tags))
|
||||
{
|
||||
ep.Tags = ep.Tags.Concat(addedTags).Except(removedTags).Distinct().ToArray();
|
||||
ep.Tags = ep.Tags.Concat(addedTags).Except(removedTags).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
|
||||
ep.OnMetadataChanged();
|
||||
@ -337,7 +337,7 @@ public class ItemUpdateController : BaseJellyfinApiController
|
||||
|
||||
if (!ep.LockedFields.Contains(MetadataField.Tags))
|
||||
{
|
||||
ep.Tags = ep.Tags.Concat(addedTags).Except(removedTags).Distinct().ToArray();
|
||||
ep.Tags = ep.Tags.Concat(addedTags).Except(removedTags).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
|
||||
ep.OnMetadataChanged();
|
||||
@ -357,7 +357,7 @@ public class ItemUpdateController : BaseJellyfinApiController
|
||||
|
||||
if (!track.LockedFields.Contains(MetadataField.Tags))
|
||||
{
|
||||
track.Tags = track.Tags.Concat(addedTags).Except(removedTags).Distinct().ToArray();
|
||||
track.Tags = track.Tags.Concat(addedTags).Except(removedTags).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
|
||||
track.OnMetadataChanged();
|
||||
|
@ -223,6 +223,6 @@ public class YearsController : BaseJellyfinApiController
|
||||
.Select(i => i.ProductionYear ?? 0)
|
||||
.Where(i => i > 0)
|
||||
.Distinct()
|
||||
.Select(year => _libraryManager.GetYear(year));
|
||||
.Select(_libraryManager.GetYear);
|
||||
}
|
||||
}
|
||||
|
@ -1804,7 +1804,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
public void SetStudios(IEnumerable<string> names)
|
||||
{
|
||||
Studios = names.Trimmed().Distinct().ToArray();
|
||||
Studios = names.Trimmed().Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -197,7 +197,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
var expandedFolders = new List<Guid>();
|
||||
|
||||
return FlattenItems(this, expandedFolders)
|
||||
.SelectMany(i => LibraryManager.GetCollectionFolders(i))
|
||||
.SelectMany(LibraryManager.GetCollectionFolders)
|
||||
.Select(i => i.Id)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
@ -14,8 +14,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
{
|
||||
public partial class EncoderValidator
|
||||
{
|
||||
private static readonly string[] _requiredDecoders = new[]
|
||||
{
|
||||
private static readonly string[] _requiredDecoders =
|
||||
[
|
||||
"h264",
|
||||
"hevc",
|
||||
"vp8",
|
||||
@ -57,10 +57,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
"vp8_rkmpp",
|
||||
"vp9_rkmpp",
|
||||
"av1_rkmpp"
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly string[] _requiredEncoders = new[]
|
||||
{
|
||||
private static readonly string[] _requiredEncoders =
|
||||
[
|
||||
"libx264",
|
||||
"libx265",
|
||||
"libsvtav1",
|
||||
@ -97,10 +97,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
"h264_rkmpp",
|
||||
"hevc_rkmpp",
|
||||
"mjpeg_rkmpp"
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly string[] _requiredFilters = new[]
|
||||
{
|
||||
private static readonly string[] _requiredFilters =
|
||||
[
|
||||
// sw
|
||||
"alphasrc",
|
||||
"zscale",
|
||||
@ -148,7 +148,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
"scale_rkrga",
|
||||
"vpp_rkrga",
|
||||
"overlay_rkrga"
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly Dictionary<int, string[]> _filterOptionsDict = new Dictionary<int, string[]>
|
||||
{
|
||||
@ -471,10 +471,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
|
||||
if (string.IsNullOrWhiteSpace(output))
|
||||
{
|
||||
return Enumerable.Empty<string>();
|
||||
return [];
|
||||
}
|
||||
|
||||
var found = output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).Distinct().ToList();
|
||||
var found = output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Skip(1).Distinct().ToList();
|
||||
_logger.LogInformation("Available hwaccel types: {Types}", found);
|
||||
|
||||
return found;
|
||||
@ -580,12 +580,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error detecting available {Codec}", codecstr);
|
||||
return Enumerable.Empty<string>();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(output))
|
||||
{
|
||||
return Enumerable.Empty<string>();
|
||||
return [];
|
||||
}
|
||||
|
||||
var required = codec == Codec.Encoder ? _requiredEncoders : _requiredDecoders;
|
||||
@ -610,12 +610,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error detecting available filters");
|
||||
return Enumerable.Empty<string>();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(output))
|
||||
{
|
||||
return Enumerable.Empty<string>();
|
||||
return [];
|
||||
}
|
||||
|
||||
var found = FilterRegex()
|
||||
|
@ -1041,7 +1041,7 @@ namespace MediaBrowser.Providers.Manager
|
||||
}
|
||||
else
|
||||
{
|
||||
target.Studios = target.Studios.Concat(source.Studios).Distinct().ToArray();
|
||||
target.Studios = target.Studios.Concat(source.Studios).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1053,7 +1053,7 @@ namespace MediaBrowser.Providers.Manager
|
||||
}
|
||||
else
|
||||
{
|
||||
target.Tags = target.Tags.Concat(source.Tags).Distinct().ToArray();
|
||||
target.Tags = target.Tags.Concat(source.Tags).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1065,7 +1065,7 @@ namespace MediaBrowser.Providers.Manager
|
||||
}
|
||||
else
|
||||
{
|
||||
target.ProductionLocations = target.ProductionLocations.Concat(source.ProductionLocations).Distinct().ToArray();
|
||||
target.ProductionLocations = target.ProductionLocations.Concat(source.ProductionLocations).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1214,7 +1214,7 @@ namespace MediaBrowser.Providers.Manager
|
||||
}
|
||||
else if (sourceHasAlbumArtist.AlbumArtists.Count > 0)
|
||||
{
|
||||
targetHasAlbumArtist.AlbumArtists = targetHasAlbumArtist.AlbumArtists.Concat(sourceHasAlbumArtist.AlbumArtists).Distinct().ToArray();
|
||||
targetHasAlbumArtist.AlbumArtists = targetHasAlbumArtist.AlbumArtists.Concat(sourceHasAlbumArtist.AlbumArtists).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ namespace MediaBrowser.Providers.Music
|
||||
}
|
||||
else
|
||||
{
|
||||
targetItem.Artists = targetItem.Artists.Concat(sourceItem.Artists).Distinct().ToArray();
|
||||
targetItem.Artists = targetItem.Artists.Concat(sourceItem.Artists).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
|
||||
if (replaceData || string.IsNullOrEmpty(targetItem.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist)))
|
||||
|
@ -63,7 +63,7 @@ namespace MediaBrowser.Providers.Music
|
||||
}
|
||||
else
|
||||
{
|
||||
targetItem.Artists = targetItem.Artists.Concat(sourceItem.Artists).Distinct().ToArray();
|
||||
targetItem.Artists = targetItem.Artists.Concat(sourceItem.Artists).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
|
||||
if (replaceData || string.IsNullOrEmpty(targetItem.Album))
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@ -48,7 +49,7 @@ namespace MediaBrowser.Providers.Music
|
||||
}
|
||||
else
|
||||
{
|
||||
targetItem.Artists = targetItem.Artists.Concat(sourceItem.Artists).Distinct().ToArray();
|
||||
targetItem.Artists = targetItem.Artists.Concat(sourceItem.Artists).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class PlaylistItemsProvider : ILocalMetadataProvider<Playlist>,
|
||||
.OfType<CollectionFolder>()
|
||||
.Where(f => f.CollectionType.HasValue && !_ignoredCollections.Contains(f.CollectionType.Value))
|
||||
.SelectMany(f => f.PhysicalLocations)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
using (var stream = File.OpenRead(path))
|
||||
|
@ -125,8 +125,8 @@ namespace Jellyfin.LiveTv
|
||||
IsKids = query.IsKids,
|
||||
IsSports = query.IsSports,
|
||||
IsSeries = query.IsSeries,
|
||||
IncludeItemTypes = new[] { BaseItemKind.LiveTvChannel },
|
||||
TopParentIds = new[] { topFolder.Id },
|
||||
IncludeItemTypes = [BaseItemKind.LiveTvChannel],
|
||||
TopParentIds = [topFolder.Id],
|
||||
IsFavorite = query.IsFavorite,
|
||||
IsLiked = query.IsLiked,
|
||||
StartIndex = query.StartIndex,
|
||||
@ -199,17 +199,17 @@ namespace Jellyfin.LiveTv
|
||||
if (query.OrderBy.Count == 0)
|
||||
{
|
||||
// Unless something else was specified, order by start date to take advantage of a specialized index
|
||||
query.OrderBy = new[]
|
||||
{
|
||||
query.OrderBy =
|
||||
[
|
||||
(ItemSortBy.StartDate, SortOrder.Ascending)
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
RemoveFields(options);
|
||||
|
||||
var internalQuery = new InternalItemsQuery(user)
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.LiveTvProgram },
|
||||
IncludeItemTypes = [BaseItemKind.LiveTvProgram],
|
||||
MinEndDate = query.MinEndDate,
|
||||
MinStartDate = query.MinStartDate,
|
||||
MaxEndDate = query.MaxEndDate,
|
||||
@ -226,7 +226,7 @@ namespace Jellyfin.LiveTv
|
||||
Limit = query.Limit,
|
||||
OrderBy = query.OrderBy,
|
||||
EnableTotalRecordCount = query.EnableTotalRecordCount,
|
||||
TopParentIds = new[] { topFolder.Id },
|
||||
TopParentIds = [topFolder.Id],
|
||||
Name = query.Name,
|
||||
DtoOptions = options,
|
||||
HasAired = query.HasAired,
|
||||
@ -272,7 +272,7 @@ namespace Jellyfin.LiveTv
|
||||
|
||||
var internalQuery = new InternalItemsQuery(user)
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.LiveTvProgram },
|
||||
IncludeItemTypes = [BaseItemKind.LiveTvProgram],
|
||||
IsAiring = query.IsAiring,
|
||||
HasAired = query.HasAired,
|
||||
IsNews = query.IsNews,
|
||||
@ -281,8 +281,8 @@ namespace Jellyfin.LiveTv
|
||||
IsSports = query.IsSports,
|
||||
IsKids = query.IsKids,
|
||||
EnableTotalRecordCount = query.EnableTotalRecordCount,
|
||||
OrderBy = new[] { (ItemSortBy.StartDate, SortOrder.Ascending) },
|
||||
TopParentIds = new[] { topFolder.Id },
|
||||
OrderBy = [(ItemSortBy.StartDate, SortOrder.Ascending)],
|
||||
TopParentIds = [topFolder.Id],
|
||||
DtoOptions = options,
|
||||
GenreIds = query.GenreIds
|
||||
};
|
||||
@ -497,19 +497,19 @@ namespace Jellyfin.LiveTv
|
||||
// TotalRecordCount = items.Length
|
||||
// };
|
||||
|
||||
dtoOptions.Fields = dtoOptions.Fields.Concat(new[] { ItemFields.Tags }).Distinct().ToArray();
|
||||
dtoOptions.Fields = dtoOptions.Fields.Concat([ItemFields.Tags]).Distinct().ToArray();
|
||||
}
|
||||
|
||||
var result = _libraryManager.GetItemsResult(new InternalItemsQuery(user)
|
||||
{
|
||||
MediaTypes = new[] { MediaType.Video },
|
||||
MediaTypes = [MediaType.Video],
|
||||
Recursive = true,
|
||||
AncestorIds = folderIds,
|
||||
IsFolder = false,
|
||||
IsVirtualItem = false,
|
||||
Limit = limit,
|
||||
StartIndex = query.StartIndex,
|
||||
OrderBy = new[] { (ItemSortBy.DateCreated, SortOrder.Descending) },
|
||||
OrderBy = [(ItemSortBy.DateCreated, SortOrder.Descending)],
|
||||
EnableTotalRecordCount = query.EnableTotalRecordCount,
|
||||
IncludeItemTypes = includeItemTypes.ToArray(),
|
||||
ExcludeItemTypes = excludeItemTypes.ToArray(),
|
||||
@ -959,13 +959,13 @@ namespace Jellyfin.LiveTv
|
||||
|
||||
var programs = options.AddCurrentProgram ? _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
IncludeItemTypes = new[] { BaseItemKind.LiveTvProgram },
|
||||
IncludeItemTypes = [BaseItemKind.LiveTvProgram],
|
||||
ChannelIds = channelIds,
|
||||
MaxStartDate = now,
|
||||
MinEndDate = now,
|
||||
Limit = channelIds.Length,
|
||||
OrderBy = new[] { (ItemSortBy.StartDate, SortOrder.Ascending) },
|
||||
TopParentIds = new[] { GetInternalLiveTvFolder(CancellationToken.None).Id },
|
||||
OrderBy = [(ItemSortBy.StartDate, SortOrder.Ascending)],
|
||||
TopParentIds = [GetInternalLiveTvFolder(CancellationToken.None).Id],
|
||||
DtoOptions = options
|
||||
}) : new List<BaseItem>();
|
||||
|
||||
@ -1269,7 +1269,7 @@ namespace Jellyfin.LiveTv
|
||||
{
|
||||
var folders = _recordingsManager.GetRecordingFolders()
|
||||
.SelectMany(i => i.Locations)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Distinct()
|
||||
.Select(i => _libraryManager.FindByPath(i, true))
|
||||
.Where(i => i is not null && i.IsVisibleStandalone(user))
|
||||
.SelectMany(i => _libraryManager.GetCollectionFolders(i))
|
||||
|
@ -230,7 +230,7 @@ public sealed class RecordingsManager : IRecordingsManager, IDisposable
|
||||
if (pathsAdded.Count > 0 || pathsToRemove.Count > 0)
|
||||
{
|
||||
pathsAdded.InsertRange(0, config.MediaLocationsCreated);
|
||||
config.MediaLocationsCreated = pathsAdded.Except(pathsToRemove).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
config.MediaLocationsCreated = pathsAdded.Except(pathsToRemove).Distinct().ToArray();
|
||||
_config.SaveConfiguration("livetv", config);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user