2
0

MusicVideo.cs 3.0 KB

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