diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs index e7bef59a2..ebe3a88a5 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxySearchFixture.cs @@ -108,6 +108,8 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook [TestCase("Eminem", 0, typeof(Artist), "Eminem")] [TestCase("Eminem Kamikaze", 0, typeof(Artist), "Eminem")] [TestCase("Eminem Kamikaze", 1, typeof(Album), "Kamikaze")] + [TestCase("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419", 0, typeof(Artist), "Linkin Park")] + [TestCase("lidarr: d77df681-b779-3d6d-b66a-3bfd15985e3e", 0, typeof(Album), "Pyromania")] public void successful_combined_search(string query, int position, Type resultType, string expected) { var result = Subject.SearchForNewEntity(query); diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 6074f81a2..11f19551b 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -186,7 +186,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { var lowerTitle = title.ToLowerInvariant(); - if (lowerTitle.StartsWith("lidarr:") || lowerTitle.StartsWith("lidarrid:") || lowerTitle.StartsWith("mbid:")) + if (IsMbidQuery(lowerTitle)) { var slug = lowerTitle.Split(':')[1].Trim(); @@ -244,7 +244,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { var lowerTitle = title.ToLowerInvariant(); - if (lowerTitle.StartsWith("lidarr:") || lowerTitle.StartsWith("lidarrid:") || lowerTitle.StartsWith("mbid:")) + if (IsMbidQuery(lowerTitle)) { var slug = lowerTitle.Split(':')[1].Trim(); @@ -322,6 +322,23 @@ namespace NzbDrone.Core.MetadataSource.SkyHook public List SearchForNewEntity(string title) { + var lowerTitle = title.ToLowerInvariant(); + + if (IsMbidQuery(lowerTitle)) + { + var artist = SearchForNewArtist(lowerTitle); + if (artist.Any()) + { + return new List { artist.First() }; + } + + var album = SearchForNewAlbum(lowerTitle, null); + if (album.Any()) + { + return new List { album.First() }; + } + } + try { var httpRequest = _requestBuilder.GetRequestBuilder().Create() @@ -345,6 +362,11 @@ namespace NzbDrone.Core.MetadataSource.SkyHook } } + private static bool IsMbidQuery(string query) + { + return query.StartsWith("lidarr:") || query.StartsWith("lidarrid:") || query.StartsWith("mbid:"); + } + private Artist MapSearchResult(ArtistResource resource) { var artist = _artistService.FindById(resource.Id);