diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-11-29 14:51:30 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-11-29 14:51:30 -0500 |
| commit | 999ad78a0d899c4b9a441933ff68843b0ae3e0a9 (patch) | |
| tree | 63d2bbc8504595b1c47e36f5e3c16e3fc51b671e /MediaBrowser.Server.Implementations/Library | |
| parent | aaac7e4208a1098bccdc5a7d4c939ef30a3a1e9f (diff) | |
rework configurations
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
6 files changed, 81 insertions, 31 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs index b9fbd6f8c..92c837932 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. /// </summary> /// <param name="item">The item.</param> + /// <param name="args">The arguments.</param> 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); } } /// <summary> - /// The MB name regex - /// </summary> - private static readonly Regex MbNameRegex = new Regex(@"(\[.*?\])", RegexOptions.Compiled); - - /// <summary> - /// Strip out attribute items and return just the name we will use for items + /// Gets the display name. /// </summary> - /// <param name="path">Assumed to be a file or directory path</param> + /// <param name="path">The path.</param> /// <param name="isDirectory">if set to <c>true</c> [is directory].</param> - /// <returns>The cleaned name</returns> - private static string GetMbName(string path, bool isDirectory) + /// <returns>System.String.</returns> + 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) + /// <summary> + /// The MB name regex + /// </summary> + 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 f6d33079b..35519b932 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 /// <returns>`0.</returns> protected override T Resolve(ItemResolveArgs args) { - return ResolveVideo<T>(args); + return ResolveVideo<T>(args, true); } /// <summary> @@ -37,8 +36,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers /// </summary> /// <typeparam name="TVideoType">The type of the T video type.</typeparam> /// <param name="args">The args.</param> + /// <param name="parseName">if set to <c>true</c> [parse name].</param> /// <returns>``0.</returns> - protected TVideoType ResolveVideo<TVideoType>(ItemResolveArgs args) + protected TVideoType ResolveVideo<TVideoType>(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 1416bd04e..7f9b16d95 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 a2da9ff77..c928c5e65 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<Trailer>(args); + return ResolveVideo<Trailer>(args, true); } Video item = null; if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { - item = ResolveVideo<MusicVideo>(args); + item = ResolveVideo<MusicVideo>(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<Movie>(args); + item = ResolveVideo<Movie>(args, true); } if (item != null) @@ -180,8 +179,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies /// <param name="fileSystemEntries">The file system entries.</param> /// <param name="directoryService">The directory service.</param> /// <param name="supportMultiFileItems">if set to <c>true</c> [support multi file items].</param> + /// <param name="supportsMultipleSources">if set to <c>true</c> [supports multiple sources].</param> + /// <param name="collectionType">Type of the collection.</param> /// <returns>Movie.</returns> - private T FindMovie<T>(string path, Folder parent, List<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems, bool supportsMultipleSources, string collectionType) + private T FindMovie<T>(string path, Folder parent, IEnumerable<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems, bool supportsMultipleSources, string collectionType) where T : Video, new() { var movies = new List<T>(); @@ -231,7 +232,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies CollectionType = collectionType }; - var item = ResolveVideo<T>(childArgs); + var item = ResolveVideo<T>(childArgs, true); if (item != null) { diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PlaylistResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PlaylistResolver.cs index 7eff53ce1..a95739f22 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 30eaf3198..52a95a300 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)) + }; } } |
