2016-03-27 23:11:27 +02:00
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-03-03 17:53:58 +01:00
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
2013-07-27 20:24:48 +02:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2018-12-13 14:18:25 +01:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2013-07-27 20:24:48 +02:00
|
|
|
|
using System;
|
2013-04-28 18:25:14 +02:00
|
|
|
|
using System.IO;
|
2013-04-28 02:44:38 +02:00
|
|
|
|
using System.Linq;
|
2017-05-26 08:48:54 +02:00
|
|
|
|
|
2016-10-25 21:02:04 +02:00
|
|
|
|
using MediaBrowser.Model.IO;
|
2016-10-07 17:08:13 +02:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2016-10-25 21:02:04 +02:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
|
2016-11-03 07:37:52 +01:00
|
|
|
|
namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2013-02-23 08:57:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class MusicArtistResolver
|
|
|
|
|
/// </summary>
|
2013-03-03 07:58:04 +01:00
|
|
|
|
public class MusicArtistResolver : ItemResolver<MusicArtist>
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2014-07-26 19:30:15 +02:00
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IFileSystem _fileSystem;
|
2014-11-16 21:44:08 +01:00
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
2016-10-07 17:08:13 +02:00
|
|
|
|
private readonly IServerConfigurationManager _config;
|
2014-07-26 19:30:15 +02:00
|
|
|
|
|
2016-10-07 17:08:13 +02:00
|
|
|
|
public MusicArtistResolver(ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager, IServerConfigurationManager config)
|
2014-07-26 19:30:15 +02:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_fileSystem = fileSystem;
|
2014-11-16 21:44:08 +01:00
|
|
|
|
_libraryManager = libraryManager;
|
2016-10-07 17:08:13 +02:00
|
|
|
|
_config = config;
|
2014-07-26 19:30:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-23 08:57:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the priority.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The priority.</value>
|
2013-02-21 02:33:05 +01:00
|
|
|
|
public override ResolverPriority Priority
|
|
|
|
|
{
|
2014-12-20 07:06:27 +01:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// Behind special folder resolver
|
|
|
|
|
return ResolverPriority.Second;
|
|
|
|
|
}
|
2013-02-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-23 08:57:11 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves the specified args.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
|
/// <returns>MusicArtist.</returns>
|
2013-02-21 02:33:05 +01:00
|
|
|
|
protected override MusicArtist Resolve(ItemResolveArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (!args.IsDirectory) return null;
|
|
|
|
|
|
2013-06-02 14:43:53 +02:00
|
|
|
|
// Don't allow nested artists
|
2014-12-15 06:16:23 +01:00
|
|
|
|
if (args.HasParent<MusicArtist>() || args.HasParent<MusicAlbum>())
|
2013-06-02 14:43:53 +02:00
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-04 19:07:35 +02:00
|
|
|
|
var collectionType = args.GetCollectionType();
|
2013-07-27 20:24:48 +02:00
|
|
|
|
|
2014-12-20 07:06:27 +01:00
|
|
|
|
var isMusicMediaFolder = string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase);
|
2014-07-30 05:31:35 +02:00
|
|
|
|
|
2013-07-27 20:24:48 +02:00
|
|
|
|
// If there's a collection type and it's not music, it can't be a series
|
2014-07-30 05:31:35 +02:00
|
|
|
|
if (!isMusicMediaFolder)
|
2013-07-27 20:24:48 +02:00
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-02-13 06:11:54 +01:00
|
|
|
|
|
2016-10-09 09:18:43 +02:00
|
|
|
|
if (args.ContainsFileSystemEntryByName("artist.nfo"))
|
2016-10-07 17:08:13 +02:00
|
|
|
|
{
|
2016-10-09 09:18:43 +02:00
|
|
|
|
return new MusicArtist();
|
2016-10-07 17:08:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 19:50:33 +01:00
|
|
|
|
if (_config.Configuration.EnableSimpleArtistDetection)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2016-10-07 17:08:13 +02:00
|
|
|
|
|
2017-02-08 19:50:33 +01:00
|
|
|
|
// Avoid mis-identifying top folders
|
|
|
|
|
if (args.Parent.IsRoot) return null;
|
2016-10-09 09:18:43 +02:00
|
|
|
|
|
2017-02-08 19:50:33 +01:00
|
|
|
|
var directoryService = args.DirectoryService;
|
2015-01-10 06:53:35 +01:00
|
|
|
|
|
2017-02-08 19:50:33 +01:00
|
|
|
|
var albumResolver = new MusicAlbumResolver(_logger, _fileSystem, _libraryManager);
|
2015-01-10 06:53:35 +01:00
|
|
|
|
|
2017-02-08 19:50:33 +01:00
|
|
|
|
// If we contain an album assume we are an artist folder
|
|
|
|
|
return args.FileSystemChildren.Where(i => i.IsDirectory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService, args.GetLibraryOptions())) ? new MusicArtist() : null;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|