diff --git a/src/Lidarr.Api.V1/Artist/ArtistModule.cs b/src/Lidarr.Api.V1/Artist/ArtistModule.cs index 52528dd6f..088139705 100644 --- a/src/Lidarr.Api.V1/Artist/ArtistModule.cs +++ b/src/Lidarr.Api.V1/Artist/ArtistModule.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using FluentValidation; @@ -122,8 +123,18 @@ namespace Lidarr.Api.V1.Artist private List AllArtists() { + var mbId = Request.GetGuidQueryParameter("mbId"); var artistStats = _artistStatisticsService.ArtistStatistics(); - var artistsResources = _artistService.GetAllArtists().ToResource(); + var artistsResources = new List(); + + if (mbId != Guid.Empty) + { + artistsResources.AddIfNotNull(_artistService.FindById(mbId.ToString()).ToResource()); + } + else + { + artistsResources.AddRange(_artistService.GetAllArtists().ToResource()); + } MapCoversToLocal(artistsResources.ToArray()); LinkNextPreviousAlbums(artistsResources.ToArray()); diff --git a/src/Lidarr.Http/Extensions/RequestExtensions.cs b/src/Lidarr.Http/Extensions/RequestExtensions.cs index e0da3fb80..ee1e74fcb 100644 --- a/src/Lidarr.Http/Extensions/RequestExtensions.cs +++ b/src/Lidarr.Http/Extensions/RequestExtensions.cs @@ -54,5 +54,29 @@ namespace Lidarr.Http.Extensions return request.Path.StartsWith("/MediaCover/", StringComparison.InvariantCultureIgnoreCase) || request.Path.StartsWith("/Content/Images/", StringComparison.InvariantCultureIgnoreCase); } + + public static int GetIntegerQueryParameter(this Request request, string parameter, int defaultValue = 0) + { + var parameterValue = request.Query[parameter]; + + if (parameterValue.HasValue) + { + return int.Parse(parameterValue.Value); + } + + return defaultValue; + } + + public static Guid GetGuidQueryParameter(this Request request, string parameter, Guid defaultValue = default) + { + var parameterValue = request.Query[parameter]; + + if (parameterValue.HasValue) + { + return Guid.Parse(parameterValue.Value); + } + + return defaultValue; + } } }