fixed some more bugs

This commit is contained in:
Christian Schabesberger 2016-02-29 21:06:00 +01:00
parent 028354b283
commit f90a1ede70
3 changed files with 11 additions and 1 deletions

View File

@ -151,6 +151,8 @@ public class VideoItemListFragment extends ListFragment {
/* todo: this shoudl not be assigned static */ "Youtube", query, R.string.general_error)); /* todo: this shoudl not be assigned static */ "Youtube", query, R.string.general_error));
e.printStackTrace(); e.printStackTrace();
} finally {
} }
} }
} }

View File

@ -31,7 +31,12 @@ public class SearchResult {
SearchResult result = engine.search(query, page, languageCode, dl).getSearchResult(); SearchResult result = engine.search(query, page, languageCode, dl).getSearchResult();
if(result.resultList.isEmpty()) { if(result.resultList.isEmpty()) {
if(result.suggestion.isEmpty()) {
throw new ExtractionException("Empty result despite no error"); throw new ExtractionException("Empty result despite no error");
} else {
// This is used as a fallback. Do not relay on it !!!
throw new SearchEngine.NothingFoundException(result.suggestion);
}
} }
return result; return result;
} }

View File

@ -96,6 +96,9 @@ public class YoutubeSearchEngine implements SearchEngine {
// both types of spell correction item // both types of spell correction item
if (!((el = item.select("div[class*=\"spell-correction\"]").first()) == null)) { if (!((el = item.select("div[class*=\"spell-correction\"]").first()) == null)) {
collector.setSuggestion(el.select("a").first().text()); collector.setSuggestion(el.select("a").first().text());
if(list.children().size() == 1) {
throw new NothingFoundException("Did you mean: " + el.select("a").first().text());
}
// search message item // search message item
} else if (!((el = item.select("div[class*=\"search-message\"]").first()) == null)) { } else if (!((el = item.select("div[class*=\"search-message\"]").first()) == null)) {
//result.errorMessage = el.text(); //result.errorMessage = el.text();