2020-06-19 14:24:13 -04:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 15:03:10 -05:00
|
|
|
using System.Linq;
|
2019-01-13 14:26:31 -05:00
|
|
|
using MediaBrowser.Controller.Providers;
|
2014-02-07 17:40:03 -05:00
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Music
|
|
|
|
{
|
|
|
|
public static class Extensions
|
|
|
|
{
|
|
|
|
public static string GetAlbumArtist(this AlbumInfo info)
|
|
|
|
{
|
2014-08-28 20:49:25 -04:00
|
|
|
var id = info.SongInfos.SelectMany(i => i.AlbumArtists)
|
|
|
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
2014-02-07 17:40:03 -05:00
|
|
|
|
2014-08-28 20:49:25 -04:00
|
|
|
if (!string.IsNullOrEmpty(id))
|
2014-02-07 17:40:03 -05:00
|
|
|
{
|
2014-08-28 20:49:25 -04:00
|
|
|
return id;
|
2014-02-07 17:40:03 -05:00
|
|
|
}
|
|
|
|
|
2014-08-28 20:49:25 -04:00
|
|
|
return info.AlbumArtists.FirstOrDefault();
|
2014-02-07 17:40:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetReleaseGroupId(this AlbumInfo info)
|
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
var id = info.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup);
|
2014-02-07 17:40:03 -05:00
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(id))
|
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup))
|
2014-02-07 17:40:03 -05:00
|
|
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetReleaseId(this AlbumInfo info)
|
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
var id = info.GetProviderId(MetadataProvider.MusicBrainzAlbum);
|
2014-02-07 17:40:03 -05:00
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(id))
|
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbum))
|
2014-02-07 17:40:03 -05:00
|
|
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2014-02-09 02:27:44 -05:00
|
|
|
public static string GetMusicBrainzArtistId(this AlbumInfo info)
|
2014-02-07 17:40:03 -05:00
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzAlbumArtist.ToString(), out string id);
|
2014-02-07 17:40:03 -05:00
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(id))
|
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
info.ArtistProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out id);
|
2014-02-07 17:40:03 -05:00
|
|
|
}
|
2019-01-07 18:27:46 -05:00
|
|
|
|
2014-02-07 17:40:03 -05:00
|
|
|
if (string.IsNullOrEmpty(id))
|
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist))
|
2014-02-07 17:40:03 -05:00
|
|
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
2014-02-08 15:02:35 -05:00
|
|
|
|
2014-02-09 02:27:44 -05:00
|
|
|
public static string GetMusicBrainzArtistId(this ArtistInfo info)
|
2014-02-08 15:02:35 -05:00
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
info.ProviderIds.TryGetValue(MetadataProvider.MusicBrainzArtist.ToString(), out var id);
|
2014-02-08 15:02:35 -05:00
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(id))
|
|
|
|
{
|
2020-06-06 15:17:49 -04:00
|
|
|
return info.SongInfos.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist))
|
2014-02-08 15:02:35 -05:00
|
|
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
2014-02-07 17:40:03 -05:00
|
|
|
}
|
|
|
|
}
|