ArtistsController.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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(Guid.Empty))
  125. {
  126. user = _userManager.GetUserById(userId.Value);
  127. }
  128. var query = new InternalItemsQuery(user)
  129. {
  130. ExcludeItemTypes = RequestHelpers.GetItemTypeStrings(excludeItemTypes),
  131. IncludeItemTypes = RequestHelpers.GetItemTypeStrings(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. {
  234. Items = dtos.ToArray(),
  235. TotalRecordCount = result.TotalRecordCount
  236. };
  237. }
  238. /// <summary>
  239. /// Gets all album artists from a given item, folder, or the entire library.
  240. /// </summary>
  241. /// <param name="minCommunityRating">Optional filter by minimum community rating.</param>
  242. /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
  243. /// <param name="limit">Optional. The maximum number of records to return.</param>
  244. /// <param name="searchTerm">Optional. Search term.</param>
  245. /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
  246. /// <param name="fields">Optional. Specify additional fields of information to return in the output.</param>
  247. /// <param name="excludeItemTypes">Optional. If specified, results will be filtered out based on item type. This allows multiple, comma delimited.</param>
  248. /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
  249. /// <param name="filters">Optional. Specify additional filters to apply.</param>
  250. /// <param name="isFavorite">Optional filter by items that are marked as favorite, or not.</param>
  251. /// <param name="mediaTypes">Optional filter by MediaType. Allows multiple, comma delimited.</param>
  252. /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimited.</param>
  253. /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimited.</param>
  254. /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimited.</param>
  255. /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimited.</param>
  256. /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimited.</param>
  257. /// <param name="enableUserData">Optional, include user data.</param>
  258. /// <param name="imageTypeLimit">Optional, the max number of images to return, per image type.</param>
  259. /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
  260. /// <param name="person">Optional. If specified, results will be filtered to include only those containing the specified person.</param>
  261. /// <param name="personIds">Optional. If specified, results will be filtered to include only those containing the specified person ids.</param>
  262. /// <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>
  263. /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimited.</param>
  264. /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimited.</param>
  265. /// <param name="userId">User id.</param>
  266. /// <param name="nameStartsWithOrGreater">Optional filter by items whose name is sorted equally or greater than a given input string.</param>
  267. /// <param name="nameStartsWith">Optional filter by items whose name is sorted equally than a given input string.</param>
  268. /// <param name="nameLessThan">Optional filter by items whose name is equally or lesser than a given input string.</param>
  269. /// <param name="enableImages">Optional, include image information in output.</param>
  270. /// <param name="enableTotalRecordCount">Total record count.</param>
  271. /// <response code="200">Album artists returned.</response>
  272. /// <returns>An <see cref="OkResult"/> containing the album artists.</returns>
  273. [HttpGet("AlbumArtists")]
  274. [ProducesResponseType(StatusCodes.Status200OK)]
  275. public ActionResult<QueryResult<BaseItemDto>> GetAlbumArtists(
  276. [FromQuery] double? minCommunityRating,
  277. [FromQuery] int? startIndex,
  278. [FromQuery] int? limit,
  279. [FromQuery] string? searchTerm,
  280. [FromQuery] Guid? parentId,
  281. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
  282. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
  283. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
  284. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
  285. [FromQuery] bool? isFavorite,
  286. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
  287. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
  288. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
  289. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
  290. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
  291. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
  292. [FromQuery] bool? enableUserData,
  293. [FromQuery] int? imageTypeLimit,
  294. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
  295. [FromQuery] string? person,
  296. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
  297. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
  298. [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] studios,
  299. [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
  300. [FromQuery] Guid? userId,
  301. [FromQuery] string? nameStartsWithOrGreater,
  302. [FromQuery] string? nameStartsWith,
  303. [FromQuery] string? nameLessThan,
  304. [FromQuery] bool? enableImages = true,
  305. [FromQuery] bool enableTotalRecordCount = true)
  306. {
  307. var dtoOptions = new DtoOptions { Fields = fields }
  308. .AddClientFields(Request)
  309. .AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
  310. User? user = null;
  311. BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
  312. if (userId.HasValue && !userId.Equals(Guid.Empty))
  313. {
  314. user = _userManager.GetUserById(userId.Value);
  315. }
  316. var query = new InternalItemsQuery(user)
  317. {
  318. ExcludeItemTypes = RequestHelpers.GetItemTypeStrings(excludeItemTypes),
  319. IncludeItemTypes = RequestHelpers.GetItemTypeStrings(includeItemTypes),
  320. MediaTypes = mediaTypes,
  321. StartIndex = startIndex,
  322. Limit = limit,
  323. IsFavorite = isFavorite,
  324. NameLessThan = nameLessThan,
  325. NameStartsWith = nameStartsWith,
  326. NameStartsWithOrGreater = nameStartsWithOrGreater,
  327. Tags = tags,
  328. OfficialRatings = officialRatings,
  329. Genres = genres,
  330. GenreIds = genreIds,
  331. StudioIds = studioIds,
  332. Person = person,
  333. PersonIds = personIds,
  334. PersonTypes = personTypes,
  335. Years = years,
  336. MinCommunityRating = minCommunityRating,
  337. DtoOptions = dtoOptions,
  338. SearchTerm = searchTerm,
  339. EnableTotalRecordCount = enableTotalRecordCount
  340. };
  341. if (parentId.HasValue)
  342. {
  343. if (parentItem is Folder)
  344. {
  345. query.AncestorIds = new[] { parentId.Value };
  346. }
  347. else
  348. {
  349. query.ItemIds = new[] { parentId.Value };
  350. }
  351. }
  352. // Studios
  353. if (studios.Length != 0)
  354. {
  355. query.StudioIds = studios.Select(i =>
  356. {
  357. try
  358. {
  359. return _libraryManager.GetStudio(i);
  360. }
  361. catch
  362. {
  363. return null;
  364. }
  365. }).Where(i => i != null).Select(i => i!.Id).ToArray();
  366. }
  367. foreach (var filter in filters)
  368. {
  369. switch (filter)
  370. {
  371. case ItemFilter.Dislikes:
  372. query.IsLiked = false;
  373. break;
  374. case ItemFilter.IsFavorite:
  375. query.IsFavorite = true;
  376. break;
  377. case ItemFilter.IsFavoriteOrLikes:
  378. query.IsFavoriteOrLiked = true;
  379. break;
  380. case ItemFilter.IsFolder:
  381. query.IsFolder = true;
  382. break;
  383. case ItemFilter.IsNotFolder:
  384. query.IsFolder = false;
  385. break;
  386. case ItemFilter.IsPlayed:
  387. query.IsPlayed = true;
  388. break;
  389. case ItemFilter.IsResumable:
  390. query.IsResumable = true;
  391. break;
  392. case ItemFilter.IsUnplayed:
  393. query.IsPlayed = false;
  394. break;
  395. case ItemFilter.Likes:
  396. query.IsLiked = true;
  397. break;
  398. }
  399. }
  400. var result = _libraryManager.GetAlbumArtists(query);
  401. var dtos = result.Items.Select(i =>
  402. {
  403. var (baseItem, itemCounts) = i;
  404. var dto = _dtoService.GetItemByNameDto(baseItem, dtoOptions, null, user);
  405. if (includeItemTypes.Length != 0)
  406. {
  407. dto.ChildCount = itemCounts.ItemCount;
  408. dto.ProgramCount = itemCounts.ProgramCount;
  409. dto.SeriesCount = itemCounts.SeriesCount;
  410. dto.EpisodeCount = itemCounts.EpisodeCount;
  411. dto.MovieCount = itemCounts.MovieCount;
  412. dto.TrailerCount = itemCounts.TrailerCount;
  413. dto.AlbumCount = itemCounts.AlbumCount;
  414. dto.SongCount = itemCounts.SongCount;
  415. dto.ArtistCount = itemCounts.ArtistCount;
  416. }
  417. return dto;
  418. });
  419. return new QueryResult<BaseItemDto>
  420. {
  421. Items = dtos.ToArray(),
  422. TotalRecordCount = result.TotalRecordCount
  423. };
  424. }
  425. /// <summary>
  426. /// Gets an artist by name.
  427. /// </summary>
  428. /// <param name="name">Studio name.</param>
  429. /// <param name="userId">Optional. Filter by user id, and attach user data.</param>
  430. /// <response code="200">Artist returned.</response>
  431. /// <returns>An <see cref="OkResult"/> containing the artist.</returns>
  432. [HttpGet("{name}")]
  433. [ProducesResponseType(StatusCodes.Status200OK)]
  434. public ActionResult<BaseItemDto> GetArtistByName([FromRoute, Required] string name, [FromQuery] Guid? userId)
  435. {
  436. var dtoOptions = new DtoOptions().AddClientFields(Request);
  437. var item = _libraryManager.GetArtist(name, dtoOptions);
  438. if (userId.HasValue && !userId.Equals(Guid.Empty))
  439. {
  440. var user = _userManager.GetUserById(userId.Value);
  441. return _dtoService.GetBaseItemDto(item, dtoOptions, user);
  442. }
  443. return _dtoService.GetBaseItemDto(item, dtoOptions);
  444. }
  445. }
  446. }