diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index d7cf00372..515d321f5 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -120,6 +120,15 @@ public void should_parse_movie_year(string postTitle, int year) Parser.Parser.ParseMovieTitle(postTitle).Year.Should().Be(year); } + [TestCase("Ghostbusters (2016) {tmdbid-43074}", 43074)] + [TestCase("Ghostbusters (2016) [tmdb-43074]", 43074)] + [TestCase("Ghostbusters (2016) {tmdb-43074}", 43074)] + [TestCase("Ghostbusters (2016) {tmdb-2020}", 2020)] + public void should_parse_tmdb_id(string postTitle, int tmdbId) + { + Parser.Parser.ParseMovieTitle(postTitle).TmdbId.Should().Be(tmdbId); + } + [TestCase("Prometheus 2012 Directors Cut", "Directors Cut")] [TestCase("Star Wars Episode IV - A New Hope 1999 (Despecialized).mkv", "Despecialized")] [TestCase("Prometheus.2012.(Special.Edition.Remastered).[Bluray-1080p].mkv", "Special Edition Remastered")] diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index b517acbe5..ca7189684 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -336,6 +336,19 @@ public List SearchForNewMovie(string title) return new List(); } } + + if (parserResult.TmdbId > 0) + { + try + { + var movieLookup = GetMovieInfo(parserResult.TmdbId).Item1; + return movieLookup == null ? new List() : new List { _movieService.FindByTmdbId(movieLookup.TmdbId) ?? movieLookup }; + } + catch (Exception) + { + return new List(); + } + } } parserTitle = StripTrailingTheFromTitle(parserTitle); diff --git a/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs index b7d9f3120..d24f2f4ea 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs @@ -18,6 +18,7 @@ public class ParsedMovieInfo public string Edition { get; set; } public int Year { get; set; } public string ImdbId { get; set; } + public int TmdbId { get; set; } [JsonIgnore] public Dictionary ExtraInfo { get; set; } = new Dictionary(); diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 077bee98f..df76048bf 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -91,6 +91,7 @@ public static class Parser RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex ReportImdbId = new Regex(@"(?tt\d{7,8})", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex ReportTmdbId = new Regex(@"tmdb(id)?-(?\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly RegexReplace SimpleTitleRegex = new RegexReplace(@"\s*(?:480[ip]|576[ip]|720[ip]|1080[ip]|2160[ip]|[xh][\W_]?26[45]|DD\W?5\W1|[<>?*:|]|848x480|1280x720|1920x1080|(8|10)b(it)?)", string.Empty, @@ -274,6 +275,7 @@ public static ParsedMovieInfo ParseMovieTitle(string title, bool isDir = false) result.SimpleReleaseTitle = simpleReleaseTitle; result.ImdbId = ParseImdbId(simpleReleaseTitle); + result.TmdbId = ParseTmdbId(simpleReleaseTitle); return result; } @@ -315,6 +317,20 @@ public static string ParseImdbId(string title) return ""; } + public static int ParseTmdbId(string title) + { + var match = ReportTmdbId.Match(title); + if (match.Success) + { + if (match.Groups["tmdbid"].Value != null) + { + return int.TryParse(match.Groups["tmdbid"].Value, out var tmdbId) ? tmdbId : 0; + } + } + + return 0; + } + public static string ParseEdition(string languageTitle) { var editionMatch = ReportEditionRegex.Match(languageTitle); @@ -522,8 +538,7 @@ private static ParsedMovieInfo ParseMovieMatchCollection(MatchCollection matchCo movieName = movieName.Trim(' '); - int airYear; - int.TryParse(matchCollection[0].Groups["year"].Value, out airYear); + int.TryParse(matchCollection[0].Groups["year"].Value, out var airYear); ParsedMovieInfo result;