MusicArtist.cs 3.3 KB

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