add support to movie names with dot notation

This commit is contained in:
Luis Miguel Almánzar 2013-10-28 20:35:01 -04:00
parent e7a1f52373
commit d77122ba0f
3 changed files with 43 additions and 1 deletions

View File

@ -189,6 +189,7 @@ namespace MediaBrowser.Providers.Movies
static readonly Regex[] NameMatches = new[] {
new Regex(@"(?<name>.*)\((?<year>\d{4})\)"), // matches "My Movie (2001)" and gives us the name and the year
new Regex(@"(?<name>.*)(\.(?<year>\d{4})(\.|$)).*$"),
new Regex(@"(?<name>.*)") // last resort matches the whole string as the name
};
@ -320,7 +321,7 @@ namespace MediaBrowser.Providers.Movies
/// <param name="name">The name.</param>
/// <param name="justName">Name of the just.</param>
/// <param name="year">The year.</param>
protected void ParseName(string name, out string justName, out int? year)
public static void ParseName(string name, out string justName, out int? year)
{
justName = null;
year = null;

View File

@ -50,6 +50,7 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Providers\MovieDbProviderTests.cs" />
<Compile Include="Resolvers\MovieResolverTests.cs" />
<Compile Include="Resolvers\TvUtilTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -63,6 +64,10 @@
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Providers\MediaBrowser.Providers.csproj">
<Project>{442B5058-DCAF-4263-BB6A-F21E31120A1B}</Project>
<Name>MediaBrowser.Providers</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">

View File

@ -0,0 +1,36 @@
using MediaBrowser.Providers.Movies;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MediaBrowser.Tests.Providers {
[TestClass]
public class MovieDbProviderTests {
[TestMethod]
public void TestNameMatches() {
var name = string.Empty;
int? year = null;
MovieDbProvider.ParseName("My Movie (2013)", out name, out year);
Assert.AreEqual("My Movie", name);
Assert.AreEqual(2013, year);
name = string.Empty;
year = null;
MovieDbProvider.ParseName("My Movie 2 (2013)", out name, out year);
Assert.AreEqual("My Movie 2", name);
Assert.AreEqual(2013, year);
name = string.Empty;
year = null;
MovieDbProvider.ParseName("My Movie 2001 (2013)", out name, out year);
Assert.AreEqual("My Movie 2001", name);
Assert.AreEqual(2013, year);
name = string.Empty;
year = null;
MovieDbProvider.ParseName("My Movie - 2 (2013)", out name, out year);
Assert.AreEqual("My Movie - 2", name);
Assert.AreEqual(2013, year);
name = string.Empty;
year = null;
MovieDbProvider.ParseName("curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", out name, out year);
Assert.AreEqual("curse.of.chucky", name);
Assert.AreEqual(2013, year);
}
}
}