mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
@@ -1174,7 +1174,6 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
return _fileSystem.GetDirectoryPaths(ConfigurationManager.ApplicationPaths.DefaultUserViewsPath)
|
||||
.Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders, refreshQueue))
|
||||
.OrderBy(i => i.Name)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -1406,25 +1405,32 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
private void SetTopParentOrAncestorIds(InternalItemsQuery query)
|
||||
{
|
||||
if (query.AncestorIds.Length == 0)
|
||||
var ancestorIds = query.AncestorIds;
|
||||
int len = ancestorIds.Length;
|
||||
if (len == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var parents = query.AncestorIds.Select(i => GetItemById(i)).ToList();
|
||||
|
||||
if (parents.All(i => i is ICollectionFolder || i is UserView))
|
||||
var parents = new BaseItem[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
// Optimize by querying against top level views
|
||||
query.TopParentIds = parents.SelectMany(i => GetTopParentIdsForQuery(i, query.User)).ToArray();
|
||||
query.AncestorIds = Array.Empty<Guid>();
|
||||
|
||||
// Prevent searching in all libraries due to empty filter
|
||||
if (query.TopParentIds.Length == 0)
|
||||
parents[i] = GetItemById(ancestorIds[i]);
|
||||
if (!(parents[i] is ICollectionFolder || parents[i] is UserView))
|
||||
{
|
||||
query.TopParentIds = new[] { Guid.NewGuid() };
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Optimize by querying against top level views
|
||||
query.TopParentIds = parents.SelectMany(i => GetTopParentIdsForQuery(i, query.User)).ToArray();
|
||||
query.AncestorIds = Array.Empty<Guid>();
|
||||
|
||||
// Prevent searching in all libraries due to empty filter
|
||||
if (query.TopParentIds.Length == 0)
|
||||
{
|
||||
query.TopParentIds = new[] { Guid.NewGuid() };
|
||||
}
|
||||
}
|
||||
|
||||
public QueryResult<(BaseItem, ItemCounts)> GetAlbumArtists(InternalItemsQuery query)
|
||||
@@ -1585,7 +1591,7 @@ namespace Emby.Server.Implementations.Library
|
||||
public async Task<IEnumerable<Video>> GetIntros(BaseItem item, User user)
|
||||
{
|
||||
var tasks = IntroProviders
|
||||
.OrderBy(i => i.GetType().Name.IndexOf("Default", StringComparison.OrdinalIgnoreCase) == -1 ? 0 : 1)
|
||||
.OrderBy(i => i.GetType().Name.Contains("Default", StringComparison.OrdinalIgnoreCase) ? 1 : 0)
|
||||
.Take(1)
|
||||
.Select(i => GetIntros(i, item, user));
|
||||
|
||||
@@ -2363,33 +2369,22 @@ namespace Emby.Server.Implementations.Library
|
||||
new SubtitleResolver(BaseItem.LocalizationManager, _fileSystem).AddExternalSubtitleStreams(streams, videoPath, streams.Count, files);
|
||||
}
|
||||
|
||||
public bool IsVideoFile(string path, LibraryOptions libraryOptions)
|
||||
/// <inheritdoc />
|
||||
public bool IsVideoFile(string path)
|
||||
{
|
||||
var resolver = new VideoResolver(GetNamingOptions());
|
||||
return resolver.IsVideoFile(path);
|
||||
}
|
||||
|
||||
public bool IsVideoFile(string path)
|
||||
{
|
||||
return IsVideoFile(path, new LibraryOptions());
|
||||
}
|
||||
|
||||
public bool IsAudioFile(string path, LibraryOptions libraryOptions)
|
||||
{
|
||||
var parser = new AudioFileParser(GetNamingOptions());
|
||||
return parser.IsAudioFile(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsAudioFile(string path)
|
||||
{
|
||||
return IsAudioFile(path, new LibraryOptions());
|
||||
}
|
||||
=> AudioFileParser.IsAudioFile(path, GetNamingOptions());
|
||||
|
||||
/// <inheritdoc />
|
||||
public int? GetSeasonNumberFromPath(string path)
|
||||
{
|
||||
return SeasonPathParser.Parse(path, true, true).SeasonNumber;
|
||||
}
|
||||
=> SeasonPathParser.Parse(path, true, true).SeasonNumber;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh)
|
||||
{
|
||||
var series = episode.Series;
|
||||
|
||||
@@ -73,7 +73,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
// Return audio if the path is a file and has a matching extension
|
||||
|
||||
var libraryOptions = args.GetLibraryOptions();
|
||||
var collectionType = args.GetCollectionType();
|
||||
|
||||
var isBooksCollectionType = string.Equals(collectionType, CollectionType.Books, StringComparison.OrdinalIgnoreCase);
|
||||
@@ -92,7 +91,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
return FindAudio<AudioBook>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
|
||||
}
|
||||
|
||||
if (LibraryManager.IsAudioFile(args.Path, libraryOptions))
|
||||
if (LibraryManager.IsAudioFile(args.Path))
|
||||
{
|
||||
var extension = Path.GetExtension(args.Path);
|
||||
|
||||
@@ -105,7 +104,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
var isMixedCollectionType = string.IsNullOrEmpty(collectionType);
|
||||
|
||||
// For conflicting extensions, give priority to videos
|
||||
if (isMixedCollectionType && LibraryManager.IsVideoFile(args.Path, libraryOptions))
|
||||
if (isMixedCollectionType && LibraryManager.IsVideoFile(args.Path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -121,7 +120,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
item = new MediaBrowser.Controller.Entities.Audio.Audio();
|
||||
}
|
||||
|
||||
else if (isBooksCollectionType)
|
||||
{
|
||||
item = new AudioBook();
|
||||
|
||||
@@ -5,7 +5,6 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -78,9 +77,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
/// <summary>
|
||||
/// Determine if the supplied file data points to a music album.
|
||||
/// </summary>
|
||||
public bool IsMusicAlbum(string path, IDirectoryService directoryService, LibraryOptions libraryOptions)
|
||||
public bool IsMusicAlbum(string path, IDirectoryService directoryService)
|
||||
{
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, _logger, _fileSystem, libraryOptions, _libraryManager);
|
||||
return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, _logger, _fileSystem, _libraryManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,7 +93,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
// if (args.Parent is MusicArtist) return true; //saves us from testing children twice
|
||||
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, args.GetLibraryOptions(), _libraryManager))
|
||||
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, _libraryManager))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -112,7 +111,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
IDirectoryService directoryService,
|
||||
ILogger logger,
|
||||
IFileSystem fileSystem,
|
||||
LibraryOptions libraryOptions,
|
||||
ILibraryManager libraryManager)
|
||||
{
|
||||
var discSubfolderCount = 0;
|
||||
@@ -132,7 +130,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
}
|
||||
|
||||
var path = fileSystemInfo.FullName;
|
||||
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryOptions, libraryManager);
|
||||
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
|
||||
|
||||
if (hasMusic)
|
||||
{
|
||||
@@ -153,7 +151,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
var fullName = fileSystemInfo.FullName;
|
||||
|
||||
if (libraryManager.IsAudioFile(fullName, libraryOptions))
|
||||
if (libraryManager.IsAudioFile(fullName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -80,14 +80,17 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
}
|
||||
|
||||
// Avoid mis-identifying top folders
|
||||
if (args.Parent.IsRoot) return null;
|
||||
if (args.Parent.IsRoot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var directoryService = args.DirectoryService;
|
||||
|
||||
var albumResolver = new MusicAlbumResolver(_logger, _fileSystem, _libraryManager);
|
||||
|
||||
// If we contain an album assume we are an artist folder
|
||||
return args.FileSystemChildren.Where(i => i.IsDirectory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService, args.GetLibraryOptions())) ? new MusicArtist() : null;
|
||||
return args.FileSystemChildren.Where(i => i.IsDirectory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService)) ? new MusicArtist() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsBluRayDirectory(child.FullName, filename, args.DirectoryService))
|
||||
{
|
||||
videoInfo = parser.ResolveDirectory(args.Path);
|
||||
@@ -137,7 +138,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||
return null;
|
||||
}
|
||||
|
||||
if (LibraryManager.IsVideoFile(args.Path, args.GetLibraryOptions()) || videoInfo.IsStub)
|
||||
if (LibraryManager.IsVideoFile(args.Path) || videoInfo.IsStub)
|
||||
{
|
||||
var path = args.Path;
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||
if (result.Items.Count == 1)
|
||||
{
|
||||
var videoPath = result.Items[0].Path;
|
||||
var hasPhotos = photos.Any(i => !PhotoResolver.IsOwnedByResolvedMedia(LibraryManager, libraryOptions, videoPath, i.Name));
|
||||
var hasPhotos = photos.Any(i => !PhotoResolver.IsOwnedByResolvedMedia(LibraryManager, videoPath, i.Name));
|
||||
|
||||
if (!hasPhotos)
|
||||
{
|
||||
@@ -446,8 +446,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||
return movie;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.Items.Count == 0 && multiDiscFolders.Count > 0)
|
||||
else if (result.Items.Count == 0 && multiDiscFolders.Count > 0)
|
||||
{
|
||||
return GetMultiDiscMovie<T>(multiDiscFolders, directoryService);
|
||||
}
|
||||
@@ -519,14 +518,15 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||
return null;
|
||||
}
|
||||
|
||||
int additionalPartsLen = folderPaths.Count - 1;
|
||||
var additionalParts = new string[additionalPartsLen];
|
||||
folderPaths.CopyTo(1, additionalParts, 0, additionalPartsLen);
|
||||
|
||||
var returnVideo = new T
|
||||
{
|
||||
Path = folderPaths[0],
|
||||
|
||||
AdditionalParts = folderPaths.Skip(1).ToArray(),
|
||||
|
||||
AdditionalParts = additionalParts,
|
||||
VideoType = videoTypes[0],
|
||||
|
||||
Name = result[0].Name
|
||||
};
|
||||
|
||||
|
||||
@@ -63,13 +63,12 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
if (!file.IsDirectory && PhotoResolver.IsImageFile(file.FullName, _imageProcessor))
|
||||
{
|
||||
var libraryOptions = args.GetLibraryOptions();
|
||||
var filename = file.Name;
|
||||
var ownedByMedia = false;
|
||||
|
||||
foreach (var siblingFile in files)
|
||||
{
|
||||
if (PhotoResolver.IsOwnedByMedia(_libraryManager, libraryOptions, siblingFile.FullName, filename))
|
||||
if (PhotoResolver.IsOwnedByMedia(_libraryManager, siblingFile.FullName, filename))
|
||||
{
|
||||
ownedByMedia = true;
|
||||
break;
|
||||
|
||||
@@ -8,7 +8,6 @@ using System.Linq;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace Emby.Server.Implementations.Library.Resolvers
|
||||
@@ -57,11 +56,10 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||
|
||||
// Make sure the image doesn't belong to a video file
|
||||
var files = args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path));
|
||||
var libraryOptions = args.GetLibraryOptions();
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (IsOwnedByMedia(_libraryManager, libraryOptions, file.FullName, filename))
|
||||
if (IsOwnedByMedia(_libraryManager, file.FullName, filename))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -78,17 +76,17 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static bool IsOwnedByMedia(ILibraryManager libraryManager, LibraryOptions libraryOptions, string file, string imageFilename)
|
||||
internal static bool IsOwnedByMedia(ILibraryManager libraryManager, string file, string imageFilename)
|
||||
{
|
||||
if (libraryManager.IsVideoFile(file, libraryOptions))
|
||||
if (libraryManager.IsVideoFile(file))
|
||||
{
|
||||
return IsOwnedByResolvedMedia(libraryManager, libraryOptions, file, imageFilename);
|
||||
return IsOwnedByResolvedMedia(libraryManager, file, imageFilename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool IsOwnedByResolvedMedia(ILibraryManager libraryManager, LibraryOptions libraryOptions, string file, string imageFilename)
|
||||
internal static bool IsOwnedByResolvedMedia(ILibraryManager libraryManager, string file, string imageFilename)
|
||||
=> imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file), StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
internal static bool IsImageFile(string path, IImageProcessor imageProcessor)
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||
return null;
|
||||
}
|
||||
|
||||
if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, args.GetLibraryOptions(), false))
|
||||
if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, false))
|
||||
{
|
||||
return new Series
|
||||
{
|
||||
@@ -123,24 +123,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||
IFileSystem fileSystem,
|
||||
ILogger logger,
|
||||
ILibraryManager libraryManager,
|
||||
LibraryOptions libraryOptions,
|
||||
bool isTvContentType)
|
||||
{
|
||||
foreach (var child in fileSystemChildren)
|
||||
{
|
||||
//if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||
//{
|
||||
// //logger.LogDebug("Igoring series file or folder marked hidden: {0}", child.FullName);
|
||||
// continue;
|
||||
//}
|
||||
|
||||
// Can't enforce this because files saved by Bitcasa are always marked System
|
||||
//if ((attributes & FileAttributes.System) == FileAttributes.System)
|
||||
//{
|
||||
// logger.LogDebug("Igoring series subfolder marked system: {0}", child.FullName);
|
||||
// continue;
|
||||
//}
|
||||
|
||||
if (child.IsDirectory)
|
||||
{
|
||||
if (IsSeasonFolder(child.FullName, isTvContentType, libraryManager))
|
||||
@@ -152,7 +138,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||
else
|
||||
{
|
||||
string fullName = child.FullName;
|
||||
if (libraryManager.IsVideoFile(fullName, libraryOptions))
|
||||
if (libraryManager.IsVideoFile(fullName))
|
||||
{
|
||||
if (isTvContentType)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user