ArtistsController.cs 23 KB

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