mirror of https://github.com/lidarr/Lidarr
Fixed: Search by MusicBrainz ID
This commit is contained in:
parent
c3f6b8660e
commit
1be3cdadb4
|
@ -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);
|
||||
|
|
|
@ -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<object> SearchForNewEntity(string title)
|
||||
{
|
||||
var lowerTitle = title.ToLowerInvariant();
|
||||
|
||||
if (IsMbidQuery(lowerTitle))
|
||||
{
|
||||
var artist = SearchForNewArtist(lowerTitle);
|
||||
if (artist.Any())
|
||||
{
|
||||
return new List<object> { artist.First() };
|
||||
}
|
||||
|
||||
var album = SearchForNewAlbum(lowerTitle, null);
|
||||
if (album.Any())
|
||||
{
|
||||
return new List<object> { 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);
|
||||
|
|
Loading…
Reference in New Issue