MusicAlbum.cs 3.5 KB

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