From 612b7e55d25131fc92e3bb5e035511409c97946c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 15 Aug 2013 11:25:51 -0400 Subject: [PATCH] prep work for multiple movies in folder support --- .../MediaInfo/FFProbeAudioInfoProvider.cs | 5 +- .../MediaInfo/FFProbeVideoInfoProvider.cs | 6 +- .../Library/Resolvers/Movies/MovieResolver.cs | 56 +++++++++++-------- .../MediaEncoder/MediaEncoder.cs | 4 +- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs index 8b59291a30..9f89300aed 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; -using MediaBrowser.Common.IO; -using MediaBrowser.Common.MediaInfo; +using MediaBrowser.Common.MediaInfo; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -11,6 +9,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Threading.Tasks; namespace MediaBrowser.Providers.MediaInfo { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs index 43ce4cd408..2a3cbcd845 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs @@ -1,10 +1,7 @@ -using System.Globalization; -using MediaBrowser.Common.IO; -using MediaBrowser.Common.MediaInfo; +using MediaBrowser.Common.MediaInfo; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Providers; @@ -15,6 +12,7 @@ using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Threading; diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 492e410ecc..c10db1bfae 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -48,35 +48,45 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies /// Video. protected override Video Resolve(ItemResolveArgs args) { - // Must be a directory - if (args.IsDirectory) + // Avoid expensive tests against VF's and all their children by not allowing this + if (args.Parent != null) { - // Avoid expensive tests against VF's and all their children by not allowing this - if (args.Parent != null) - { - if (args.Parent.IsRoot) - { - return null; - } - - // If the parent is not a boxset, the only other allowed parent type is Folder - if (!(args.Parent is BoxSet)) - { - if (args.Parent.GetType() != typeof(Folder)) - { - return null; - } - } - } - - // Since the looping is expensive, this is an optimization to help us avoid it - if (args.ContainsMetaFileByName("series.xml") || args.Path.IndexOf("[tvdbid", StringComparison.OrdinalIgnoreCase) != -1) + if (args.Parent.IsRoot) { return null; } - var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent); + // If the parent is not a boxset, the only other allowed parent type is Folder + if (!(args.Parent is BoxSet)) + { + if (args.Parent.GetType() != typeof(Folder)) + { + return null; + } + } + } + // Since the looping is expensive, this is an optimization to help us avoid it + if (args.Path.IndexOf("[tvdbid", StringComparison.OrdinalIgnoreCase) != -1) + { + return null; + } + + var isDirectory = args.IsDirectory; + + if (isDirectory) + { + // Since the looping is expensive, this is an optimization to help us avoid it + if (args.ContainsMetaFileByName("series.xml")) + { + return null; + } + } + + var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent); + + if (isDirectory) + { if (args.Path.IndexOf("[trailers]", StringComparison.OrdinalIgnoreCase) != -1 || string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase)) { diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index 51ca6d3bdf..f5b5ea6c07 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs @@ -1,5 +1,4 @@ -using System.Globalization; -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.MediaInfo; using MediaBrowser.Model.Entities; @@ -10,6 +9,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Reflection;