MusicVideo.cs 2.1 KB

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