private void TryDownloadingAnime(IWebDriver webdriver, Anime anime, bool useAltNAme) { bool foundEpisode = true; do { try { string url = CurrentEpisodeURL(anime, settings.CrawlURL, useAltNAme); webdriver.Url = url; new WebDriverWait(webdriver, TimeSpan.FromSeconds(10)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.UrlToBe(url)); webdriver.Navigate().Refresh(); webdriver.FindElement(By.Id(Anime.AddLeadingZero(anime.CurrentEpisode) + "-" + settings.Quality)) .FindElement(By.LinkText("Torrent")).Click(); Console.WriteLine("Downloaded Episode " + Anime.AddLeadingZero(anime.CurrentEpisode) + " " + anime.Name); dlProcessor.ProcessDownload(anime, useAltNAme); anime.CurrentEpisode++; } catch (NoSuchElementException) { foundEpisode = false; CouldNotFind(anime); } } while (!webdriver.PageSource.Contains(animeNotFound) && foundEpisode); }
public ViewResult Download(Library library, DocumentDetails documentDetails) { if (library.Lines.Count() == 0) { ModelState.AddModelError("", "Извините, ваша корзина пуста!"); } if (ModelState.IsValid) { downloadProcessor.ProcessDownload(library, documentDetails); library.Clear(); return(View("Completed")); } else { return(View(documentDetails)); } }