strip only certain bracket blocks fixes #598

This commit is contained in:
Luis Miguel Almánzar
2013-11-02 21:19:33 -04:00
parent ab490d7467
commit 8a0606e970
3 changed files with 29 additions and 2 deletions

View File

@@ -71,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <summary>
/// The MB name regex
/// </summary>
private static readonly Regex MBNameRegex = new Regex("(\\[.*\\])", RegexOptions.Compiled);
private static readonly Regex MBNameRegex = new Regex(@"(\[boxset\]|\[tmdbid=\d+\]|\[tvdbid=\d+\])", RegexOptions.Compiled);
/// <summary>
/// Strip out attribute items and return just the name we will use for items
@@ -85,10 +85,15 @@ namespace MediaBrowser.Server.Implementations.Library
var fn = isDirectory ? Path.GetFileName(path) : Path.GetFileNameWithoutExtension(path);
//now - strip out anything inside brackets
fn = MBNameRegex.Replace(fn, string.Empty);
fn = StripBrackets(fn);
return fn;
}
public static string StripBrackets(string inputString) {
var output = MBNameRegex.Replace(inputString, string.Empty).Trim();
return Regex.Replace(output, @"\s+", " ");
}
}
}