From beeb5204b825f669083cfff56e6a581d0737b5b5 Mon Sep 17 00:00:00 2001 From: Vincent Caron Date: Tue, 8 Oct 2024 17:49:55 +0200 Subject: [PATCH] New: Parse IMDB and TMDB URLs as search terms --- .../SkyHook/SkyHookProxySearchFixture.cs | 4 ++++ .../MetadataSource/SkyHook/SkyHookProxy.cs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs index 4ae0b066d..2371d7fb5 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs @@ -23,6 +23,8 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook // [TestCase("The Man from U.N.C.L.E.", "The Man from U.N.C.L.E.")] [TestCase("imdb:tt2527336", "Star Wars: The Last Jedi")] [TestCase("imdb:tt2798920", "Annihilation")] + [TestCase("https://www.imdb.com/title/tt0033467/", "Citizen Kane")] + [TestCase("https://www.themoviedb.org/movie/775-le-voyage-dans-la-lune", "A Trip to the Moon")] public void successful_search(string title, string expected) { var result = Subject.SearchForNewMovie(title); @@ -41,6 +43,8 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook [TestCase("tmdbid:1")] [TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")] [TestCase("imdb: tt9805708")] + [TestCase("https://www.UNKNOWN-DOMAIN.com/title/tt0033467/")] + [TestCase("https://www.themoviedb.org/MALFORMED/775-le-voyage-dans-la-lune")] public void no_search_result(string term) { var result = Subject.SearchForNewMovie(term); diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index df46ed115..2cf794c87 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Net; +using System.Text.RegularExpressions; using Newtonsoft.Json; using NLog; using NzbDrone.Common.Cloud; @@ -405,6 +406,20 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { try { + var match = new Regex("^https://www.imdb.com/title/(tt[0-9]+).*?$").Match(title); + if (match.Success) + { + title = "imdb:" + match.Groups[1].Value; + } + else + { + match = new Regex("^https://www.themoviedb.org/movie/([0-9]+).*$").Match(title); + if (match.Success) + { + title = "tmdb:" + match.Groups[1].Value; + } + } + var lowerTitle = title.ToLower(); lowerTitle = lowerTitle.Replace(".", "");