MusicAlbum.cs 3.3 KB

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