ArtistsController.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.Linq;
  4. using Jellyfin.Api.Constants;
  5. using Jellyfin.Api.Extensions;
  6. using Jellyfin.Api.Helpers;
  7. using Jellyfin.Api.ModelBinders;
  8. using Jellyfin.Data.Entities;
  9. using Jellyfin.Data.Enums;
  10. using MediaBrowser.Controller.Dto;
  11. using MediaBrowser.Controller.Entities;
  12. using MediaBrowser.Controller.Library;
  13. using MediaBrowser.Model.Dto;
  14. using MediaBrowser.Model.Entities;
  15. using MediaBrowser.Model.Querying;
  16. using Microsoft.AspNetCore.Authorization;
  17. using Microsoft.AspNetCore.Http;
  18. using Microsoft.AspNetCore.Mvc;
  19. namespace Jellyfin.Api.Controllers
  20. {
  21. /// <summary>
  22. /// The artists controller.
  23. /// </summary>
  24. [Route("Artists")]
  25. [Authorize(Policy = Policies.DefaultAuthorization)]
  26. public class ArtistsController : BaseJellyfinApiController
  27. {
  28. private readonly ILibraryManager _libraryManager;
  29. private readonly IUserManager _userManager;
  30. private readonly IDtoService _dtoService;
  31. /// <summary>
  32. /// Initializes a new instance of the <see cref="ArtistsController"/> class.
  33. /// </summary>
  34. /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
  35. /// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
  36. /// <param name="dtoService">Instance of the <see cref="IDtoService"/> interface.</param>
  37. public ArtistsController(
  38. ILibraryManager libraryManager,
  39. IUserManager userManager,
  40. IDtoService dtoService)
  41. {
  42. _libraryManager = libraryManager;
  43. _userManager = userManager;
  44. _dtoService = dtoService;
  45. }
  46. /// <summary>
  47. /// Gets all artists from a given item, folder, or the entire library.
  48. /// </summary>
  49. /// <param name="minCommunityRating">Optional filter by minimum community rating.</param>
  50. /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
  51. /// <param name="limit">Optional. The maximum number of records to return.</param>
  52. /// <param name="searchTerm">Optional. Search term.</param>
  53. /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
  54. /// <param name="fields">Optional. Specify additional fields of information to return in the output.</param>
  55. /// <param name="excludeItemTypes">Optional. If specified, results will be filtered out based on item type. This allows multiple, comma delimited.</param>
  56. /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
  57. /// <param name="filters">Optional. Specify additional filters to apply.</param>
  58. /// <param name="isFavorite">Optional filter by items that are marked as favorite, or not.</param>
  59. /// <param name="mediaTypes">Optional filter by MediaType. Allows multiple, comma delimited.</param>
  60. /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimited.</param>
  61. /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimited.</param>
  62. /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimited.</param>
  63. /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimited.</param>
  64. /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimited.</param>
  65. /// <param name="enableUserData">Optional, include user data.</param>
  66. /// <param name="imageTypeLimit">Optional, the max number of images to return, per image type.</param>
  67. /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
  68. /// <param name="person">Optional. If specified, results will be filtered to include only those containing the specified person.</param>
  69. /// <param name="personIds">Optional. If specified, results will be filtered to include only those containing the specified person ids.</param>
  70. /// <param name="personTypes">Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited.</param>
  71. /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimited.</param>
  72. /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimited.</param>
  73. /// <param name="userId">User id.</param>
  74. /// <param name="nameStartsWithOrGreater">Optional filter by items whose name is sorted equally or greater than a given input string.</param>
  75. /// <param name="nameStartsWith">Optional filter by items whose name is sorted equally than a given input string.</param>
  76. /// <param name="nameLessThan">Optional filter by items whose name is equally or lesser than a given input string.</param>
  77. /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited.</param>
  78. /// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
  79. /// <param name="enableImages">Optional, include image information in output.</param>
  80. /// <param name="enableTotalRecordCount">Total record count.</param>
  81. /// <response code="200">Artists returned.</response>
  82. /// <returns>An <see cref="OkResult"/> containing the artists.</returns>
  83. [HttpGet]
  84. [ProducesResponseType(StatusCodes.Status200OK)]
  85. public ActionResult<QueryResult<BaseItemDto>> GetArtists(
  86. [FromQuery] double? minCommunityRating,
  87. [FromQuery] int? startIndex,
  88. [FromQuery] int? limit,
  89. [FromQuery] string? searchTerm,
  90. [FromQuery] Guid? parentId,
  91. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
  92. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
  93. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
  94. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
  95. [FromQuery] bool? isFavorite,
  96. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
  97. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
  98. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
  99. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
  100. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
  101. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
  102. [FromQuery] bool? enableUserData,
  103. [FromQuery] int? imageTypeLimit,
  104. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
  105. [FromQuery] string? person,
  106. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
  107. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
  108. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] studios,
  109. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
  110. [FromQuery] Guid? userId,
  111. [FromQuery] string? nameStartsWithOrGreater,
  112. [FromQuery] string? nameStartsWith,
  113. [FromQuery] string? nameLessThan,
  114. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
  115. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
  116. [FromQuery] bool? enableImages = true,
  117. [FromQuery] bool enableTotalRecordCount = true)
  118. {
  119. var dtoOptions = new DtoOptions { Fields = fields }
  120. .AddClientFields(Request)
  121. .AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
  122. User? user = null;
  123. BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
  124. if (userId.HasValue && !userId.Equals(default))
  125. {
  126. user = _userManager.GetUserById(userId.Value);
  127. }
  128. var query = new InternalItemsQuery(user)
  129. {
  130. ExcludeItemTypes = excludeItemTypes,
  131. IncludeItemTypes = includeItemTypes,
  132. MediaTypes = mediaTypes,
  133. StartIndex = startIndex,
  134. Limit = limit,
  135. IsFavorite = isFavorite,
  136. NameLessThan = nameLessThan,
  137. NameStartsWith = nameStartsWith,
  138. NameStartsWithOrGreater = nameStartsWithOrGreater,
  139. Tags = tags,
  140. OfficialRatings = officialRatings,
  141. Genres = genres,
  142. GenreIds = genreIds,
  143. StudioIds = studioIds,
  144. Person = person,
  145. PersonIds = personIds,
  146. PersonTypes = personTypes,
  147. Years = years,
  148. MinCommunityRating = minCommunityRating,
  149. DtoOptions = dtoOptions,
  150. SearchTerm = searchTerm,
  151. EnableTotalRecordCount = enableTotalRecordCount,
  152. OrderBy = RequestHelpers.GetOrderBy(sortBy, sortOrder)
  153. };
  154. if (parentId.HasValue)
  155. {
  156. if (parentItem is Folder)
  157. {
  158. query.AncestorIds = new[] { parentId.Value };
  159. }
  160. else
  161. {
  162. query.ItemIds = new[] { parentId.Value };
  163. }
  164. }
  165. // Studios
  166. if (studios.Length != 0)
  167. {
  168. query.StudioIds = studios.Select(i =>
  169. {
  170. try
  171. {
  172. return _libraryManager.GetStudio(i);
  173. }
  174. catch
  175. {
  176. return null;
  177. }
  178. }).Where(i => i != null).Select(i => i!.Id).ToArray();
  179. }
  180. foreach (var filter in filters)
  181. {
  182. switch (filter)
  183. {
  184. case ItemFilter.Dislikes:
  185. query.IsLiked = false;
  186. break;
  187. case ItemFilter.IsFavorite:
  188. query.IsFavorite = true;
  189. break;
  190. case ItemFilter.IsFavoriteOrLikes:
  191. query.IsFavoriteOrLiked = true;
  192. break;
  193. case ItemFilter.IsFolder:
  194. query.IsFolder = true;
  195. break;
  196. case ItemFilter.IsNotFolder:
  197. query.IsFolder = false;
  198. break;
  199. case ItemFilter.IsPlayed:
  200. query.IsPlayed = true;
  201. break;
  202. case ItemFilter.IsResumable:
  203. query.IsResumable = true;
  204. break;
  205. case ItemFilter.IsUnplayed:
  206. query.IsPlayed = false;
  207. break;
  208. case ItemFilter.Likes:
  209. query.IsLiked = true;
  210. break;
  211. }
  212. }
  213. var result = _libraryManager.GetArtists(query);
  214. var dtos = result.Items.Select(i =>
  215. {
  216. var (baseItem, itemCounts) = i;
  217. var dto = _dtoService.GetItemByNameDto(baseItem, dtoOptions, null, user);
  218. if (includeItemTypes.Length != 0)
  219. {
  220. dto.ChildCount = itemCounts.ItemCount;
  221. dto.ProgramCount = itemCounts.ProgramCount;
  222. dto.SeriesCount = itemCounts.SeriesCount;
  223. dto.EpisodeCount = itemCounts.EpisodeCount;
  224. dto.MovieCount = itemCounts.MovieCount;
  225. dto.TrailerCount = itemCounts.TrailerCount;
  226. dto.AlbumCount = itemCounts.AlbumCount;
  227. dto.SongCount = itemCounts.SongCount;
  228. dto.ArtistCount = itemCounts.ArtistCount;
  229. }
  230. return dto;
  231. });
  232. return new QueryResult<BaseItemDto>(
  233. query.StartIndex,
  234. result.TotalRecordCount,
  235. dtos.ToArray());
  236. }
  237. /// <summary>
  238. /// Gets all album artists from a given item, folder, or the entire library.
  239. /// </summary>
  240. /// <param name="minCommunityRating">Optional filter by minimum community rating.</param>
  241. /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
  242. /// <param name="limit">Optional. The maximum number of records to return.</param>
  243. /// <param name="searchTerm">Optional. Search term.</param>
  244. /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
  245. /// <param name="fields">Optional. Specify additional fields of information to return in the output.</param>
  246. /// <param name="excludeItemTypes">Optional. If specified, results will be filtered out based on item type. This allows multiple, comma delimited.</param>
  247. /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
  248. /// <param name="filters">Optional. Specify additional filters to apply.</param>
  249. /// <param name="isFavorite">Optional filter by items that are marked as favorite, or not.</param>
  250. /// <param name="mediaTypes">Optional filter by MediaType. Allows multiple, comma delimited.</param>
  251. /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimited.</param>
  252. /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimited.</param>
  253. /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimited.</param>
  254. /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimited.</param>
  255. /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimited.</param>
  256. /// <param name="enableUserData">Optional, include user data.</param>
  257. /// <param name="imageTypeLimit">Optional, the max number of images to return, per image type.</param>
  258. /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
  259. /// <param name="person">Optional. If specified, results will be filtered to include only those containing the specified person.</param>
  260. /// <param name="personIds">Optional. If specified, results will be filtered to include only those containing the specified person ids.</param>
  261. /// <param name="personTypes">Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited.</param>
  262. /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimited.</param>
  263. /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimited.</param>
  264. /// <param name="userId">User id.</param>
  265. /// <param name="nameStartsWithOrGreater">Optional filter by items whose name is sorted equally or greater than a given input string.</param>
  266. /// <param name="nameStartsWith">Optional filter by items whose name is sorted equally than a given input string.</param>
  267. /// <param name="nameLessThan">Optional filter by items whose name is equally or lesser than a given input string.</param>
  268. /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited.</param>
  269. /// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
  270. /// <param name="enableImages">Optional, include image information in output.</param>
  271. /// <param name="enableTotalRecordCount">Total record count.</param>
  272. /// <response code="200">Album artists returned.</response>
  273. /// <returns>An <see cref="OkResult"/> containing the album artists.</returns>
  274. [HttpGet("AlbumArtists")]
  275. [ProducesResponseType(StatusCodes.Status200OK)]
  276. public ActionResult<QueryResult<BaseItemDto>> GetAlbumArtists(
  277. [FromQuery] double? minCommunityRating,
  278. [FromQuery] int? startIndex,
  279. [FromQuery] int? limit,
  280. [FromQuery] string? searchTerm,
  281. [FromQuery] Guid? parentId,
  282. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
  283. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
  284. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
  285. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
  286. [FromQuery] bool? isFavorite,
  287. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
  288. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
  289. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
  290. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
  291. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
  292. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
  293. [FromQuery] bool? enableUserData,
  294. [FromQuery] int? imageTypeLimit,
  295. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
  296. [FromQuery] string? person,
  297. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
  298. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
  299. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] studios,
  300. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
  301. [FromQuery] Guid? userId,
  302. [FromQuery] string? nameStartsWithOrGreater,
  303. [FromQuery] string? nameStartsWith,
  304. [FromQuery] string? nameLessThan,
  305. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
  306. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
  307. [FromQuery] bool? enableImages = true,
  308. [FromQuery] bool enableTotalRecordCount = true)
  309. {
  310. var dtoOptions = new DtoOptions { Fields = fields }
  311. .AddClientFields(Request)
  312. .AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
  313. User? user = null;
  314. BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
  315. if (userId.HasValue && !userId.Equals(default))
  316. {
  317. user = _userManager.GetUserById(userId.Value);
  318. }
  319. var query = new InternalItemsQuery(user)
  320. {
  321. ExcludeItemTypes = excludeItemTypes,
  322. IncludeItemTypes = includeItemTypes,
  323. MediaTypes = mediaTypes,
  324. StartIndex = startIndex,
  325. Limit = limit,
  326. IsFavorite = isFavorite,
  327. NameLessThan = nameLessThan,
  328. NameStartsWith = nameStartsWith,
  329. NameStartsWithOrGreater = nameStartsWithOrGreater,
  330. Tags = tags,
  331. OfficialRatings = officialRatings,
  332. Genres = genres,
  333. GenreIds = genreIds,
  334. StudioIds = studioIds,
  335. Person = person,
  336. PersonIds = personIds,
  337. PersonTypes = personTypes,
  338. Years = years,
  339. MinCommunityRating = minCommunityRating,
  340. DtoOptions = dtoOptions,
  341. SearchTerm = searchTerm,
  342. EnableTotalRecordCount = enableTotalRecordCount,
  343. OrderBy = RequestHelpers.GetOrderBy(sortBy, sortOrder)
  344. };
  345. if (parentId.HasValue)
  346. {
  347. if (parentItem is Folder)
  348. {
  349. query.AncestorIds = new[] { parentId.Value };
  350. }
  351. else
  352. {
  353. query.ItemIds = new[] { parentId.Value };
  354. }
  355. }
  356. // Studios
  357. if (studios.Length != 0)
  358. {
  359. query.StudioIds = studios.Select(i =>
  360. {
  361. try
  362. {
  363. return _libraryManager.GetStudio(i);
  364. }
  365. catch
  366. {
  367. return null;
  368. }
  369. }).Where(i => i != null).Select(i => i!.Id).ToArray();
  370. }
  371. foreach (var filter in filters)
  372. {
  373. switch (filter)
  374. {
  375. case ItemFilter.Dislikes:
  376. query.IsLiked = false;
  377. break;
  378. case ItemFilter.IsFavorite:
  379. query.IsFavorite = true;
  380. break;
  381. case ItemFilter.IsFavoriteOrLikes:
  382. query.IsFavoriteOrLiked = true;
  383. break;
  384. case ItemFilter.IsFolder:
  385. query.IsFolder = true;
  386. break;
  387. case ItemFilter.IsNotFolder:
  388. query.IsFolder = false;
  389. break;
  390. case ItemFilter.IsPlayed:
  391. query.IsPlayed = true;
  392. break;
  393. case ItemFilter.IsResumable:
  394. query.IsResumable = true;
  395. break;
  396. case ItemFilter.IsUnplayed:
  397. query.IsPlayed = false;
  398. break;
  399. case ItemFilter.Likes:
  400. query.IsLiked = true;
  401. break;
  402. }
  403. }
  404. var result = _libraryManager.GetAlbumArtists(query);
  405. var dtos = result.Items.Select(i =>
  406. {
  407. var (baseItem, itemCounts) = i;
  408. var dto = _dtoService.GetItemByNameDto(baseItem, dtoOptions, null, user);
  409. if (includeItemTypes.Length != 0)
  410. {
  411. dto.ChildCount = itemCounts.ItemCount;
  412. dto.ProgramCount = itemCounts.ProgramCount;
  413. dto.SeriesCount = itemCounts.SeriesCount;
  414. dto.EpisodeCount = itemCounts.EpisodeCount;
  415. dto.MovieCount = itemCounts.MovieCount;
  416. dto.TrailerCount = itemCounts.TrailerCount;
  417. dto.AlbumCount = itemCounts.AlbumCount;
  418. dto.SongCount = itemCounts.SongCount;
  419. dto.ArtistCount = itemCounts.ArtistCount;
  420. }
  421. return dto;
  422. });
  423. return new QueryResult<BaseItemDto>(
  424. query.StartIndex,
  425. result.TotalRecordCount,
  426. dtos.ToArray());
  427. }
  428. /// <summary>
  429. /// Gets an artist by name.
  430. /// </summary>
  431. /// <param name="name">Studio name.</param>
  432. /// <param name="userId">Optional. Filter by user id, and attach user data.</param>
  433. /// <response code="200">Artist returned.</response>
  434. /// <returns>An <see cref="OkResult"/> containing the artist.</returns>
  435. [HttpGet("{name}")]
  436. [ProducesResponseType(StatusCodes.Status200OK)]
  437. public ActionResult<BaseItemDto> GetArtistByName([FromRoute, Required] string name, [FromQuery] Guid? userId)
  438. {
  439. var dtoOptions = new DtoOptions().AddClientFields(Request);
  440. var item = _libraryManager.GetArtist(name, dtoOptions);
  441. if (userId.HasValue && !userId.Value.Equals(default))
  442. {
  443. var user = _userManager.GetUserById(userId.Value);
  444. return _dtoService.GetBaseItemDto(item, dtoOptions, user);
  445. }
  446. return _dtoService.GetBaseItemDto(item, dtoOptions);
  447. }
  448. }
  449. }