MusicAlbum.cs 3.6 KB

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