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