MusicAlbum.cs 3.2 KB

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