MusicAlbum.cs 2.5 KB

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