| | | 1 | | #pragma warning disable CS1591 |
| | | 2 | | |
| | | 3 | | using System.Linq; |
| | | 4 | | using MediaBrowser.Controller.Providers; |
| | | 5 | | using MediaBrowser.Model.Entities; |
| | | 6 | | |
| | | 7 | | namespace MediaBrowser.Providers.Music |
| | | 8 | | { |
| | | 9 | | public static class AlbumInfoExtensions |
| | | 10 | | { |
| | | 11 | | public static string? GetAlbumArtist(this AlbumInfo info) |
| | | 12 | | { |
| | 0 | 13 | | var id = info.SongInfos.SelectMany(i => i.AlbumArtists) |
| | 0 | 14 | | .FirstOrDefault(i => !string.IsNullOrEmpty(i)); |
| | | 15 | | |
| | 0 | 16 | | if (!string.IsNullOrEmpty(id)) |
| | | 17 | | { |
| | 0 | 18 | | return id; |
| | | 19 | | } |
| | | 20 | | |
| | 0 | 21 | | return info.AlbumArtists.Count > 0 ? info.AlbumArtists[0] : default; |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | public static string? GetReleaseGroupId(this AlbumInfo info) |
| | | 25 | | { |
| | 0 | 26 | | var id = info.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup); |
| | | 27 | | |
| | 0 | 28 | | if (string.IsNullOrEmpty(id)) |
| | | 29 | | { |
| | 0 | 30 | | return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup)) |
| | 0 | 31 | | .FirstOrDefault(i => !string.IsNullOrEmpty(i)); |
| | | 32 | | } |
| | | 33 | | |
| | 0 | 34 | | return id; |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | public static string? GetReleaseId(this AlbumInfo info) |
| | | 38 | | { |
| | 0 | 39 | | var id = info.GetProviderId(MetadataProvider.MusicBrainzAlbum); |
| | | 40 | | |
| | 0 | 41 | | if (string.IsNullOrEmpty(id)) |
| | | 42 | | { |
| | 0 | 43 | | return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbum)) |
| | 0 | 44 | | .FirstOrDefault(i => !string.IsNullOrEmpty(i)); |
| | | 45 | | } |
| | | 46 | | |
| | 0 | 47 | | return id; |
| | | 48 | | } |
| | | 49 | | |
| | | 50 | | public static string? GetMusicBrainzArtistId(this AlbumInfo info) |
| | | 51 | | { |
| | 0 | 52 | | info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzAlbumArtist.ToString(), out string? id); |
| | | 53 | | |
| | 0 | 54 | | if (string.IsNullOrEmpty(id)) |
| | | 55 | | { |
| | 0 | 56 | | info.ArtistProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out id); |
| | | 57 | | } |
| | | 58 | | |
| | 0 | 59 | | if (string.IsNullOrEmpty(id)) |
| | | 60 | | { |
| | 0 | 61 | | return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist)) |
| | 0 | 62 | | .FirstOrDefault(i => !string.IsNullOrEmpty(i)); |
| | | 63 | | } |
| | | 64 | | |
| | 0 | 65 | | return id; |
| | | 66 | | } |
| | | 67 | | |
| | | 68 | | public static string? GetMusicBrainzArtistId(this ArtistInfo info) |
| | | 69 | | { |
| | 0 | 70 | | info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out var id); |
| | | 71 | | |
| | 0 | 72 | | if (string.IsNullOrEmpty(id)) |
| | | 73 | | { |
| | 0 | 74 | | return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist)) |
| | 0 | 75 | | .FirstOrDefault(i => !string.IsNullOrEmpty(i)); |
| | | 76 | | } |
| | | 77 | | |
| | 0 | 78 | | return id; |
| | | 79 | | } |
| | | 80 | | } |
| | | 81 | | } |