MusicArtist.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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
  14. {
  15. [IgnoreDataMember]
  16. public List<ItemByNameCounts> UserItemCountList { get; set; }
  17. public bool IsAccessedByName { get; set; }
  18. public override bool IsFolder
  19. {
  20. get
  21. {
  22. return !IsAccessedByName;
  23. }
  24. }
  25. protected override IEnumerable<BaseItem> ActualChildren
  26. {
  27. get
  28. {
  29. if (IsAccessedByName)
  30. {
  31. return new List<BaseItem>();
  32. }
  33. return base.ActualChildren;
  34. }
  35. }
  36. protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false)
  37. {
  38. if (IsAccessedByName)
  39. {
  40. // Should never get in here anyway
  41. return Task.FromResult(true);
  42. }
  43. return base.ValidateChildrenInternal(progress, cancellationToken, recursive, forceRefreshMetadata);
  44. }
  45. public override string GetClientTypeName()
  46. {
  47. if (IsAccessedByName)
  48. {
  49. //return "Artist";
  50. }
  51. return base.GetClientTypeName();
  52. }
  53. /// <summary>
  54. /// Gets or sets the last fm image URL.
  55. /// </summary>
  56. /// <value>The last fm image URL.</value>
  57. public string LastFmImageUrl { get; set; }
  58. public string LastFmImageSize { get; set; }
  59. public MusicArtist()
  60. {
  61. UserItemCountList = new List<ItemByNameCounts>();
  62. }
  63. /// <summary>
  64. /// Gets the user data key.
  65. /// </summary>
  66. /// <returns>System.String.</returns>
  67. public override string GetUserDataKey()
  68. {
  69. return GetUserDataKey(this);
  70. }
  71. /// <summary>
  72. /// Gets the user data key.
  73. /// </summary>
  74. /// <param name="item">The item.</param>
  75. /// <returns>System.String.</returns>
  76. public static string GetUserDataKey(BaseItem item)
  77. {
  78. var id = item.GetProviderId(MetadataProviders.Musicbrainz);
  79. if (!string.IsNullOrEmpty(id))
  80. {
  81. return "Artist-Musicbrainz-" + id;
  82. }
  83. return "Artist-" + item.Name;
  84. }
  85. }
  86. }