You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.6 KiB
82 lines
2.6 KiB
4 years ago
|
#pragma warning disable CS1591
|
||
|
|
||
6 years ago
|
using System.Linq;
|
||
6 years ago
|
using MediaBrowser.Controller.Providers;
|
||
11 years ago
|
using MediaBrowser.Model.Entities;
|
||
|
|
||
|
namespace MediaBrowser.Providers.Music
|
||
|
{
|
||
4 years ago
|
public static class AlbumInfoExtensions
|
||
11 years ago
|
{
|
||
|
public static string GetAlbumArtist(this AlbumInfo info)
|
||
|
{
|
||
10 years ago
|
var id = info.SongInfos.SelectMany(i => i.AlbumArtists)
|
||
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||
11 years ago
|
|
||
10 years ago
|
if (!string.IsNullOrEmpty(id))
|
||
11 years ago
|
{
|
||
10 years ago
|
return id;
|
||
11 years ago
|
}
|
||
|
|
||
4 years ago
|
return info.AlbumArtists.Count > 0 ? info.AlbumArtists[0] : default;
|
||
11 years ago
|
}
|
||
|
|
||
|
public static string GetReleaseGroupId(this AlbumInfo info)
|
||
|
{
|
||
5 years ago
|
var id = info.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup);
|
||
11 years ago
|
|
||
|
if (string.IsNullOrEmpty(id))
|
||
|
{
|
||
5 years ago
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup))
|
||
11 years ago
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||
|
}
|
||
|
|
||
|
return id;
|
||
|
}
|
||
|
|
||
|
public static string GetReleaseId(this AlbumInfo info)
|
||
|
{
|
||
5 years ago
|
var id = info.GetProviderId(MetadataProvider.MusicBrainzAlbum);
|
||
11 years ago
|
|
||
|
if (string.IsNullOrEmpty(id))
|
||
|
{
|
||
5 years ago
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbum))
|
||
11 years ago
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||
|
}
|
||
|
|
||
|
return id;
|
||
|
}
|
||
|
|
||
11 years ago
|
public static string GetMusicBrainzArtistId(this AlbumInfo info)
|
||
11 years ago
|
{
|
||
5 years ago
|
info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzAlbumArtist.ToString(), out string id);
|
||
11 years ago
|
|
||
|
if (string.IsNullOrEmpty(id))
|
||
|
{
|
||
5 years ago
|
info.ArtistProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out id);
|
||
11 years ago
|
}
|
||
6 years ago
|
|
||
11 years ago
|
if (string.IsNullOrEmpty(id))
|
||
|
{
|
||
5 years ago
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist))
|
||
11 years ago
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||
|
}
|
||
|
|
||
|
return id;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
public static string GetMusicBrainzArtistId(this ArtistInfo info)
|
||
11 years ago
|
{
|
||
5 years ago
|
info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out var id);
|
||
11 years ago
|
|
||
|
if (string.IsNullOrEmpty(id))
|
||
|
{
|
||
5 years ago
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist))
|
||
11 years ago
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||
|
}
|
||
|
|
||
|
return id;
|
||
|
}
|
||
11 years ago
|
}
|
||
|
}
|