MusicArtist.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using MediaBrowser.Model.Dto;
  2. using MediaBrowser.Model.Entities;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.Serialization;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace MediaBrowser.Controller.Entities.Audio
  9. {
  10. /// <summary>
  11. /// Class MusicArtist
  12. /// </summary>
  13. public class MusicArtist : Folder, IItemByName, IHasMusicGenres, IHasDualAccess, IHasTags, IHasProductionLocations
  14. {
  15. [IgnoreDataMember]
  16. public List<ItemByNameCounts> UserItemCountList { get; set; }
  17. public bool IsAccessedByName { get; set; }
  18. /// <summary>
  19. /// Gets or sets the tags.
  20. /// </summary>
  21. /// <value>The tags.</value>
  22. public List<string> Tags { get; set; }
  23. public List<string> ProductionLocations { get; set; }
  24. public override bool IsFolder
  25. {
  26. get
  27. {
  28. return !IsAccessedByName;
  29. }
  30. }
  31. protected override IEnumerable<BaseItem> ActualChildren
  32. {
  33. get
  34. {
  35. if (IsAccessedByName)
  36. {
  37. return new List<BaseItem>();
  38. }
  39. return base.ActualChildren;
  40. }
  41. }
  42. protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false)
  43. {
  44. if (IsAccessedByName)
  45. {
  46. // Should never get in here anyway
  47. return Task.FromResult(true);
  48. }
  49. return base.ValidateChildrenInternal(progress, cancellationToken, recursive, forceRefreshMetadata);
  50. }
  51. public override string GetClientTypeName()
  52. {
  53. if (IsAccessedByName)
  54. {
  55. //return "Artist";
  56. }
  57. return base.GetClientTypeName();
  58. }
  59. /// <summary>
  60. /// Gets or sets the last fm image URL.
  61. /// </summary>
  62. /// <value>The last fm image URL.</value>
  63. public string LastFmImageUrl { get; set; }
  64. public string LastFmImageSize { get; set; }
  65. public MusicArtist()
  66. {
  67. UserItemCountList = new List<ItemByNameCounts>();
  68. Tags = new List<string>();
  69. ProductionLocations = new List<string>();
  70. }
  71. /// <summary>
  72. /// Gets the user data key.
  73. /// </summary>
  74. /// <returns>System.String.</returns>
  75. public override string GetUserDataKey()
  76. {
  77. return GetUserDataKey(this);
  78. }
  79. /// <summary>
  80. /// Gets the user data key.
  81. /// </summary>
  82. /// <param name="item">The item.</param>
  83. /// <returns>System.String.</returns>
  84. public static string GetUserDataKey(BaseItem item)
  85. {
  86. var id = item.GetProviderId(MetadataProviders.Musicbrainz);
  87. if (!string.IsNullOrEmpty(id))
  88. {
  89. return "Artist-Musicbrainz-" + id;
  90. }
  91. return "Artist-" + item.Name;
  92. }
  93. }
  94. }