MusicVideo.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using MediaBrowser.Controller.Entities.Audio;
  2. using MediaBrowser.Controller.Providers;
  3. using MediaBrowser.Model.Configuration;
  4. using MediaBrowser.Model.Entities;
  5. using System.Collections.Generic;
  6. using System.Runtime.Serialization;
  7. namespace MediaBrowser.Controller.Entities
  8. {
  9. public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasProductionLocations, IHasBudget, IHasLookupInfo<MusicVideoInfo>
  10. {
  11. /// <summary>
  12. /// Gets or sets the album.
  13. /// </summary>
  14. /// <value>The album.</value>
  15. public string Album { get; set; }
  16. /// <summary>
  17. /// Gets or sets the budget.
  18. /// </summary>
  19. /// <value>The budget.</value>
  20. public double? Budget { get; set; }
  21. /// <summary>
  22. /// Gets or sets the revenue.
  23. /// </summary>
  24. /// <value>The revenue.</value>
  25. public double? Revenue { get; set; }
  26. public List<string> ProductionLocations { get; set; }
  27. public List<string> Artists { get; set; }
  28. public MusicVideo()
  29. {
  30. ProductionLocations = new List<string>();
  31. Artists = new List<string>();
  32. }
  33. [IgnoreDataMember]
  34. public List<string> AllArtists
  35. {
  36. get
  37. {
  38. return Artists;
  39. }
  40. }
  41. public override UnratedItem GetBlockUnratedType()
  42. {
  43. return UnratedItem.Music;
  44. }
  45. public MusicVideoInfo GetLookupInfo()
  46. {
  47. return GetItemLookupInfo<MusicVideoInfo>();
  48. }
  49. public override bool BeforeMetadataRefresh()
  50. {
  51. var hasChanges = base.BeforeMetadataRefresh();
  52. if (!ProductionYear.HasValue)
  53. {
  54. var info = LibraryManager.ParseName(Name);
  55. var yearInName = info.Year;
  56. if (yearInName.HasValue)
  57. {
  58. ProductionYear = yearInName;
  59. hasChanges = true;
  60. }
  61. else
  62. {
  63. // Try to get the year from the folder name
  64. if (!IsInMixedFolder)
  65. {
  66. info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
  67. yearInName = info.Year;
  68. if (yearInName.HasValue)
  69. {
  70. ProductionYear = yearInName;
  71. hasChanges = true;
  72. }
  73. }
  74. }
  75. }
  76. return hasChanges;
  77. }
  78. }
  79. }