jellyfin/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
2013-04-28 12:25:14 -04:00

42 lines
1.4 KiB
C#

using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using System.IO;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
{
/// <summary>
/// Class MusicArtistResolver
/// </summary>
public class MusicArtistResolver : ItemResolver<MusicArtist>
{
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public override ResolverPriority Priority
{
get { return ResolverPriority.Third; } // we need to be ahead of the generic folder resolver but behind the movie one
}
/// <summary>
/// Resolves the specified args.
/// </summary>
/// <param name="args">The args.</param>
/// <returns>MusicArtist.</returns>
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.Where(i => i.Attributes.HasFlag(FileAttributes.Directory)).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null;
}
}
}