//thread code for searching anime while not holding gui private void searchAnime(Form1 form, string SearchInput, string bot) { SearchInput = SearchInput.Replace(' ', '+').ToLower(); string htmlCode = ""; using (WebClient client = new WebClient()) { if (bot == "" || bot == null) { htmlCode = client.DownloadString("http://nibl.co.uk/bots.php?search=" + SearchInput); } else { htmlCode = client.DownloadString("http://nibl.co.uk/bots.php?search=" + SearchInput + "&bot=" + bot + "&searchthis=Search+this+bot"); } if (htmlCode != null || htmlCode != "") { int posOfBotPart = 3; string searchQuery = "botlistitem"; string lastFile = ""; while (posOfBotPart > 0 && !htmlCode.Contains("No packs found") && !htmlCode.Contains("Search query too vague")) { posOfBotPart = htmlCode.IndexOf(searchQuery); htmlCode = htmlCode.Substring(posOfBotPart + searchQuery.Length); string partOfHtmlCode = htmlCode; int startBotName = partOfHtmlCode.IndexOf("botname\">"); string botName = partOfHtmlCode.Substring(startBotName + 9); int endBotName = botName.IndexOf("<a"); botName = botName.Substring(0, endBotName); form.addBot(botName); int startFileName = partOfHtmlCode.IndexOf("filename\">"); string fileName = partOfHtmlCode.Substring(startFileName + 10); int endFileName = fileName.IndexOf("<a"); fileName = fileName.Substring(0, endFileName).Trim(); if (fileName == lastFile) { break; } int startPackNum = partOfHtmlCode.IndexOf("packnumber\">"); string packNum = partOfHtmlCode.Substring(startPackNum + 12); int endPackNum = packNum.IndexOf("</td>"); packNum = packNum.Substring(0, endPackNum); int startFileSize = partOfHtmlCode.IndexOf("filesize\">"); string fileSize = partOfHtmlCode.Substring(startFileSize + 10); int endFileSize = fileSize.IndexOf("</td>"); fileSize = fileSize.Substring(0, endFileSize); lastFile = fileName; form.setAnimeSearchResult(fileName, fileSize, packNum, botName); } } } }
//thread code for searching anime while not holding gui private void searchAnime(Form1 form, string SearchInput, string bot) { SearchInput = SearchInput.Replace(' ', '+').ToLower(); string htmlCode = ""; using (WebClient client = new WebClient()) { if(bot == "" || bot == null) { htmlCode = client.DownloadString("http://nibl.co.uk/bots.php?search=" + SearchInput); } else { htmlCode = client.DownloadString("http://nibl.co.uk/bots.php?search=" + SearchInput + "&bot=" + bot + "&searchthis=Search+this+bot"); } if (htmlCode != null || htmlCode != "") { int posOfBotPart = 3; string searchQuery = "botlistitem"; string lastFile = ""; while (posOfBotPart > 0 && !htmlCode.Contains("No packs found") && !htmlCode.Contains("Search query too vague")) { posOfBotPart = htmlCode.IndexOf(searchQuery); htmlCode = htmlCode.Substring(posOfBotPart + searchQuery.Length); string partOfHtmlCode = htmlCode; int startBotName = partOfHtmlCode.IndexOf("botname\">"); string botName = partOfHtmlCode.Substring(startBotName + 9); int endBotName = botName.IndexOf("<a"); botName = botName.Substring(0, endBotName); form.addBot(botName); int startFileName= partOfHtmlCode.IndexOf("filename\">"); string fileName = partOfHtmlCode.Substring(startFileName + 10); int endFileName = fileName.IndexOf("<a"); fileName = fileName.Substring(0, endFileName).Trim(); if(fileName == lastFile) { break; } int startPackNum = partOfHtmlCode.IndexOf("packnumber\">"); string packNum = partOfHtmlCode.Substring(startPackNum + 12); int endPackNum = packNum.IndexOf("</td>"); packNum = packNum.Substring(0, endPackNum); int startFileSize = partOfHtmlCode.IndexOf("filesize\">"); string fileSize = partOfHtmlCode.Substring(startFileSize + 10); int endFileSize = fileSize.IndexOf("</td>"); fileSize = fileSize.Substring(0, endFileSize); lastFile = fileName; form.setAnimeSearchResult(fileName, fileSize, packNum, botName); } } } }