use of org.nzbhydra.indexers.exceptions.IndexerParsingException in project nzbhydra2 by theotherp.
the class Binsearch method getSearchResultItems.
@SuppressWarnings("ConstantConditions")
@Override
protected List<SearchResultItem> getSearchResultItems(String searchRequestResponse) 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++) {
// First row is header
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;
}
Aggregations