@Test public void shouldParseResultsCorrectly() throws Exception { String html = Resources.toString(Resources.getResource(BinsearchTest.class, "/org/nzbhydra/mapping/binsearch.html"), Charsets.UTF_8); List<SearchResultItem> searchResultItems = testee.getSearchResultItems(html, new SearchRequest()); assertThat(searchResultItems.size(), is(1)); SearchResultItem item = searchResultItems.get(0); assertThat(item.getTitle(), is("testtitle. 3D.TOPBOT.TrueFrench.1080p.X264.AC3.5.1-JKF.mkv")); assertThat(item.getLink(), is("https: assertThat(item.getDetails(), is("https: assertThat(item.getSize(), is(12209999872L)); assertThat(item.getIndexerGuid(), is("176073735")); assertThat(item.getPubDate(), is(Instant.ofEpochSecond(1443312000))); assertThat(item.isAgePrecise(), is(false)); assertThat(item.getPoster().get(), is("Ramer@marmer.com (Clown_nez)")); assertThat(item.getGroup().get(), is("alt.binaries.movies.mkv")); }
@SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; } }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }  }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }  @Override NfoResult getNfo(String guid); }
Binsearch extends Indexer<String> { @SuppressWarnings("ConstantConditions") @Override protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse, SearchRequest searchRequest) throws IndexerParsingException { List<SearchResultItem> items = new ArrayList<>(); Document doc = Jsoup.parse(searchRequestResponse); if (doc.text().contains("No results in most popular groups")) { return Collections.emptyList(); } Elements mainTables = doc.select("table#r2"); if (mainTables.size() == 0) { throw new IndexerParsingException("Unable to find main table in binsearch page. This happens sometimes ;-)"); } Element mainTable = mainTables.get(0); Elements rows = mainTable.select("tr"); for (int i = 1; i < rows.size(); i++) { Element row = rows.get(i); SearchResultItem item = parseRow(row); if (item == null) { continue; } items.add(item); } debug("Finished parsing {} of {} rows", items.size(), rows.size()); return items; }  @Override NfoResult getNfo(String guid);  }