using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Entities.Audio
{
///
/// Class MusicArtist
///
public class MusicArtist : Folder, IItemByName, IHasMusicGenres, IHasDualAccess, IHasTags, IHasProductionLocations
{
[IgnoreDataMember]
public List UserItemCountList { get; set; }
public bool IsAccessedByName { get; set; }
///
/// Gets or sets the tags.
///
/// The tags.
public List Tags { get; set; }
public List ProductionLocations { get; set; }
public override bool IsFolder
{
get
{
return !IsAccessedByName;
}
}
protected override IEnumerable ActualChildren
{
get
{
if (IsAccessedByName)
{
return new List();
}
return base.ActualChildren;
}
}
protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false)
{
if (IsAccessedByName)
{
// Should never get in here anyway
return Task.FromResult(true);
}
return base.ValidateChildrenInternal(progress, cancellationToken, recursive, forceRefreshMetadata);
}
public override string GetClientTypeName()
{
if (IsAccessedByName)
{
//return "Artist";
}
return base.GetClientTypeName();
}
///
/// Gets or sets the last fm image URL.
///
/// The last fm image URL.
public string LastFmImageUrl { get; set; }
public string LastFmImageSize { get; set; }
public MusicArtist()
{
UserItemCountList = new List();
Tags = new List();
ProductionLocations = new List();
}
///
/// Gets the user data key.
///
/// System.String.
public override string GetUserDataKey()
{
return GetUserDataKey(this);
}
///
/// Gets the user data key.
///
/// The item.
/// System.String.
private static string GetUserDataKey(MusicArtist item)
{
var id = item.GetProviderId(MetadataProviders.Musicbrainz);
if (!string.IsNullOrEmpty(id))
{
return "Artist-Musicbrainz-" + id;
}
return "Artist-" + item.Name;
}
protected override bool GetBlockUnratedValue(UserConfiguration config)
{
return config.BlockUnratedMusic;
}
}
}