From 68d1b609647d0a592afc7d994fad2dedcb135f6b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 13 Aug 2016 01:49:00 -0400 Subject: stub out objects for per library settings --- .../Library/Resolvers/Audio/AudioResolver.cs | 6 +++-- .../Library/Resolvers/Audio/MusicAlbumResolver.cs | 30 ++++++++-------------- .../Library/Resolvers/Audio/MusicArtistResolver.cs | 2 +- 3 files changed, 16 insertions(+), 22 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/Resolvers/Audio') diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs index b4cda39cd..039a17100 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs @@ -37,14 +37,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio if (!args.IsDirectory) { - if (_libraryManager.IsAudioFile(args.Path)) + var libraryOptions = args.GetLibraryOptions(); + + if (_libraryManager.IsAudioFile(args.Path, libraryOptions)) { var collectionType = args.GetCollectionType(); var isMixed = string.IsNullOrWhiteSpace(collectionType); // For conflicting extensions, give priority to videos - if (isMixed && _libraryManager.IsVideoFile(args.Path)) + if (isMixed && _libraryManager.IsVideoFile(args.Path, libraryOptions)) { return null; } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 9f8293cb5..546f64d3c 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; using System.IO; using CommonIO; +using MediaBrowser.Controller.Configuration; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { @@ -72,12 +73,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio /// /// Determine if the supplied file data points to a music album /// - /// The path. - /// The directory service. - /// true if [is music album] [the specified data]; otherwise, false. - public bool IsMusicAlbum(string path, IDirectoryService directoryService) + public bool IsMusicAlbum(string path, IDirectoryService directoryService, LibraryOptions libraryOptions) { - return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, _logger, _fileSystem, _libraryManager); + return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService, _logger, _fileSystem, libraryOptions, _libraryManager); } /// @@ -91,7 +89,7 @@ namespace MediaBrowser.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, _libraryManager)) return true; + if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService, _logger, _fileSystem, args.GetLibraryOptions(), _libraryManager)) return true; } return false; @@ -100,18 +98,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio /// /// Determine if the supplied list contains what we should consider music /// - /// The list. - /// if set to true [allow subfolders]. - /// The directory service. - /// The logger. - /// The file system. - /// The library manager. - /// true if the specified list contains music; otherwise, false. private bool ContainsMusic(IEnumerable list, bool allowSubfolders, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem, + LibraryOptions libraryOptions, ILibraryManager libraryManager) { var discSubfolderCount = 0; @@ -124,11 +116,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio if (allowSubfolders) { var path = fileSystemInfo.FullName; - var isMultiDisc = IsMultiDiscFolder(path); + var isMultiDisc = IsMultiDiscFolder(path, libraryOptions); if (isMultiDisc) { - var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager); + var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryOptions, libraryManager); if (hasMusic) { @@ -138,7 +130,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio } else { - var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager); + var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryOptions, libraryManager); if (hasMusic) { @@ -151,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio var fullName = fileSystemInfo.FullName; - if (libraryManager.IsAudioFile(fullName)) + if (libraryManager.IsAudioFile(fullName, libraryOptions)) { return true; } @@ -165,9 +157,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio return discSubfolderCount > 0; } - private bool IsMultiDiscFolder(string path) + private bool IsMultiDiscFolder(string path, LibraryOptions libraryOptions) { - var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions(); + var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions(libraryOptions); var parser = new AlbumParser(namingOptions, new PatternsLogger()); var result = parser.ParseMultiPart(path); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs index e3c991e7e..e819af06f 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs @@ -72,7 +72,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio var albumResolver = new MusicAlbumResolver(_logger, _fileSystem, _libraryManager); // If we contain an album assume we are an artist folder - return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService)) ? new MusicArtist() : null; + return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService, args.GetLibraryOptions())) ? new MusicArtist() : null; } } -- cgit v1.2.3