Пример #1
0
        public (bool finished, DirectoryInfo[] subDirs) CheckFolderForShows([NotNull] DirectoryInfo di2, bool andGuess, bool fullLogging, bool showErrorMsgBox)
        {
            try
            {
                // ..and not already a folder for one of our shows
                string theFolder = di2.FullName.ToLower();
                foreach (ShowItem si in mDoc.Library.GetShowItems())
                {
                    if (RejectFolderIfIncludedInShow(fullLogging, si, theFolder))
                    {
                        return(true, null);
                    }
                } // for each showitem

                //We don't have it already
                bool hasSeasonFolders = HasSeasonFolders(di2, out DirectoryInfo[] subDirectories, out string folderFormat);

                //This is an indication that something is wrong
                if (subDirectories is null)
                {
                    return(false, null);
                }

                bool hasSubFolders = subDirectories.Length > 0;
                if (hasSubFolders && !hasSeasonFolders)
                {
                    return(false, subDirectories);
                }

                if (TVSettings.Instance.BulkAddCompareNoVideoFolders && !HasFilmFiles(di2))
                {
                    return(false, subDirectories);
                }

                if (TVSettings.Instance.BulkAddIgnoreRecycleBin && IsRecycleBin(di2))
                {
                    return(false, subDirectories);
                }

                // ....its good!
                FoundFolder ai = new FoundFolder(di2, hasSeasonFolders, folderFormat);

                AddItems.Add(ai);
                Logger.Info("Adding {0} as a new folder", theFolder);
                if (andGuess)
                {
                    GuessShowItem(ai, mDoc.Library, showErrorMsgBox);
                }
                return(hasSeasonFolders, subDirectories);
            }
            catch (UnauthorizedAccessException)
            {
                Logger.Info("Can't access {0}, so ignoring it", di2.FullName);
                return(true, null);
            }
        }
Пример #2
0
        public bool CheckFolderForShows(DirectoryInfo di2, bool andGuess, out DirectoryInfo[] subDirs)
        {
            // ..and not already a folder for one of our shows
            string theFolder = di2.FullName.ToLower();

            foreach (ShowItem si in mDoc.Library.GetShowItems())
            {
                if (si.AutoAddNewSeasons() && !string.IsNullOrEmpty(si.AutoAddFolderBase) &&
                    theFolder.IsSubfolderOf(si.AutoAddFolderBase))
                {
                    // we're looking at a folder that is a subfolder of an existing show
                    Logger.Info("Rejecting {0} as it's already part of {1}.", theFolder, si.ShowName);
                    subDirs = null;
                    return(true);
                }

                if (si.UsesManualFolders())
                {
                    Dictionary <int, List <string> > afl = si.AllFolderLocations();
                    foreach (KeyValuePair <int, List <string> > kvp in afl)
                    {
                        foreach (string folder in kvp.Value)
                        {
                            if (!string.Equals(theFolder, folder, StringComparison.CurrentCultureIgnoreCase))
                            {
                                continue;
                            }

                            Logger.Info("Rejecting {0} as it's already part of {1}:{2}.", theFolder, si.ShowName,
                                        folder);

                            subDirs = null;
                            return(true);
                        }
                    }
                }
            } // for each showitem

            //We don't have it already
            bool hasSeasonFolders;

            try
            {
                hasSeasonFolders = HasSeasonFolders(di2, out DirectoryInfo[] subDirectories, out string folderFormat);

                subDirs = subDirectories;

                //This is an indication that something is wrong
                if (subDirectories is null)
                {
                    return(false);
                }

                bool hasSubFolders = subDirectories.Length > 0;
                if (!hasSubFolders || hasSeasonFolders)
                {
                    if (TVSettings.Instance.BulkAddCompareNoVideoFolders && !HasFilmFiles(di2))
                    {
                        return(false);
                    }

                    if (TVSettings.Instance.BulkAddIgnoreRecycleBin &&
                        di2.FullName.Contains("$RECYCLE.BIN", StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }

                    if (TVSettings.Instance.BulkAddIgnoreRecycleBin &&
                        di2.FullName.Contains("\\@Recycle\\", StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }

                    // ....its good!
                    FoundFolder ai =
                        new FoundFolder(di2, hasSeasonFolders, folderFormat);

                    AddItems.Add(ai);
                    Logger.Info("Adding {0} as a new folder", theFolder);
                    if (andGuess)
                    {
                        GuessShowItem(ai, mDoc.Library);
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                Logger.Info("Can't access {0}, so ignoring it", di2.FullName);
                subDirs = null;
                return(true);
            }

            return(hasSeasonFolders);
        }