MusicVideo.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using MediaBrowser.Controller.Entities.Audio;
  2. using MediaBrowser.Controller.Providers;
  3. using MediaBrowser.Model.Configuration;
  4. using System.Collections.Generic;
  5. using MediaBrowser.Model.Serialization;
  6. namespace MediaBrowser.Controller.Entities
  7. {
  8. public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasLookupInfo<MusicVideoInfo>
  9. {
  10. public List<string> Artists { get; set; }
  11. public MusicVideo()
  12. {
  13. Artists = new List<string>();
  14. }
  15. [IgnoreDataMember]
  16. public List<string> AllArtists
  17. {
  18. get
  19. {
  20. return Artists;
  21. }
  22. }
  23. public override UnratedItem GetBlockUnratedType()
  24. {
  25. return UnratedItem.Music;
  26. }
  27. public MusicVideoInfo GetLookupInfo()
  28. {
  29. return GetItemLookupInfo<MusicVideoInfo>();
  30. }
  31. public override bool BeforeMetadataRefresh()
  32. {
  33. var hasChanges = base.BeforeMetadataRefresh();
  34. if (!ProductionYear.HasValue)
  35. {
  36. var info = LibraryManager.ParseName(Name);
  37. var yearInName = info.Year;
  38. if (yearInName.HasValue)
  39. {
  40. ProductionYear = yearInName;
  41. hasChanges = true;
  42. }
  43. else
  44. {
  45. // Try to get the year from the folder name
  46. if (!IsInMixedFolder)
  47. {
  48. info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
  49. yearInName = info.Year;
  50. if (yearInName.HasValue)
  51. {
  52. ProductionYear = yearInName;
  53. hasChanges = true;
  54. }
  55. }
  56. }
  57. }
  58. return hasChanges;
  59. }
  60. }
  61. }