2013-02-20 20:33:05 -05:00
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2013-09-17 22:43:34 -04:00
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-03-03 11:53:58 -05:00
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
2013-07-27 14:24:48 -04:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
|
using System;
|
2013-04-28 12:25:14 -04:00
|
|
|
|
using System.IO;
|
2013-04-27 20:44:38 -04:00
|
|
|
|
using System.Linq;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2013-03-03 01:58:04 -05:00
|
|
|
|
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2013-02-23 02:57:11 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Class MusicArtistResolver
|
|
|
|
|
|
/// </summary>
|
2013-03-03 01:58:04 -05:00
|
|
|
|
public class MusicArtistResolver : ItemResolver<MusicArtist>
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2013-02-23 02:57:11 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the priority.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>The priority.</value>
|
2013-02-20 20:33:05 -05:00
|
|
|
|
public override ResolverPriority Priority
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ResolverPriority.Third; } // we need to be ahead of the generic folder resolver but behind the movie one
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-02-23 02:57:11 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Resolves the specified args.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
|
|
/// <returns>MusicArtist.</returns>
|
2013-02-20 20:33:05 -05:00
|
|
|
|
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;
|
|
|
|
|
|
|
2013-06-02 08:43:53 -04:00
|
|
|
|
// Don't allow nested artists
|
|
|
|
|
|
if (args.Parent is MusicArtist)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-17 22:43:34 -04:00
|
|
|
|
// Optimization
|
|
|
|
|
|
if (args.Parent is BoxSet || args.Parent is Series || args.Parent is Season)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-09-04 13:07:35 -04:00
|
|
|
|
var collectionType = args.GetCollectionType();
|
2013-07-27 14:24:48 -04:00
|
|
|
|
|
|
|
|
|
|
// If there's a collection type and it's not music, it can't be a series
|
|
|
|
|
|
if (!string.IsNullOrEmpty(collectionType) &&
|
|
|
|
|
|
!string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2014-02-13 00:11:54 -05:00
|
|
|
|
|
|
|
|
|
|
var directoryService = args.DirectoryService;
|
2013-07-27 14:24:48 -04:00
|
|
|
|
|
2013-02-20 20:33:05 -05:00
|
|
|
|
// If we contain an album assume we are an artist folder
|
2014-02-13 00:11:54 -05:00
|
|
|
|
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, directoryService)) ? new MusicArtist() : null;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|