From 999ad78a0d899c4b9a441933ff68843b0ae3e0a9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 29 Nov 2014 14:51:30 -0500 Subject: rework configurations --- .../Library/ResolverHelper.cs | 27 ++++++------ .../Library/Resolvers/BaseVideoResolver.cs | 50 +++++++++++++++++++--- .../Library/Resolvers/Movies/BoxSetResolver.cs | 6 ++- .../Library/Resolvers/Movies/MovieResolver.cs | 17 ++++---- .../Library/Resolvers/PlaylistResolver.cs | 6 ++- .../Library/Resolvers/TV/SeriesResolver.cs | 6 ++- 6 files changed, 81 insertions(+), 31 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library') diff --git a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs index b9fbd6f8c4..92c8379322 100644 --- a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs +++ b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs @@ -56,43 +56,40 @@ namespace MediaBrowser.Server.Implementations.Library /// Ensures the name. /// /// The item. + /// The arguments. private static void EnsureName(BaseItem item, ItemResolveArgs args) { // If the subclass didn't supply a name, add it here if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path)) { //we use our resolve args name here to get the name of the containg folder, not actual video file - item.Name = GetMbName(args.FileInfo.Name, (args.FileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory); + item.Name = GetDisplayName(args.FileInfo.Name, (args.FileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory); } } /// - /// The MB name regex - /// - private static readonly Regex MbNameRegex = new Regex(@"(\[.*?\])", RegexOptions.Compiled); - - /// - /// Strip out attribute items and return just the name we will use for items + /// Gets the display name. /// - /// Assumed to be a file or directory path + /// The path. /// if set to true [is directory]. - /// The cleaned name - private static string GetMbName(string path, bool isDirectory) + /// System.String. + private static string GetDisplayName(string path, bool isDirectory) { //first just get the file or directory name var fn = isDirectory ? Path.GetFileName(path) : Path.GetFileNameWithoutExtension(path); - //now - strip out anything inside brackets - fn = StripBrackets(fn); - return fn; } - private static string StripBrackets(string inputString) + /// + /// The MB name regex + /// + private static readonly Regex MbNameRegex = new Regex(@"(\[.*?\])", RegexOptions.Compiled); + + internal static string StripBrackets(string inputString) { var output = MbNameRegex.Replace(inputString, string.Empty).Trim(); return Regex.Replace(output, @"\s+", " "); } - } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs index f6d33079b9..35519b9321 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs @@ -1,10 +1,9 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; -using MediaBrowser.Naming.Audio; using MediaBrowser.Naming.Common; -using MediaBrowser.Naming.Video; using System; +using System.IO; namespace MediaBrowser.Server.Implementations.Library.Resolvers { @@ -29,7 +28,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers /// `0. protected override T Resolve(ItemResolveArgs args) { - return ResolveVideo(args); + return ResolveVideo(args, true); } /// @@ -37,8 +36,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers /// /// The type of the T video type. /// The args. + /// if set to true [parse name]. /// ``0. - protected TVideoType ResolveVideo(ItemResolveArgs args) + protected TVideoType ResolveVideo(ItemResolveArgs args, bool parseName) where TVideoType : Video, new() { // If the path is a file check for a matching extensions @@ -69,10 +69,18 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers IsInMixedFolder = true, IsPlaceHolder = videoInfo.IsStub, IsShortcut = isShortcut, - Name = videoInfo.Name, ProductionYear = videoInfo.Year }; + if (parseName) + { + video.Name = videoInfo.Name; + } + else + { + video.Name = Path.GetFileNameWithoutExtension(path); + } + if (videoInfo.IsStub) { if (string.Equals(videoInfo.StubType, "dvd", StringComparison.OrdinalIgnoreCase)) @@ -89,6 +97,38 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers } } + if (videoInfo.Is3D) + { + if (string.Equals(videoInfo.Format3D, "fsbs", StringComparison.OrdinalIgnoreCase)) + { + video.Video3DFormat = Video3DFormat.FullSideBySide; + } + else if (string.Equals(videoInfo.Format3D, "ftab", StringComparison.OrdinalIgnoreCase)) + { + video.Video3DFormat = Video3DFormat.FullTopAndBottom; + } + else if (string.Equals(videoInfo.Format3D, "hsbs", StringComparison.OrdinalIgnoreCase)) + { + video.Video3DFormat = Video3DFormat.HalfSideBySide; + } + else if (string.Equals(videoInfo.Format3D, "htab", StringComparison.OrdinalIgnoreCase)) + { + video.Video3DFormat = Video3DFormat.HalfTopAndBottom; + } + else if (string.Equals(videoInfo.Format3D, "sbs", StringComparison.OrdinalIgnoreCase)) + { + video.Video3DFormat = Video3DFormat.HalfSideBySide; + } + else if (string.Equals(videoInfo.Format3D, "sbs3d", StringComparison.OrdinalIgnoreCase)) + { + video.Video3DFormat = Video3DFormat.HalfSideBySide; + } + else if (string.Equals(videoInfo.Format3D, "tab", StringComparison.OrdinalIgnoreCase)) + { + video.Video3DFormat = Video3DFormat.HalfTopAndBottom; + } + } + return video; } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs index 1416bd04ea..7f9b16d950 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs @@ -40,7 +40,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies if (filename.IndexOf("[boxset]", StringComparison.OrdinalIgnoreCase) != -1 || args.ContainsFileSystemEntryByName("collection.xml")) { - return new BoxSet { Path = args.Path }; + return new BoxSet + { + Path = args.Path, + Name = ResolverHelper.StripBrackets(Path.GetFileName(args.Path)) + }; } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index a2da9ff775..c928c5e656 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -8,13 +8,12 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Resolvers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Naming.Common; +using MediaBrowser.Naming.Video; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using MediaBrowser.Naming.Audio; -using MediaBrowser.Naming.Common; -using MediaBrowser.Naming.Video; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies { @@ -116,14 +115,14 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies // Find movies that are mixed in the same folder if (string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase)) { - return ResolveVideo(args); + return ResolveVideo(args, true); } Video item = null; if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { - item = ResolveVideo(args); + item = ResolveVideo(args, true); } // To find a movie file, the collection type must be movies or boxsets @@ -131,7 +130,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) { - item = ResolveVideo(args); + item = ResolveVideo(args, true); } if (item != null) @@ -180,8 +179,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies /// The file system entries. /// The directory service. /// if set to true [support multi file items]. + /// if set to true [supports multiple sources]. + /// Type of the collection. /// Movie. - private T FindMovie(string path, Folder parent, List fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems, bool supportsMultipleSources, string collectionType) + private T FindMovie(string path, Folder parent, IEnumerable fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems, bool supportsMultipleSources, string collectionType) where T : Video, new() { var movies = new List(); @@ -231,7 +232,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies CollectionType = collectionType }; - var item = ResolveVideo(childArgs); + var item = ResolveVideo(childArgs, true); if (item != null) { diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PlaylistResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PlaylistResolver.cs index 7eff53ce1f..a95739f227 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/PlaylistResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PlaylistResolver.cs @@ -28,7 +28,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers if (filename.IndexOf("[playlist]", StringComparison.OrdinalIgnoreCase) != -1) { - return new Playlist { Path = args.Path }; + return new Playlist + { + Path = args.Path, + Name = ResolverHelper.StripBrackets(Path.GetFileName(args.Path)) + }; } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs index 30eaf3198d..52a95a3002 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs @@ -81,7 +81,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV if (IsSeriesFolder(args.Path, isTvShowsFolder, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager)) { - return new Series(); + return new Series + { + Path = args.Path, + Name = ResolverHelper.StripBrackets(Path.GetFileName(args.Path)) + }; } } -- cgit v1.2.3