MusicAlbum.cs 2.4 KB

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