using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
{
///
/// Class MusicArtistResolver
///
public class MusicArtistResolver : ItemResolver
{
///
/// Gets the priority.
///
/// The priority.
public override ResolverPriority Priority
{
get { return ResolverPriority.Third; } // we need to be ahead of the generic folder resolver but behind the movie one
}
///
/// Resolves the specified args.
///
/// The args.
/// MusicArtist.
protected override MusicArtist Resolve(ItemResolveArgs args)
{
if (!args.IsDirectory) return null;
//Avoid mis-identifying top folders
if (args.Parent == null) return null;
if (args.Parent.IsRoot) return null;
// If we contain an album assume we are an artist folder
return args.FileSystemChildren.Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null;
}
}
}