diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 98ad31220..f9c7fecb3 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -7,7 +7,13 @@ namespace MediaBrowser.Controller.Entities.TV /// /// Store these to reduce disk access in Episode Resolver /// - public string[] MetadataFiles { get; set; } + public string[] MetadataFiles + { + get + { + return ResolveArgs.MetadataFiles ?? new string[] { }; + } + } /// /// Determines if the metafolder contains a given file diff --git a/MediaBrowser.Controller/IO/FileSystemHelper.cs b/MediaBrowser.Controller/IO/FileSystemHelper.cs index 2897150a8..732cf0803 100644 --- a/MediaBrowser.Controller/IO/FileSystemHelper.cs +++ b/MediaBrowser.Controller/IO/FileSystemHelper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.IO; using System.Threading.Tasks; using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.Library; @@ -67,6 +68,12 @@ namespace MediaBrowser.Controller.IO args.IsBDFolder |= file.cFileName.Equals("bdmv", StringComparison.OrdinalIgnoreCase); args.IsDVDFolder |= file.cFileName.Equals("video_ts", StringComparison.OrdinalIgnoreCase); args.IsHDDVDFolder |= file.cFileName.Equals("hvdvd_ts", StringComparison.OrdinalIgnoreCase); + + //and check to see if it is a metadata folder and collect contents now if so + if (IsMetadataFolder(file.cFileName)) + { + args.MetadataFiles = Directory.GetFiles(Path.Combine(args.Path, "metadata"), "*", SearchOption.TopDirectoryOnly); + } } } } @@ -83,6 +90,11 @@ namespace MediaBrowser.Controller.IO return args; } + public static bool IsMetadataFolder(string path) + { + return path.TrimEnd('\\').EndsWith("metadata", StringComparison.OrdinalIgnoreCase); + } + public static bool IsVideoFile(string path) { string extension = System.IO.Path.GetExtension(path).ToLower(); diff --git a/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs b/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs index 02cffcf0f..32b8783df 100644 --- a/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs @@ -39,13 +39,10 @@ namespace MediaBrowser.Controller.Library public bool IsDVDFolder { get; set; } public bool IsHDDVDFolder { get; set; } - public bool IsMetadataFolder - { - get - { - return this.FileInfo.cFileName.Equals("metadata", StringComparison.OrdinalIgnoreCase); - } - } + /// + /// Store these to reduce disk access in Resolvers + /// + public string[] MetadataFiles { get; set; } public WIN32_FIND_DATA? GetFileSystemEntry(string path) { diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs index ebb1f4103..b821f8801 100644 --- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs +++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs @@ -18,6 +18,7 @@ namespace MediaBrowser.Controller.Resolvers public static List IgnoreFolders = new List() { "trailers", + "metadata", "bdmv", "certificate", "backup", @@ -62,11 +63,6 @@ namespace MediaBrowser.Controller.Resolvers // Ignore any folders containing a file called .ignore resolve = false; } - else if (args.IsMetadataFolder) - { - // I think this is redundant, but... - resolve = false; - } return resolve; } diff --git a/MediaBrowser.Controller/Resolvers/FolderResolver.cs b/MediaBrowser.Controller/Resolvers/FolderResolver.cs index b34d8163b..408e513d4 100644 --- a/MediaBrowser.Controller/Resolvers/FolderResolver.cs +++ b/MediaBrowser.Controller/Resolvers/FolderResolver.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Resolvers protected override Folder Resolve(ItemResolveEventArgs args) { - if (args.IsDirectory && !args.IsMetadataFolder) + if (args.IsDirectory) { return new Folder() { PhysicalLocations = args.PhysicalLocations }; } diff --git a/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs b/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs index d01e1ce31..0ad0782e0 100644 --- a/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs +++ b/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs @@ -10,15 +10,12 @@ namespace MediaBrowser.Controller.Resolvers.TV { protected override Season Resolve(ItemResolveEventArgs args) { - if (args.Parent is Series && args.IsDirectory && !args.IsMetadataFolder) + if (args.Parent is Series && args.IsDirectory) { var season = new Season { }; season.IndexNumber = TVUtils.GetSeasonNumberFromPath(args.Path); - // Gather these now so that the episode provider classes can utilize them instead of having to make their own file system calls - season.MetadataFiles = args.ContainsFolder("metadata") ? Directory.GetFiles(Path.Combine(args.Path, "metadata"), "*", SearchOption.TopDirectoryOnly) : new string[] { }; - return season; }