From 64e8fde0e1881cd8a61e34619c85e4334da291f8 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Tue, 11 Sep 2018 23:47:00 +0200 Subject: [PATCH] Fixed: ImdbIds not being padded with zeroes, which messes up matching. --- src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs | 10 ++++++++++ src/NzbDrone.Core/Parser/Parser.cs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index f2c4be9ee..71e1b1d39 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -124,5 +124,15 @@ namespace NzbDrone.Core.Test.ParserTests { Parser.Parser.ParseMinimalMovieTitle(postTitle, foundTitle, 1290).Edition.Should().Be(edition); } + + [TestCase("123", "tt0000123")] + [TestCase("1234567", "tt1234567")] + [TestCase("tt1234567", "tt1234567")] + [TestCase("tt12345678", "tt12345678")] + [TestCase("12345678", "tt12345678")] + public void should_normalize_imdbid(string imdbid, string normalized) + { + Parser.Parser.NormalizeImdbId(imdbid).Should().BeEquivalentTo(normalized); + } } } diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index e88272b20..b296c2918 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -352,7 +352,8 @@ namespace NzbDrone.Core.Parser { if (imdbId.Length > 2) { - return (imdbId.Substring(0,2) != "tt" ? $"tt{imdbId}" : imdbId); + imdbId = imdbId.Replace("tt", "").PadLeft(7, '0'); + return $"tt{imdbId}"; } return null;