add support to movie names with dot notation

pull/702/head
Luis Miguel Almánzar 11 years ago
parent e7a1f52373
commit d77122ba0f

@ -189,6 +189,7 @@ namespace MediaBrowser.Providers.Movies
static readonly Regex[] NameMatches = new[] { 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})\)"), // 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 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="name">The name.</param>
/// <param name="justName">Name of the just.</param> /// <param name="justName">Name of the just.</param>
/// <param name="year">The year.</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; justName = null;
year = null; year = null;

@ -50,6 +50,7 @@
</Otherwise> </Otherwise>
</Choose> </Choose>
<ItemGroup> <ItemGroup>
<Compile Include="Providers\MovieDbProviderTests.cs" />
<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" />
@ -63,6 +64,10 @@
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project> <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name> <Name>MediaBrowser.Model</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\MediaBrowser.Providers\MediaBrowser.Providers.csproj">
<Project>{442B5058-DCAF-4263-BB6A-F21E31120A1B}</Project>
<Name>MediaBrowser.Providers</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,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);
}
}
}
Loading…
Cancel
Save