MusicArtist.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. public MusicArtist()
  61. {
  62. UserItemCountList = new List<ItemByNameCounts>();
  63. Tags = new List<string>();
  64. ProductionLocations = new List<string>();
  65. }
  66. /// <summary>
  67. /// Gets the user data key.
  68. /// </summary>
  69. /// <returns>System.String.</returns>
  70. public override string GetUserDataKey()
  71. {
  72. return GetUserDataKey(this);
  73. }
  74. /// <summary>
  75. /// Gets the user data key.
  76. /// </summary>
  77. /// <param name="item">The item.</param>
  78. /// <returns>System.String.</returns>
  79. private static string GetUserDataKey(MusicArtist item)
  80. {
  81. var id = item.GetProviderId(MetadataProviders.Musicbrainz);
  82. if (!string.IsNullOrEmpty(id))
  83. {
  84. return "Artist-Musicbrainz-" + id;
  85. }
  86. return "Artist-" + item.Name;
  87. }
  88. protected override bool GetBlockUnratedValue(UserConfiguration config)
  89. {
  90. return config.BlockUnratedMusic;
  91. }
  92. }
  93. }