diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index 9ed0860b2..63a237d2c 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -189,6 +189,7 @@ namespace MediaBrowser.Providers.Movies static readonly Regex[] NameMatches = new[] { new Regex(@"(?.*)\((?\d{4})\)"), // matches "My Movie (2001)" and gives us the name and the year + new Regex(@"(?.*)(\.(?\d{4})(\.|$)).*$"), new Regex(@"(?.*)") // last resort matches the whole string as the name }; @@ -320,7 +321,7 @@ namespace MediaBrowser.Providers.Movies /// The name. /// Name of the just. /// The year. - 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; diff --git a/MediaBrowser.Tests/MediaBrowser.Tests.csproj b/MediaBrowser.Tests/MediaBrowser.Tests.csproj index a7a7ac243..95e55fda0 100644 --- a/MediaBrowser.Tests/MediaBrowser.Tests.csproj +++ b/MediaBrowser.Tests/MediaBrowser.Tests.csproj @@ -50,6 +50,7 @@ + @@ -63,6 +64,10 @@ {7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b} MediaBrowser.Model + + {442B5058-DCAF-4263-BB6A-F21E31120A1B} + MediaBrowser.Providers + diff --git a/MediaBrowser.Tests/Providers/MovieDbProviderTests.cs b/MediaBrowser.Tests/Providers/MovieDbProviderTests.cs new file mode 100644 index 000000000..f7a87c9d4 --- /dev/null +++ b/MediaBrowser.Tests/Providers/MovieDbProviderTests.cs @@ -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); + } + } +} \ No newline at end of file