fixes #379 - artist images don't show on web interface

This commit is contained in:
Luke Pulverenti 2013-08-14 10:05:55 -04:00
parent f064d6c9c7
commit ab70effd5e
2 changed files with 41 additions and 12 deletions

View File

@ -56,22 +56,37 @@ namespace MediaBrowser.Providers.Music
if (musicArtist != null) if (musicArtist != null)
{ {
artist.Images = new Dictionary<ImageType, string>(musicArtist.Images); MergeImages(musicArtist.Images, artist.Images);
artist.BackdropImagePaths = musicArtist.BackdropImagePaths.ToList(); // Merge backdrops
artist.ScreenshotImagePaths = musicArtist.ScreenshotImagePaths.ToList(); var backdrops = musicArtist.BackdropImagePaths.ToList();
artist.SetProviderId(MetadataProviders.Musicbrainz, musicArtist.GetProviderId(MetadataProviders.Musicbrainz)); backdrops.InsertRange(0, artist.BackdropImagePaths);
artist.Genres = musicArtist.Genres.ToList(); artist.BackdropImagePaths = backdrops.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
if (!artist.LockedFields.Contains(MetadataFields.Genres))
{
// Merge genres
var genres = musicArtist.Genres.ToList();
genres.InsertRange(0, artist.Genres);
artist.Genres = genres.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
artist.Genres = musicArtist.Genres.ToList();
}
} }
else else
{ {
// Avoid implicitly captured closure if (!artist.LockedFields.Contains(MetadataFields.Genres))
var artist1 = artist; {
// Avoid implicitly captured closure
var artist1 = artist;
artist.Genres = allSongs.Where(i => i.HasArtist(artist1.Name)) artist.Genres = allSongs.Where(i => i.HasArtist(artist1.Name))
.SelectMany(i => i.Genres) .SelectMany(i => i.Genres)
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList(); .ToList();
}
} }
numComplete++; numComplete++;
@ -89,6 +104,21 @@ namespace MediaBrowser.Providers.Music
await _libraryManager.ValidateArtists(cancellationToken, innerProgress).ConfigureAwait(false); await _libraryManager.ValidateArtists(cancellationToken, innerProgress).ConfigureAwait(false);
} }
private void MergeImages(Dictionary<ImageType, string> source, Dictionary<ImageType, string> target)
{
foreach (var key in source.Keys
.ToList()
.Where(k => !target.ContainsKey(k)))
{
string path;
if (source.TryGetValue(key, out path))
{
target[key] = path;
}
}
}
/// <summary> /// <summary>
/// Gets all artists. /// Gets all artists.
/// </summary> /// </summary>

View File

@ -40,7 +40,6 @@ namespace MediaBrowser.Providers.Music
target.Tags = source.Tags.ToList(); target.Tags = source.Tags.ToList();
target.Overview = source.Overview; target.Overview = source.Overview;
target.ProductionLocations = source.ProductionLocations.ToList(); target.ProductionLocations = source.ProductionLocations.ToList();
target.Genres = source.Genres.ToList();
} }
public static void ProcessAlbumData(BaseItem item, LastfmAlbum data) public static void ProcessAlbumData(BaseItem item, LastfmAlbum data)