From 2c563ac92f28fbe6804219ace6a1767f88ac52cd Mon Sep 17 00:00:00 2001 From: ebr11 Eric Reed spam Date: Tue, 18 Sep 2012 17:07:01 -0400 Subject: [PATCH] Hopefully the last of dealing with the metadata folder --- .../IO/FileSystemHelper.cs | 33 +++++++++++++++++ MediaBrowser.Controller/Kernel.cs | 4 +-- .../Library/ItemResolveEventArgs.cs | 8 +++++ .../Resolvers/EntityResolutionHelper.cs | 5 +++ .../Resolvers/FolderResolver.cs | 2 +- .../Resolvers/TV/SeasonResolver.cs | 2 +- .../Resolvers/TV/TVUtils.cs | 2 +- .../Resolvers/VideoResolver.cs | 36 ++----------------- 8 files changed, 53 insertions(+), 39 deletions(-) diff --git a/MediaBrowser.Controller/IO/FileSystemHelper.cs b/MediaBrowser.Controller/IO/FileSystemHelper.cs index cafd64fcf..2897150a8 100644 --- a/MediaBrowser.Controller/IO/FileSystemHelper.cs +++ b/MediaBrowser.Controller/IO/FileSystemHelper.cs @@ -83,5 +83,38 @@ namespace MediaBrowser.Controller.IO return args; } + public static bool IsVideoFile(string path) + { + string extension = System.IO.Path.GetExtension(path).ToLower(); + + switch (extension) + { + case ".mkv": + case ".m2ts": + case ".iso": + case ".ts": + case ".rmvb": + case ".mov": + case ".avi": + case ".mpg": + case ".mpeg": + case ".wmv": + case ".mp4": + case ".divx": + case ".dvr-ms": + case ".wtv": + case ".ogm": + case ".ogv": + case ".asf": + case ".m4v": + case ".flv": + case ".f4v": + case ".3gp": + return true; + + default: + return false; + } + } } } diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index 1daa43dcd..c61473784 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -200,10 +200,10 @@ namespace MediaBrowser.Controller DirectoryWatchers.Start(); //Task.Delay(30000); //let's wait and see if more data gets filled in... var allChildren = RootFolder.RecursiveChildren; - Logger.LogInfo(string.Format("Loading complete. Movies: {0} Episodes: {1}", allChildren.OfType().Count(), allChildren.OfType().Count())); + Logger.LogDebugInfo(string.Format("Loading complete. Movies: {0} Episodes: {1} Folders: {2}", allChildren.OfType().Count(), allChildren.OfType().Count(), allChildren.Where(i => i is Folder && !(i is Series || i is Season)).Count())); foreach (var child in allChildren) { - Logger.LogDebugInfo("(" + child.GetType().Name + ") " + child.Name + " Overview " + (child.Overview != null ? child.Overview.Substring(0,Math.Min(25,child.Overview.Length)): "") + " (" + child.Path + ")"); + Logger.LogDebugInfo("(" + child.GetType().Name + ") " + child.Name + " (" + child.Path + ")"); } } diff --git a/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs b/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs index 0a7c29d06..02cffcf0f 100644 --- a/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveEventArgs.cs @@ -39,6 +39,14 @@ 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); + } + } + public WIN32_FIND_DATA? GetFileSystemEntry(string path) { WIN32_FIND_DATA entry = FileSystemChildren.FirstOrDefault(f => f.Path.Equals(path, StringComparison.OrdinalIgnoreCase)); diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs index 5b1365c6d..043453bc0 100644 --- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs +++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs @@ -62,6 +62,11 @@ namespace MediaBrowser.Controller.Resolvers // Ignore any folders containing a file called .ignore resolve = false; } + else if (args.IsMetadataFolder) + { + // Don't retrieve these children here - we'll get them in the season resolver + resolve = false; + } return resolve; } diff --git a/MediaBrowser.Controller/Resolvers/FolderResolver.cs b/MediaBrowser.Controller/Resolvers/FolderResolver.cs index 3c6083c5d..b34d8163b 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.FileInfo.cFileName.Equals("metadata",System.StringComparison.OrdinalIgnoreCase)) + if (args.IsDirectory && !args.IsMetadataFolder) { return new Folder() { PhysicalLocations = args.PhysicalLocations }; } diff --git a/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs b/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs index 528a55ae4..d01e1ce31 100644 --- a/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs +++ b/MediaBrowser.Controller/Resolvers/TV/SeasonResolver.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Resolvers.TV { protected override Season Resolve(ItemResolveEventArgs args) { - if (args.Parent is Series && args.IsDirectory) + if (args.Parent is Series && args.IsDirectory && !args.IsMetadataFolder) { var season = new Season { }; diff --git a/MediaBrowser.Controller/Resolvers/TV/TVUtils.cs b/MediaBrowser.Controller/Resolvers/TV/TVUtils.cs index c40f3fa63..ec3305e16 100644 --- a/MediaBrowser.Controller/Resolvers/TV/TVUtils.cs +++ b/MediaBrowser.Controller/Resolvers/TV/TVUtils.cs @@ -128,7 +128,7 @@ namespace MediaBrowser.Controller.Resolvers.TV } else { - if (!string.IsNullOrEmpty(EpisodeNumberFromFile(child.Path, false))) + if (FileSystemHelper.IsVideoFile(child.Path) && !string.IsNullOrEmpty(EpisodeNumberFromFile(child.Path, false))) { return true; } diff --git a/MediaBrowser.Controller/Resolvers/VideoResolver.cs b/MediaBrowser.Controller/Resolvers/VideoResolver.cs index e162fa509..bc3be5e43 100644 --- a/MediaBrowser.Controller/Resolvers/VideoResolver.cs +++ b/MediaBrowser.Controller/Resolvers/VideoResolver.cs @@ -1,6 +1,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; +using MediaBrowser.Controller.IO; using System.ComponentModel.Composition; using System.IO; @@ -29,7 +30,7 @@ namespace MediaBrowser.Controller.Resolvers // If the path is a file check for a matching extensions if (!args.IsDirectory) { - if (IsVideoFile(args.Path)) + if (FileSystemHelper.IsVideoFile(args.Path)) { VideoType type = Path.GetExtension(args.Path).EndsWith("iso", System.StringComparison.OrdinalIgnoreCase) ? VideoType.Iso : VideoType.VideoFile; @@ -95,38 +96,5 @@ namespace MediaBrowser.Controller.Resolvers return null; } - private static bool IsVideoFile(string path) - { - string extension = Path.GetExtension(path).ToLower(); - - switch (extension) - { - case ".mkv": - case ".m2ts": - case ".iso": - case ".ts": - case ".rmvb": - case ".mov": - case ".avi": - case ".mpg": - case ".mpeg": - case ".wmv": - case ".mp4": - case ".divx": - case ".dvr-ms": - case ".wtv": - case ".ogm": - case ".ogv": - case ".asf": - case ".m4v": - case ".flv": - case ".f4v": - case ".3gp": - return true; - - default: - return false; - } - } } }