diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
8 files changed, 103 insertions, 52 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 055fde504b..a19f70e68c 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -364,7 +364,7 @@ namespace MediaBrowser.Server.Implementations.Library if (item.IsFolder) { - if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel)) + if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel) && !(item is AggregateFolder)) { if (item.SourceType != SourceType.Library) { @@ -556,7 +556,12 @@ namespace MediaBrowser.Server.Implementations.Library return ResolvePath(fileInfo, new DirectoryService(_logger, _fileSystem), null, parent); } - private BaseItem ResolvePath(FileSystemMetadata fileInfo, IDirectoryService directoryService, IItemResolver[] resolvers, Folder parent = null, string collectionType = null) + private BaseItem ResolvePath(FileSystemMetadata fileInfo, + IDirectoryService directoryService, + IItemResolver[] resolvers, + Folder parent = null, + string collectionType = null, + LibraryOptions libraryOptions = null) { if (fileInfo == null) { @@ -575,7 +580,8 @@ namespace MediaBrowser.Server.Implementations.Library Parent = parent, Path = fullPath, FileInfo = fileInfo, - CollectionType = collectionType + CollectionType = collectionType, + LibraryOptions = libraryOptions }; // Return null if ignore rules deem that we should do so @@ -653,12 +659,17 @@ namespace MediaBrowser.Server.Implementations.Library return !args.ContainsFileSystemEntryByName(".ignore"); } - public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, string collectionType) + public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, LibraryOptions libraryOptions, string collectionType) { - return ResolvePaths(files, directoryService, parent, collectionType, EntityResolvers); + return ResolvePaths(files, directoryService, parent, libraryOptions, collectionType, EntityResolvers); } - public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, string collectionType, IItemResolver[] resolvers) + public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, + IDirectoryService directoryService, + Folder parent, + LibraryOptions libraryOptions, + string collectionType, + IItemResolver[] resolvers) { var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList(); @@ -679,22 +690,27 @@ namespace MediaBrowser.Server.Implementations.Library { ResolverHelper.SetInitialItemValues(item, parent, _fileSystem, this, directoryService); } - items.AddRange(ResolveFileList(result.ExtraFiles, directoryService, parent, collectionType, resolvers)); + items.AddRange(ResolveFileList(result.ExtraFiles, directoryService, parent, collectionType, resolvers, libraryOptions)); return items; } } } - return ResolveFileList(fileList, directoryService, parent, collectionType, resolvers); + return ResolveFileList(fileList, directoryService, parent, collectionType, resolvers, libraryOptions); } - private IEnumerable<BaseItem> ResolveFileList(IEnumerable<FileSystemMetadata> fileList, IDirectoryService directoryService, Folder parent, string collectionType, IItemResolver[] resolvers) + private IEnumerable<BaseItem> ResolveFileList(IEnumerable<FileSystemMetadata> fileList, + IDirectoryService directoryService, + Folder parent, + string collectionType, + IItemResolver[] resolvers, + LibraryOptions libraryOptions) { return fileList.Select(f => { try { - return ResolvePath(f, directoryService, resolvers, parent, collectionType); + return ResolvePath(f, directoryService, resolvers, parent, collectionType, libraryOptions); } catch (Exception ex) { @@ -1207,7 +1223,7 @@ namespace MediaBrowser.Server.Implementations.Library .Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders)); } - private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> collectionFolders) + private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> allCollectionFolders) { var info = new VirtualFolderInfo { @@ -1221,7 +1237,7 @@ namespace MediaBrowser.Server.Implementations.Library CollectionType = GetCollectionType(dir) }; - var libraryFolder = collectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase)); + var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase)); if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary)) { @@ -1233,6 +1249,12 @@ namespace MediaBrowser.Server.Implementations.Library info.ItemId = libraryFolder.Id.ToString("N"); } + var collectionFolder = libraryFolder as CollectionFolder; + if (collectionFolder != null) + { + info.LibraryOptions = collectionFolder.GetLibraryOptions(); + } + return info; } @@ -1891,6 +1913,15 @@ namespace MediaBrowser.Server.Implementations.Library .Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase)); } + public LibraryOptions GetLibraryOptions(BaseItem item) + { + var collectionFolder = GetCollectionFolders(item) + .OfType<CollectionFolder>() + .FirstOrDefault(); + + return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions(); + } + public string GetContentType(BaseItem item) { string configuredContentType = GetConfiguredContentType(item, false); @@ -2242,18 +2273,28 @@ namespace MediaBrowser.Server.Implementations.Library return item; } - public bool IsVideoFile(string path) + public bool IsVideoFile(string path, LibraryOptions libraryOptions) { - var resolver = new VideoResolver(GetNamingOptions(), new PatternsLogger()); + var resolver = new VideoResolver(GetNamingOptions(libraryOptions), new PatternsLogger()); return resolver.IsVideoFile(path); } - public bool IsAudioFile(string path) + public bool IsVideoFile(string path) + { + return IsVideoFile(path, new LibraryOptions()); + } + + public bool IsAudioFile(string path, LibraryOptions libraryOptions) { - var parser = new AudioFileParser(GetNamingOptions()); + var parser = new AudioFileParser(GetNamingOptions(libraryOptions)); return parser.IsAudioFile(path); } + public bool IsAudioFile(string path) + { + return IsAudioFile(path, new LibraryOptions()); + } + public int? GetSeasonNumberFromPath(string path) { return new SeasonPathParser(GetNamingOptions(), new RegexProvider()).Parse(path, true, true).SeasonNumber; @@ -2380,19 +2421,24 @@ namespace MediaBrowser.Server.Implementations.Library public NamingOptions GetNamingOptions() { + return GetNamingOptions(new LibraryOptions()); + } + + public NamingOptions GetNamingOptions(LibraryOptions libraryOptions) + { var options = new ExtendedNamingOptions(); // These cause apps to have problems options.AudioFileExtensions.Remove(".m3u"); options.AudioFileExtensions.Remove(".wpl"); - if (!ConfigurationManager.Configuration.EnableAudioArchiveFiles) + if (!libraryOptions.EnableArchiveMediaFiles) { options.AudioFileExtensions.Remove(".rar"); options.AudioFileExtensions.Remove(".zip"); } - if (!ConfigurationManager.Configuration.EnableVideoArchiveFiles) + if (!libraryOptions.EnableArchiveMediaFiles) { options.VideoFileExtensions.Remove(".rar"); options.VideoFileExtensions.Remove(".zip"); @@ -2443,7 +2489,7 @@ namespace MediaBrowser.Server.Implementations.Library new GenericVideoResolver<Trailer>(this) }; - return ResolvePaths(files, directoryService, null, null, resolvers) + return ResolvePaths(files, directoryService, null, new LibraryOptions(), null, resolvers) .OfType<Trailer>() .Select(video => { @@ -2487,7 +2533,7 @@ namespace MediaBrowser.Server.Implementations.Library files.AddRange(currentVideo.Extras.Where(i => !string.Equals(i.ExtraType, "trailer", StringComparison.OrdinalIgnoreCase)).Select(i => _fileSystem.GetFileInfo(i.Path))); } - return ResolvePaths(files, directoryService, null, null) + return ResolvePaths(files, directoryService, null, new LibraryOptions(), null) .OfType<Video>() .Select(video => { @@ -2665,7 +2711,7 @@ namespace MediaBrowser.Server.Implementations.Library throw new InvalidOperationException(); } - public void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, bool refreshLibrary) + public void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, LibraryOptions options, bool refreshLibrary) { if (string.IsNullOrWhiteSpace(name)) { @@ -2708,6 +2754,8 @@ namespace MediaBrowser.Server.Implementations.Library } } + CollectionFolder.SaveLibraryOptions(virtualFolderPath, options); + if (mediaPaths != null) { foreach (var path in mediaPaths) diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs index b4cda39cd2..039a17100a 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 9f8293cb5b..1a8295800f 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -10,6 +10,8 @@ using System; using System.Collections.Generic; using System.IO; using CommonIO; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { @@ -72,12 +74,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio /// <summary> /// Determine if the supplied file data points to a music album /// </summary> - /// <param name="path">The path.</param> - /// <param name="directoryService">The directory service.</param> - /// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns> - 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); } /// <summary> @@ -91,7 +90,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 +99,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio /// <summary> /// Determine if the supplied list contains what we should consider music /// </summary> - /// <param name="list">The list.</param> - /// <param name="allowSubfolders">if set to <c>true</c> [allow subfolders].</param> - /// <param name="directoryService">The directory service.</param> - /// <param name="logger">The logger.</param> - /// <param name="fileSystem">The file system.</param> - /// <param name="libraryManager">The library manager.</param> - /// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns> private bool ContainsMusic(IEnumerable<FileSystemMetadata> list, bool allowSubfolders, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem, + LibraryOptions libraryOptions, ILibraryManager libraryManager) { var discSubfolderCount = 0; @@ -124,11 +117,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 +131,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 +144,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 +158,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 e3c991e7ea..e819af06fd 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; } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs index 703a338568..d0042a9907 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs @@ -133,7 +133,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers return null; } - if (LibraryManager.IsVideoFile(args.Path) || videoInfo.IsStub) + if (LibraryManager.IsVideoFile(args.Path, args.GetLibraryOptions()) || videoInfo.IsStub) { var path = args.Path; diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs index 9dd30eddee..3f9475480a 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs @@ -6,6 +6,8 @@ using System; using System.IO; using System.Linq; using CommonIO; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Server.Implementations.Library.Resolvers { @@ -32,15 +34,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers // Must be an image file within a photo collection var collectionType = args.GetCollectionType(); + if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) || - string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) + (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.GetLibraryOptions().EnablePhotos)) { if (IsImageFile(args.Path, _imageProcessor)) { var filename = Path.GetFileNameWithoutExtension(args.Path); // Make sure the image doesn't belong to a video file - if (args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(i, filename))) + if (args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename))) { return null; } @@ -56,9 +59,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers return null; } - private bool IsOwnedByMedia(FileSystemMetadata file, string imageFilename) + private bool IsOwnedByMedia(LibraryOptions libraryOptions, FileSystemMetadata file, string imageFilename) { - if (_libraryManager.IsVideoFile(file.FullName) && imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file.Name), StringComparison.OrdinalIgnoreCase)) + if (_libraryManager.IsVideoFile(file.FullName, libraryOptions) && imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file.Name), StringComparison.OrdinalIgnoreCase)) { return true; } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs index 45ba2ddbb3..aefb29f1a6 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs @@ -12,6 +12,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; using CommonIO; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV { @@ -83,7 +85,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV { return null; } - if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, false)) + if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, args.GetLibraryOptions(), false)) { return new Series { @@ -104,6 +106,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager, + LibraryOptions libraryOptions, bool isTvContentType) { foreach (var child in fileSystemChildren) @@ -134,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV else { string fullName = child.FullName; - if (libraryManager.IsVideoFile(fullName)) + if (libraryManager.IsVideoFile(fullName, libraryOptions)) { if (isTvContentType) { diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs index aa993d1768..d90b9615ba 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs @@ -115,6 +115,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators _logger.Debug("Will refresh {0} people", dict.Count); + var numPeople = dict.Count; + foreach (var person in dict) { cancellationToken.ThrowIfCancellationRequested(); @@ -124,7 +126,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var item = _libraryManager.GetPerson(person.Key); var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview); - var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 90; + var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 30; var defaultMetadataRefreshMode = performFullRefresh ? MetadataRefreshMode.FullRefresh @@ -155,7 +157,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators // Update progress numComplete++; double percent = numComplete; - percent /= people.Count; + percent /= numPeople; progress.Report(100 * percent); } |
