MusicVideo.cs 2.0 KB

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