2013-10-01 16:33:50 -07:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-09-10 13:23:41 -07:00
|
|
|
|
using MediaBrowser.Model.Dto;
|
2013-10-01 16:33:50 -07:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2013-09-10 11:56:00 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-10-01 16:33:50 -07:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Linq;
|
2013-10-01 11:31:32 -07:00
|
|
|
|
using System.Runtime.Serialization;
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2013-04-20 18:02:16 -07:00
|
|
|
|
namespace MediaBrowser.Controller.Entities.Audio
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class Artist
|
|
|
|
|
/// </summary>
|
2013-09-10 11:56:00 -07:00
|
|
|
|
public class Artist : BaseItem, IItemByName, IHasMusicGenres
|
2013-04-20 18:02:16 -07:00
|
|
|
|
{
|
2013-09-10 11:56:00 -07:00
|
|
|
|
public Artist()
|
|
|
|
|
{
|
|
|
|
|
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 08:23:20 -07:00
|
|
|
|
public string LastFmImageUrl { get; set; }
|
2013-11-06 09:29:20 -07:00
|
|
|
|
public string LastFmImageSize { get; set; }
|
2013-10-04 17:44:43 -07:00
|
|
|
|
|
2013-04-20 18:02:16 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the user data key.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public override string GetUserDataKey()
|
|
|
|
|
{
|
2013-10-01 16:33:50 -07:00
|
|
|
|
return GetUserDataKey(this);
|
2013-04-20 18:02:16 -07:00
|
|
|
|
}
|
2013-04-24 07:05:47 -07:00
|
|
|
|
|
2013-09-10 13:23:41 -07:00
|
|
|
|
[IgnoreDataMember]
|
2013-09-10 11:56:00 -07:00
|
|
|
|
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
|
2013-10-01 11:31:32 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the music artist.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="artist">The artist.</param>
|
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
|
|
|
|
/// <returns>MusicArtist.</returns>
|
|
|
|
|
public static MusicArtist FindMusicArtist(Artist artist, ILibraryManager libraryManager)
|
|
|
|
|
{
|
|
|
|
|
return FindMusicArtist(artist, libraryManager.RootFolder.RecursiveChildren.OfType<MusicArtist>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the music artist.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="artist">The artist.</param>
|
|
|
|
|
/// <param name="allMusicArtists">All music artists.</param>
|
|
|
|
|
/// <returns>MusicArtist.</returns>
|
|
|
|
|
public static MusicArtist FindMusicArtist(Artist artist, IEnumerable<MusicArtist> allMusicArtists)
|
|
|
|
|
{
|
|
|
|
|
var musicBrainzId = artist.GetProviderId(MetadataProviders.Musicbrainz);
|
|
|
|
|
|
|
|
|
|
return allMusicArtists.FirstOrDefault(i =>
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(musicBrainzId) && string.Equals(musicBrainzId, i.GetProviderId(MetadataProviders.Musicbrainz), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Compare(i.Name, artist.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0;
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-10-01 16:33:50 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the user data key.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public static string GetUserDataKey(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
var id = item.GetProviderId(MetadataProviders.Musicbrainz);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(id))
|
|
|
|
|
{
|
2013-10-04 17:44:43 -07:00
|
|
|
|
return "Artist-Musicbrainz-" + id;
|
2013-10-01 16:33:50 -07:00
|
|
|
|
}
|
2013-10-04 17:44:43 -07:00
|
|
|
|
|
2013-10-01 16:33:50 -07:00
|
|
|
|
return "Artist-" + item.Name;
|
|
|
|
|
}
|
2013-04-20 18:02:16 -07:00
|
|
|
|
}
|
|
|
|
|
}
|