MusicAlbum.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using MediaBrowser.Model.Configuration;
  2. using MediaBrowser.Model.Entities;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Runtime.Serialization;
  7. namespace MediaBrowser.Controller.Entities.Audio
  8. {
  9. /// <summary>
  10. /// Class MusicAlbum
  11. /// </summary>
  12. public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasTags
  13. {
  14. public List<Guid> SoundtrackIds { get; set; }
  15. public MusicAlbum()
  16. {
  17. Artists = new List<string>();
  18. SoundtrackIds = new List<Guid>();
  19. Tags = new List<string>();
  20. }
  21. public string LastFmImageUrl { get; set; }
  22. public string LastFmImageSize { get; set; }
  23. /// <summary>
  24. /// Gets or sets the tags.
  25. /// </summary>
  26. /// <value>The tags.</value>
  27. public List<string> Tags { get; set; }
  28. /// <summary>
  29. /// Songs will group into us so don't also include us in the index
  30. /// </summary>
  31. /// <value><c>true</c> if [include in index]; otherwise, <c>false</c>.</value>
  32. [IgnoreDataMember]
  33. public override bool IncludeInIndex
  34. {
  35. get
  36. {
  37. return false;
  38. }
  39. }
  40. /// <summary>
  41. /// Override this to true if class should be grouped under a container in indicies
  42. /// The container class should be defined via IndexContainer
  43. /// </summary>
  44. /// <value><c>true</c> if [group in index]; otherwise, <c>false</c>.</value>
  45. [IgnoreDataMember]
  46. public override bool GroupInIndex
  47. {
  48. get
  49. {
  50. return true;
  51. }
  52. }
  53. /// <summary>
  54. /// The unknwon artist
  55. /// </summary>
  56. private static readonly MusicArtist UnknwonArtist = new MusicArtist { Name = "<Unknown>" };
  57. /// <summary>
  58. /// Override this to return the folder that should be used to construct a container
  59. /// for this item in an index. GroupInIndex should be true as well.
  60. /// </summary>
  61. /// <value>The index container.</value>
  62. [IgnoreDataMember]
  63. public override Folder IndexContainer
  64. {
  65. get { return Parent as MusicArtist ?? UnknwonArtist; }
  66. }
  67. /// <summary>
  68. /// Determines whether the specified artist has artist.
  69. /// </summary>
  70. /// <param name="artist">The artist.</param>
  71. /// <returns><c>true</c> if the specified artist has artist; otherwise, <c>false</c>.</returns>
  72. public bool HasArtist(string artist)
  73. {
  74. return string.Equals(AlbumArtist, artist, StringComparison.OrdinalIgnoreCase)
  75. || Artists.Contains(artist, StringComparer.OrdinalIgnoreCase);
  76. }
  77. public string AlbumArtist { get; set; }
  78. public List<string> Artists { get; set; }
  79. /// <summary>
  80. /// Gets the user data key.
  81. /// </summary>
  82. /// <returns>System.String.</returns>
  83. public override string GetUserDataKey()
  84. {
  85. var id = this.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
  86. if (!string.IsNullOrEmpty(id))
  87. {
  88. return "MusicAlbum-MusicBrainzReleaseGroup-" + id;
  89. }
  90. id = this.GetProviderId(MetadataProviders.Musicbrainz);
  91. if (!string.IsNullOrEmpty(id))
  92. {
  93. return "MusicAlbum-Musicbrainz-" + id;
  94. }
  95. return base.GetUserDataKey();
  96. }
  97. protected override bool GetBlockUnratedValue(UserConfiguration config)
  98. {
  99. return config.BlockUnratedMusic;
  100. }
  101. }
  102. public class MusicAlbumDisc : Folder
  103. {
  104. }
  105. }