Beispiel #1
0
        /// <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);
            }

            // Don't allow nested artists
            if (args.HasParent <MusicArtist>() || args.HasParent <MusicAlbum>())
            {
                return(null);
            }

            var collectionType = args.GetCollectionType();

            var isMusicMediaFolder = string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase);

            // If there's a collection type and it's not music, it can't be a series
            if (!isMusicMediaFolder)
            {
                return(null);
            }

            if (args.ContainsFileSystemEntryByName("artist.nfo"))
            {
                return(new MusicArtist());
            }

            if (_config.Configuration.EnableSimpleArtistDetection)
            {
                return(null);
            }

            // Avoid mis-identifying top folders
            if (args.Parent.IsRoot)
            {
                return(null);
            }

            var directoryService = args.DirectoryService;

            var albumResolver = new MusicAlbumResolver(_logger, _fileSystem, _libraryManager);

            // If we contain an album assume we are an artist folder
            return(args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => albumResolver.IsMusicAlbum(i.FullName, directoryService, args.GetLibraryOptions())) ? new MusicArtist() : null);
        }
Beispiel #2
0
        /// <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);
            }

            // Don't allow nested artists
            if (args.Parent is MusicArtist)
            {
                return(null);
            }

            // Optimization
            if (args.Parent is BoxSet || args.Parent is Series || args.Parent is Season)
            {
                return(null);
            }

            var collectionType = args.GetCollectionType();

            // 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);
            }

            var directoryService = args.DirectoryService;

            // If we contain an album assume we are an artist folder
            return(args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName, directoryService)) ? new MusicArtist() : null);
        }
        /// <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);
            }

            // Don't allow nested artists
            if (args.Parent is MusicArtist)
            {
                return(null);
            }

            // If we contain an album assume we are an artist folder
            return(args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null);
        }