private static int FindShowCode(FoundFolder ai) { List <string> possibleFilenames = new List <string> { "series.xml", "tvshow.nfo" }; foreach (string fileName in possibleFilenames) { IEnumerable <FileInfo> files = ai.Folder.EnumerateFiles(fileName).ToList(); if (files.Any()) { foreach (FileInfo file in files) { int x = FindShowCode(file); if (x != -1) { return(x); } } } } //Can't find it return(-1); }
private void bnIgnoreNewFolder_Click(object _, System.EventArgs e) { if (lvFMNewShows.SelectedItems.Count == 0) { return; } DialogResult res = MessageBox.Show("Add selected folders to the 'Bulk Add Shows' ignore folders list?", "Bulk Add Shows", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res != DialogResult.Yes) { return; } foreach (ListViewItem lvi in lvFMNewShows.SelectedItems) { FoundFolder ai = (FoundFolder)(lvi.Tag); TVSettings.Instance.IgnoreFolders.Add(ai.Folder.FullName.ToLower()); engine.AddItems.Remove(ai); } mDoc.SetDirty(); FillNewShowList(false); FillFolderStringLists(); }
public bool CheckFolderForShows([NotNull] DirectoryInfo di2, bool andGuess, [CanBeNull] out DirectoryInfo[] subDirs, 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)) { subDirs = null; return(true); } } // for each showitem //We don't have it already bool 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, showErrorMsgBox); } } return(hasSeasonFolders); } catch (UnauthorizedAccessException) { Logger.Info("Can't access {0}, so ignoring it", di2.FullName); subDirs = null; return(true); } }
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); }