MusicAlbum.cs 3.1 KB

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