MusicArtist.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. private readonly Task _cachedTask = Task.FromResult(true);
  44. protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false)
  45. {
  46. if (IsAccessedByName)
  47. {
  48. // Should never get in here anyway
  49. return _cachedTask;
  50. }
  51. return base.ValidateChildrenInternal(progress, cancellationToken, recursive, forceRefreshMetadata);
  52. }
  53. public override string GetClientTypeName()
  54. {
  55. if (IsAccessedByName)
  56. {
  57. //return "Artist";
  58. }
  59. return base.GetClientTypeName();
  60. }
  61. public MusicArtist()
  62. {
  63. UserItemCountList = new List<ItemByNameCounts>();
  64. Tags = new List<string>();
  65. ProductionLocations = new List<string>();
  66. }
  67. /// <summary>
  68. /// Gets the user data key.
  69. /// </summary>
  70. /// <returns>System.String.</returns>
  71. public override string GetUserDataKey()
  72. {
  73. return GetUserDataKey(this);
  74. }
  75. /// <summary>
  76. /// Gets the user data key.
  77. /// </summary>
  78. /// <param name="item">The item.</param>
  79. /// <returns>System.String.</returns>
  80. private static string GetUserDataKey(MusicArtist item)
  81. {
  82. var id = item.GetProviderId(MetadataProviders.Musicbrainz);
  83. if (!string.IsNullOrEmpty(id))
  84. {
  85. return "Artist-Musicbrainz-" + id;
  86. }
  87. return "Artist-" + item.Name;
  88. }
  89. protected override bool GetBlockUnratedValue(UserConfiguration config)
  90. {
  91. return config.BlockUnratedMusic;
  92. }
  93. }
  94. }