mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-10 23:33:38 -07:00
New: MB ID filter when getting artist from API
Fixes #1200 Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
2a76ae4087
commit
140f3f88c4
2 changed files with 36 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
@ -122,8 +123,18 @@ namespace Lidarr.Api.V1.Artist
|
||||||
|
|
||||||
private List<ArtistResource> AllArtists()
|
private List<ArtistResource> AllArtists()
|
||||||
{
|
{
|
||||||
|
var mbId = Request.GetGuidQueryParameter("mbId");
|
||||||
var artistStats = _artistStatisticsService.ArtistStatistics();
|
var artistStats = _artistStatisticsService.ArtistStatistics();
|
||||||
var artistsResources = _artistService.GetAllArtists().ToResource();
|
var artistsResources = new List<ArtistResource>();
|
||||||
|
|
||||||
|
if (mbId != Guid.Empty)
|
||||||
|
{
|
||||||
|
artistsResources.AddIfNotNull(_artistService.FindById(mbId.ToString()).ToResource());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
artistsResources.AddRange(_artistService.GetAllArtists().ToResource());
|
||||||
|
}
|
||||||
|
|
||||||
MapCoversToLocal(artistsResources.ToArray());
|
MapCoversToLocal(artistsResources.ToArray());
|
||||||
LinkNextPreviousAlbums(artistsResources.ToArray());
|
LinkNextPreviousAlbums(artistsResources.ToArray());
|
||||||
|
|
|
@ -54,5 +54,29 @@ namespace Lidarr.Http.Extensions
|
||||||
return request.Path.StartsWith("/MediaCover/", StringComparison.InvariantCultureIgnoreCase) ||
|
return request.Path.StartsWith("/MediaCover/", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
request.Path.StartsWith("/Content/Images/", 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue