jellyfin-server/MediaBrowser.Providers/Music/Extensions.cs

80 lines
2.5 KiB
C#
Raw Normal View History

using System.Linq;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Providers.Music
{
public static class Extensions
{
public static string GetAlbumArtist(this AlbumInfo info)
{
var id = info.SongInfos.SelectMany(i => i.AlbumArtists)
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
if (!string.IsNullOrEmpty(id))
{
return id;
}
return info.AlbumArtists.FirstOrDefault();
}
public static string GetReleaseGroupId(this AlbumInfo info)
{
2020-06-06 19:17:49 +00:00
var id = info.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup);
if (string.IsNullOrEmpty(id))
{
2020-06-06 19:17:49 +00:00
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup))
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
}
return id;
}
public static string GetReleaseId(this AlbumInfo info)
{
2020-06-06 19:17:49 +00:00
var id = info.GetProviderId(MetadataProvider.MusicBrainzAlbum);
if (string.IsNullOrEmpty(id))
{
2020-06-06 19:17:49 +00:00
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbum))
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
}
return id;
}
2014-02-09 07:27:44 +00:00
public static string GetMusicBrainzArtistId(this AlbumInfo info)
{
2020-06-06 19:17:49 +00:00
info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzAlbumArtist.ToString(), out string id);
if (string.IsNullOrEmpty(id))
{
2020-06-06 19:17:49 +00:00
info.ArtistProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out id);
}
2019-01-07 23:27:46 +00:00
if (string.IsNullOrEmpty(id))
{
2020-06-06 19:17:49 +00:00
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist))
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
}
return id;
}
2014-02-08 20:02:35 +00:00
2014-02-09 07:27:44 +00:00
public static string GetMusicBrainzArtistId(this ArtistInfo info)
2014-02-08 20:02:35 +00:00
{
2020-06-06 19:17:49 +00:00
info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out var id);
2014-02-08 20:02:35 +00:00
if (string.IsNullOrEmpty(id))
{
2020-06-06 19:17:49 +00:00
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist))
2014-02-08 20:02:35 +00:00
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
}
return id;
}
}
}