More improvements

This commit is contained in:
Bond_009 2021-05-05 15:30:32 +02:00
parent 787bcd4a83
commit bcb4010db6
9 changed files with 32 additions and 47 deletions

View File

@ -11,6 +11,12 @@ namespace Emby.Server.Implementations.Library.Resolvers
public abstract class ItemResolver<T> : IItemResolver public abstract class ItemResolver<T> : IItemResolver
where T : BaseItem, new() where T : BaseItem, new()
{ {
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public virtual ResolverPriority Priority => ResolverPriority.First;
/// <summary> /// <summary>
/// Resolves the specified args. /// Resolves the specified args.
/// </summary> /// </summary>
@ -21,12 +27,6 @@ namespace Emby.Server.Implementations.Library.Resolvers
return null; return null;
} }
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public virtual ResolverPriority Priority => ResolverPriority.First;
/// <summary> /// <summary>
/// Sets initial values on the newly resolved item. /// Sets initial values on the newly resolved item.
/// </summary> /// </summary>

View File

@ -376,7 +376,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
{ {
var multiDiscFolders = new List<FileSystemMetadata>(); var multiDiscFolders = new List<FileSystemMetadata>();
var libraryOptions = args.GetLibraryOptions(); var libraryOptions = args.LibraryOptions;
var supportPhotos = string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && libraryOptions.EnablePhotos; var supportPhotos = string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && libraryOptions.EnablePhotos;
var photos = new List<FileSystemMetadata>(); var photos = new List<FileSystemMetadata>();

View File

@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
public class PhotoAlbumResolver : FolderResolver<PhotoAlbum> public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
{ {
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PhotoAlbumResolver"/> class. /// Initializes a new instance of the <see cref="PhotoAlbumResolver"/> class.
@ -26,6 +26,9 @@ namespace Emby.Server.Implementations.Library.Resolvers
_libraryManager = libraryManager; _libraryManager = libraryManager;
} }
/// <inheritdoc />
public override ResolverPriority Priority => ResolverPriority.Second;
/// <summary> /// <summary>
/// Resolves the specified args. /// Resolves the specified args.
/// </summary> /// </summary>
@ -39,8 +42,8 @@ namespace Emby.Server.Implementations.Library.Resolvers
// Must be an image file within a photo collection // Must be an image file within a photo collection
var collectionType = args.GetCollectionType(); var collectionType = args.GetCollectionType();
if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) || if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)
(string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.GetLibraryOptions().EnablePhotos)) || (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.LibraryOptions.EnablePhotos))
{ {
if (HasPhotos(args)) if (HasPhotos(args))
{ {
@ -84,8 +87,5 @@ namespace Emby.Server.Implementations.Library.Resolvers
return false; return false;
} }
/// <inheritdoc />
public override ResolverPriority Priority => ResolverPriority.Second;
} }
} }

View File

@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
var collectionType = args.CollectionType; var collectionType = args.CollectionType;
if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)
|| (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.GetLibraryOptions().EnablePhotos)) || (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.LibraryOptions.EnablePhotos))
{ {
if (IsImageFile(args.Path, _imageProcessor)) if (IsImageFile(args.Path, _imageProcessor))
{ {

View File

@ -88,7 +88,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
_localization.GetLocalizedString("NameSeasonNumber"), _localization.GetLocalizedString("NameSeasonNumber"),
seasonNumber, seasonNumber,
args.GetLibraryOptions().PreferredMetadataLanguage); args.LibraryOptions.PreferredMetadataLanguage);
} }
return season; return season;

View File

@ -19,19 +19,16 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
/// </summary> /// </summary>
public class SeriesResolver : FolderResolver<Series> public class SeriesResolver : FolderResolver<Series>
{ {
private readonly IFileSystem _fileSystem;
private readonly ILogger<SeriesResolver> _logger; private readonly ILogger<SeriesResolver> _logger;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SeriesResolver"/> class. /// Initializes a new instance of the <see cref="SeriesResolver"/> class.
/// </summary> /// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
public SeriesResolver(IFileSystem fileSystem, ILogger<SeriesResolver> logger, ILibraryManager libraryManager) public SeriesResolver(ILogger<SeriesResolver> logger, ILibraryManager libraryManager)
{ {
_fileSystem = fileSystem;
_logger = logger; _logger = logger;
_libraryManager = libraryManager; _libraryManager = libraryManager;
} }
@ -59,15 +56,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var collectionType = args.GetCollectionType(); var collectionType = args.GetCollectionType();
if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{ {
// if (args.ContainsFileSystemEntryByName("tvshow.nfo"))
//{
// return new Series
// {
// Path = args.Path,
// Name = Path.GetFileName(args.Path)
// };
//}
var configuredContentType = _libraryManager.GetConfiguredContentType(args.Path); var configuredContentType = _libraryManager.GetConfiguredContentType(args.Path);
if (!string.Equals(configuredContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(configuredContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{ {
@ -100,7 +88,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
return null; return null;
} }
if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, false)) if (IsSeriesFolder(args.Path, args.FileSystemChildren, _logger, _libraryManager, false))
{ {
return new Series return new Series
{ {
@ -117,8 +105,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
public static bool IsSeriesFolder( public static bool IsSeriesFolder(
string path, string path,
IEnumerable<FileSystemMetadata> fileSystemChildren, IEnumerable<FileSystemMetadata> fileSystemChildren,
IDirectoryService directoryService,
IFileSystem fileSystem,
ILogger<SeriesResolver> logger, ILogger<SeriesResolver> logger,
ILibraryManager libraryManager, ILibraryManager libraryManager,
bool isTvContentType) bool isTvContentType)

View File

@ -61,7 +61,6 @@ namespace MediaBrowser.Controller.Entities
try try
{ {
var result = XmlSerializer.DeserializeFromFile(typeof(LibraryOptions), GetLibraryOptionsPath(path)) as LibraryOptions; var result = XmlSerializer.DeserializeFromFile(typeof(LibraryOptions), GetLibraryOptionsPath(path)) as LibraryOptions;
if (result == null) if (result == null)
{ {
return new LibraryOptions(); return new LibraryOptions();

View File

@ -14,14 +14,14 @@ namespace MediaBrowser.Controller.Library
/// These are arguments relating to the file system that are collected once and then referred to /// These are arguments relating to the file system that are collected once and then referred to
/// whenever needed. Primarily for entity resolution. /// whenever needed. Primarily for entity resolution.
/// </summary> /// </summary>
public class ItemResolveArgs : EventArgs public class ItemResolveArgs
{ {
/// <summary> /// <summary>
/// The _app paths. /// The _app paths.
/// </summary> /// </summary>
private readonly IServerApplicationPaths _appPaths; private readonly IServerApplicationPaths _appPaths;
public IDirectoryService DirectoryService { get; private set; } private LibraryOptions _libraryOptions;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ItemResolveArgs" /> class. /// Initializes a new instance of the <see cref="ItemResolveArgs" /> class.
@ -34,17 +34,18 @@ namespace MediaBrowser.Controller.Library
DirectoryService = directoryService; DirectoryService = directoryService;
} }
public IDirectoryService DirectoryService { get; }
/// <summary> /// <summary>
/// Gets the file system children. /// Gets the file system children.
/// </summary> /// </summary>
/// <value>The file system children.</value> /// <value>The file system children.</value>
public FileSystemMetadata[] FileSystemChildren { get; set; } public FileSystemMetadata[] FileSystemChildren { get; set; }
public LibraryOptions LibraryOptions { get; set; } public LibraryOptions LibraryOptions
public LibraryOptions GetLibraryOptions()
{ {
return LibraryOptions ?? (LibraryOptions = Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent)); get => _libraryOptions ??= Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent);
set => _libraryOptions = value;
} }
/// <summary> /// <summary>
@ -139,7 +140,7 @@ namespace MediaBrowser.Controller.Library
/// Adds the additional location. /// Adds the additional location.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <c>null</c> or empty.</exception>
public void AddAdditionalLocation(string path) public void AddAdditionalLocation(string path)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
@ -148,7 +149,6 @@ namespace MediaBrowser.Controller.Library
} }
AdditionalLocations ??= new List<string>(); AdditionalLocations ??= new List<string>();
AdditionalLocations.Add(path); AdditionalLocations.Add(path);
} }
@ -172,7 +172,7 @@ namespace MediaBrowser.Controller.Library
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <returns>FileSystemInfo.</returns> /// <returns>FileSystemInfo.</returns>
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
public FileSystemMetadata GetFileSystemEntryByName(string name) public FileSystemMetadata GetFileSystemEntryByName(string name)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))

View File

@ -10,6 +10,12 @@ namespace MediaBrowser.Controller.Resolvers
public abstract class ItemResolver<T> : IItemResolver public abstract class ItemResolver<T> : IItemResolver
where T : BaseItem, new() where T : BaseItem, new()
{ {
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public virtual ResolverPriority Priority => ResolverPriority.First;
/// <summary> /// <summary>
/// Resolves the specified args. /// Resolves the specified args.
/// </summary> /// </summary>
@ -20,12 +26,6 @@ namespace MediaBrowser.Controller.Resolvers
return null; return null;
} }
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public virtual ResolverPriority Priority => ResolverPriority.First;
/// <summary> /// <summary>
/// Sets initial values on the newly resolved item. /// Sets initial values on the newly resolved item.
/// </summary> /// </summary>