MusicAlbum.cs 2.4 KB

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