Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether [is multi disc album folder] [the specified path].
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns><c>true</c> if [is multi disc album folder] [the specified path]; otherwise, <c>false</c>.</returns>
        private static bool IsMultiDiscAlbumFolder(string path)
        {
            var parser = new AlbumParser(new ExtendedNamingOptions(), new Naming.Logging.NullLogger());
            var result = parser.ParseMultiPart(path);

            return(result.IsMultiPart);
        }
Ejemplo n.º 2
0
        private bool IsMultiDiscFolder(string path, LibraryOptions libraryOptions)
        {
            var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();

            var parser = new AlbumParser(namingOptions);
            var result = parser.ParseMultiPart(path);

            return result.IsMultiPart;
        }
Ejemplo n.º 3
0
        private bool IsMultiDiscFolder(string path)
        {
            var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();

            var parser = new AlbumParser(namingOptions, new PatternsLogger());
            var result = parser.ParseMultiPart(path);

            return(result.IsMultiPart);
        }
Ejemplo n.º 4
0
        private bool ContainsMusic(
            IEnumerable <FileSystemMetadata> list,
            bool allowSubfolders,
            IDirectoryService directoryService,
            ILogger <MusicAlbumResolver> logger,
            IFileSystem fileSystem,
            ILibraryManager libraryManager)
        {
            // check for audio files before digging down into directories
            var foundAudioFile = list.Any(fileSystemInfo => !fileSystemInfo.IsDirectory && libraryManager.IsAudioFile(fileSystemInfo.FullName));

            if (foundAudioFile)
            {
                // at least one audio file exists
                return(true);
            }

            if (!allowSubfolders)
            {
                // not music since no audio file exists and we're not looking into subfolders
                return(false);
            }

            var discSubfolderCount = 0;

            var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
            var parser        = new AlbumParser(namingOptions);

            var directories = list.Where(fileSystemInfo => fileSystemInfo.IsDirectory);

            var result = Parallel.ForEach(directories, (fileSystemInfo, state) =>
            {
                var path     = fileSystemInfo.FullName;
                var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);

                if (hasMusic)
                {
                    if (parser.IsMultiPart(path))
                    {
                        logger.LogDebug("Found multi-disc folder: " + path);
                        Interlocked.Increment(ref discSubfolderCount);
                    }
                    else
                    {
                        // If there are folders underneath with music that are not multidisc, then this can't be a multi-disc album
                        state.Stop();
                    }
                }
            });

            if (!result.IsCompleted)
            {
                return(false);
            }

            return(discSubfolderCount > 0);
        }
        private bool IsMultiDiscAlbumFolder(string path)
        {
            var parser = new AlbumParser(new NamingOptions(), new NullLogger());

            return(parser.ParseMultiPart(path).IsMultiPart);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Determine if the supplied list contains what we should consider music.
        /// </summary>
        private bool ContainsMusic(
            IEnumerable <FileSystemMetadata> list,
            bool allowSubfolders,
            IDirectoryService directoryService,
            ILogger logger,
            IFileSystem fileSystem,
            ILibraryManager libraryManager)
        {
            var discSubfolderCount = 0;
            var notMultiDisc       = false;

            var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
            var parser        = new AlbumParser(namingOptions);

            foreach (var fileSystemInfo in list)
            {
                if (fileSystemInfo.IsDirectory)
                {
                    if (allowSubfolders)
                    {
                        if (notMultiDisc)
                        {
                            continue;
                        }

                        var path     = fileSystemInfo.FullName;
                        var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);

                        if (hasMusic)
                        {
                            if (parser.IsMultiPart(path))
                            {
                                logger.LogDebug("Found multi-disc folder: " + path);
                                discSubfolderCount++;
                            }
                            else
                            {
                                // If there are folders underneath with music that are not multidisc, then this can't be a multi-disc album
                                notMultiDisc = true;
                            }
                        }
                    }
                }
                else
                {
                    var fullName = fileSystemInfo.FullName;

                    if (libraryManager.IsAudioFile(fullName))
                    {
                        return(true);
                    }
                }
            }

            if (notMultiDisc)
            {
                return(false);
            }

            return(discSubfolderCount > 0);
        }
Ejemplo n.º 7
0
        public void AlbumParser_MultidiscPath_Identifies(string path, bool result)
        {
            var parser = new AlbumParser(_namingOptions);

            Assert.Equal(result, parser.IsMultiPart(path));
        }
Ejemplo n.º 8
0
        private bool IsMultiDiscAlbumFolder(string path)
        {
            var parser = new AlbumParser(new NamingOptions(), new NullLogger());

            return parser.ParseMultiPart(path).IsMultiPart;
        }