mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
strip only certain bracket blocks fixes #598
This commit is contained in:
parent
ab490d7467
commit
8a0606e970
@ -71,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The MB name regex
|
/// The MB name regex
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Strip out attribute items and return just the name we will use for items
|
/// 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);
|
var fn = isDirectory ? Path.GetFileName(path) : Path.GetFileNameWithoutExtension(path);
|
||||||
|
|
||||||
//now - strip out anything inside brackets
|
//now - strip out anything inside brackets
|
||||||
fn = MBNameRegex.Replace(fn, string.Empty);
|
fn = StripBrackets(fn);
|
||||||
|
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string StripBrackets(string inputString) {
|
||||||
|
var output = MBNameRegex.Replace(inputString, string.Empty).Trim();
|
||||||
|
return Regex.Replace(output, @"\s+", " ");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
<Compile Include="Resolvers\MovieResolverTests.cs" />
|
<Compile Include="Resolvers\MovieResolverTests.cs" />
|
||||||
<Compile Include="Resolvers\TvUtilTests.cs" />
|
<Compile Include="Resolvers\TvUtilTests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Server.Implementations\Library\ResolverHelperTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj">
|
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj">
|
||||||
@ -68,6 +69,10 @@
|
|||||||
<Project>{442B5058-DCAF-4263-BB6A-F21E31120A1B}</Project>
|
<Project>{442B5058-DCAF-4263-BB6A-F21E31120A1B}</Project>
|
||||||
<Name>MediaBrowser.Providers</Name>
|
<Name>MediaBrowser.Providers</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj">
|
||||||
|
<Project>{2E781478-814D-4A48-9D80-BFF206441A65}</Project>
|
||||||
|
<Name>MediaBrowser.Server.Implementations</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
using MediaBrowser.Server.Implementations.Library;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Tests.Server.Implementations.Library {
|
||||||
|
[TestClass]
|
||||||
|
public class ResolverHelperTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void TestStripBrackets()
|
||||||
|
{
|
||||||
|
Assert.AreEqual("My Movie [blah blah]", ResolverHelper.StripBrackets("My Movie [boxset] [blah blah]"));
|
||||||
|
Assert.AreEqual("[tag1] file 01", ResolverHelper.StripBrackets("[tag1] file 01 [tvdbid=12345]"));
|
||||||
|
Assert.AreEqual("[tag1] file 01", ResolverHelper.StripBrackets("[tag1] file 01 [tmdbid=12345]"));
|
||||||
|
Assert.AreEqual("[tag1] file 01", ResolverHelper.StripBrackets("[tag1] file [boxset] [tvdbid=12345] 01 [tmdbid=12345]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user