public async Task <IEnumerable <ReleaseInfo> > PerformQuery(TorznabQuery query, int attempts) { query = query.Clone(); var originalSearchTerm = query.SearchTerm; if (query.SearchTerm == null) { query.SearchTerm = ""; } query.SearchTerm = query.SearchTerm.Replace("'", ""); var requester = new MejorTorrentRequester(this); var tvShowScraper = new TvShowScraper(); var seasonScraper = new SeasonScraper(); var downloadScraper = new DownloadScraper(); var rssScraper = new RssScraper(); var downloadGenerator = new DownloadGenerator(requester, downloadScraper); var tvShowPerformer = new TvShowPerformer(requester, tvShowScraper, seasonScraper, downloadGenerator); var rssPerformer = new RssPerformer(requester, rssScraper, seasonScraper, downloadGenerator); var movieSearchScraper = new MovieSearchScraper(); var movieInfoScraper = new MovieInfoScraper(); var movieDownloadScraper = new MovieDownloadScraper(); var moviePerformer = new MoviePerformer(requester, movieSearchScraper, movieInfoScraper, movieDownloadScraper); var releases = new List <ReleaseInfo>(); if (string.IsNullOrEmpty(query.SanitizedSearchTerm)) { releases = (await rssPerformer.PerformQuery(query)).ToList(); var movie = releases.First(); movie.Category.Add(TorznabCatType.Movies.ID); releases.ToList().Add(movie); if (releases.Count() == 0) { releases = (await AliveCheck(tvShowPerformer)).ToList(); } return(releases); } if (query.Categories.Contains(TorznabCatType.Movies.ID) || query.Categories.Count() == 0) { releases.AddRange(await moviePerformer.PerformQuery(query)); } if (query.Categories.Contains(TorznabCatType.TV.ID) || query.Categories.Contains(TorznabCatType.TVSD.ID) || query.Categories.Contains(TorznabCatType.TVHD.ID) || query.Categories.Count() == 0) { releases.AddRange(await tvShowPerformer.PerformQuery(query)); } query.SearchTerm = originalSearchTerm; return(releases); }
protected override async Task <IEnumerable <ReleaseInfo> > PerformQuery(TorznabQuery query) { var newQuery = query; if (string.IsNullOrEmpty(query.SearchTerm) && string.IsNullOrEmpty(query.ImdbID)) { newQuery = query.Clone(); newQuery.SearchTerm = "%"; } return(await base.PerformQuery(newQuery)); }
protected override async Task <IEnumerable <ReleaseInfo> > PerformQuery(TorznabQuery query) { var newQuery = query.Clone(); var releases = new List <ReleaseInfo>(); var matchWords = ((BoolConfigurationItem)configData.GetDynamic("MatchWords")).Value; matchWords = newQuery.SearchTerm != "" && matchWords; // we remove parts from the original query newQuery = ParseQuery(newQuery); var qc = new NameValueCollection { { "s", newQuery.SearchTerm } }; var page = 1; IHtmlDocument htmlDocument = null; do { var url = SiteLink + "page/" + page + "/?" + qc.GetQueryString(); string htmlString; try { htmlString = await LoadWebPageAsync(url); } catch { logger.Error($"DivxTotal: Failed to load url {url}"); return(releases); } try { htmlDocument = ParseHtmlIntoDocument(htmlString); var table = htmlDocument.QuerySelector("table.table"); if (table == null) { break; } var rows = table.QuerySelectorAll("tbody > tr"); foreach (var row in rows) { try { var rels = await ParseReleasesAsync(row, newQuery, matchWords); if (rels.Any()) { releases.AddRange(rels); } } catch (Exception ex) { logger.Error($"CardigannIndexer ({Id}): Error while parsing row '{row.ToHtmlPretty()}':\n\n{ex}"); } } } catch (Exception ex) { OnParseError(htmlString, ex); } page++; } while (page <= MaxPageLoads && releases.Count < MaxNrOfResults && !IsLastPageOfQueryResult(htmlDocument)); return(releases); }