MusicVideo.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. [IgnoreDataMember]
  11. public List<string> Artists { get; set; }
  12. public MusicVideo()
  13. {
  14. Artists = new List<string>();
  15. }
  16. [IgnoreDataMember]
  17. public List<string> AllArtists
  18. {
  19. get
  20. {
  21. return Artists;
  22. }
  23. }
  24. public override UnratedItem GetBlockUnratedType()
  25. {
  26. return UnratedItem.Music;
  27. }
  28. public MusicVideoInfo GetLookupInfo()
  29. {
  30. return GetItemLookupInfo<MusicVideoInfo>();
  31. }
  32. public override bool BeforeMetadataRefresh()
  33. {
  34. var hasChanges = base.BeforeMetadataRefresh();
  35. if (!ProductionYear.HasValue)
  36. {
  37. var info = LibraryManager.ParseName(Name);
  38. var yearInName = info.Year;
  39. if (yearInName.HasValue)
  40. {
  41. ProductionYear = yearInName;
  42. hasChanges = true;
  43. }
  44. else
  45. {
  46. // Try to get the year from the folder name
  47. if (!IsInMixedFolder)
  48. {
  49. info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
  50. yearInName = info.Year;
  51. if (yearInName.HasValue)
  52. {
  53. ProductionYear = yearInName;
  54. hasChanges = true;
  55. }
  56. }
  57. }
  58. }
  59. return hasChanges;
  60. }
  61. }
  62. }