diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/ResolverHelper.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/ResolverHelper.cs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs index b9fbd6f8c..d071fd232 100644 --- a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs +++ b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.IO; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using System; @@ -20,7 +19,7 @@ namespace MediaBrowser.Server.Implementations.Library /// <param name="item">The item.</param> /// <param name="args">The args.</param> /// <param name="fileSystem">The file system.</param> - public static void SetInitialItemValues(BaseItem item, ItemResolveArgs args, IFileSystem fileSystem) + public static void SetInitialItemValues(BaseItem item, ItemResolveArgs args, IFileSystem fileSystem, ILibraryManager libraryManager) { // If the resolver didn't specify this if (string.IsNullOrEmpty(item.Path)) @@ -34,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library item.Parent = args.Parent; } - item.Id = item.Path.GetMBId(item.GetType()); + item.Id = libraryManager.GetNewItemId(item.Path, item.GetType()); // If the resolver didn't specify this if (string.IsNullOrEmpty(item.DisplayMediaType)) @@ -56,43 +55,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+", " "); } - } } |
