mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Apply review suggestions
This commit is contained in:
parent
ff18586beb
commit
08c68eb8dc
@ -90,25 +90,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
.Select(g => g.Key)
|
.Select(g => g.Key)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var musicbrainzAlbumArtistIds = songs
|
updateType |= setProviderIdFromSongs(item, songs, MetadataProvider.MusicBrainzAlbumArtist);
|
||||||
.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist))
|
|
||||||
.GroupBy(i => i)
|
|
||||||
.OrderByDescending(g => g.Count())
|
|
||||||
.Select(g => g.Key)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
var musicbrainzAlbumArtistId = item.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist);
|
|
||||||
if (musicbrainzAlbumArtistIds.Any())
|
|
||||||
{
|
|
||||||
var firstMusicbrainzAlbumArtistId = musicbrainzAlbumArtistIds[0];
|
|
||||||
if (!string.IsNullOrEmpty(firstMusicbrainzAlbumArtistId)
|
|
||||||
&& (string.IsNullOrEmpty(musicbrainzAlbumArtistId)
|
|
||||||
|| !musicbrainzAlbumArtistId.Equals(firstMusicbrainzAlbumArtistId, StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
item.SetProviderId(MetadataProvider.MusicBrainzAlbumArtist, firstMusicbrainzAlbumArtistId);
|
|
||||||
updateType |= ItemUpdateType.MetadataEdit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!item.AlbumArtists.SequenceEqual(albumArtists, StringComparer.OrdinalIgnoreCase))
|
if (!item.AlbumArtists.SequenceEqual(albumArtists, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
@ -143,45 +125,8 @@ namespace MediaBrowser.Providers.Music
|
|||||||
{
|
{
|
||||||
var updateType = ItemUpdateType.None;
|
var updateType = ItemUpdateType.None;
|
||||||
|
|
||||||
var musicbrainzAlbumIds = songs
|
updateType |= setProviderIdFromSongs(item, songs, MetadataProvider.MusicBrainzAlbum);
|
||||||
.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzAlbum))
|
updateType |= setProviderIdFromSongs(item, songs, MetadataProvider.MusicBrainzReleaseGroup);
|
||||||
.GroupBy(i => i)
|
|
||||||
.OrderByDescending(g => g.Count())
|
|
||||||
.Select(g => g.Key)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
var musicbrainzAlbumId = item.GetProviderId(MetadataProvider.MusicBrainzAlbum);
|
|
||||||
if (musicbrainzAlbumIds.Any())
|
|
||||||
{
|
|
||||||
var firstMusicbrainzAlbumId = musicbrainzAlbumIds[0];
|
|
||||||
if (!string.IsNullOrEmpty(firstMusicbrainzAlbumId)
|
|
||||||
&& (string.IsNullOrEmpty(musicbrainzAlbumId)
|
|
||||||
|| !musicbrainzAlbumId.Equals(firstMusicbrainzAlbumId, StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
item.SetProviderId(MetadataProvider.MusicBrainzAlbum, firstMusicbrainzAlbumId);
|
|
||||||
updateType |= ItemUpdateType.MetadataEdit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var musicbrainzReleaseGroupIds = songs
|
|
||||||
.Select(i => i.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup))
|
|
||||||
.GroupBy(i => i)
|
|
||||||
.OrderByDescending(g => g.Count())
|
|
||||||
.Select(g => g.Key)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
var musicbrainzReleaseGroupId = item.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup);
|
|
||||||
if (musicbrainzReleaseGroupIds.Any())
|
|
||||||
{
|
|
||||||
var firstMusicbrainzReleaseGroupId = musicbrainzReleaseGroupIds[0];
|
|
||||||
if (!string.IsNullOrEmpty(firstMusicbrainzReleaseGroupId)
|
|
||||||
&& (string.IsNullOrEmpty(musicbrainzReleaseGroupId)
|
|
||||||
|| !musicbrainzReleaseGroupId.Equals(firstMusicbrainzReleaseGroupId, StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
item.SetProviderId(MetadataProvider.MusicBrainzReleaseGroup, firstMusicbrainzReleaseGroupId);
|
|
||||||
updateType |= ItemUpdateType.MetadataEdit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateType;
|
return updateType;
|
||||||
}
|
}
|
||||||
@ -264,5 +209,29 @@ namespace MediaBrowser.Providers.Music
|
|||||||
targetItem.SetProviderId(provider, source);
|
targetItem.SetProviderId(provider, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ItemUpdateType setProviderIdFromSongs(BaseItem item, IReadOnlyList<Audio> songs, MetadataProvider provider)
|
||||||
|
{
|
||||||
|
var ids = songs
|
||||||
|
.Select(i => i.GetProviderId(provider))
|
||||||
|
.GroupBy(i => i)
|
||||||
|
.OrderByDescending(g => g.Count())
|
||||||
|
.Select(g => g.Key)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var id = item.GetProviderId(provider);
|
||||||
|
if (ids.Any())
|
||||||
|
{
|
||||||
|
var firstId = ids[0];
|
||||||
|
if (!string.IsNullOrEmpty(firstId)
|
||||||
|
&& (string.IsNullOrEmpty(id)
|
||||||
|
|| !id.Equals(firstId, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
item.SetProviderId(provider, firstId);
|
||||||
|
return ItemUpdateType.MetadataEdit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ItemUpdateType.None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user