-Fixed youtube stream type to no longer return none.

-Fixed search result errors on empty.
This commit is contained in:
John Zhen Mo 2018-02-27 18:16:29 -08:00
parent 837dbd6b86
commit 4cf4ee394f
2 changed files with 5 additions and 20 deletions

View file

@ -44,23 +44,10 @@ public class SearchResult {
this.errors = Collections.unmodifiableList(new ArrayList<>(errors));
}
public static SearchResult getSearchResult(SearchEngine engine, String query, int page, String languageCode, SearchEngine.Filter filter)
public static SearchResult getSearchResult(@Nonnull final SearchEngine engine, final String query, final int page,
final String languageCode, final SearchEngine.Filter filter)
throws IOException, ExtractionException {
SearchResult result = engine
.search(query, page, languageCode, filter)
.getSearchResult();
if (result.resultList.isEmpty()) {
if (result.suggestion.isEmpty()) {
if (result.errors.isEmpty()) {
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 engine.search(query, page, languageCode, filter).getSearchResult();
}
public String getSuggestion() {

View file

@ -458,11 +458,9 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override
public StreamType getStreamType() throws ParsingException {
assertPageFetched();
if (playerArgs == null) return StreamType.NONE;
try {
if (playerArgs.has("ps") && playerArgs.get("ps").toString().equals("live") ||
playerArgs.get(URL_ENCODED_FMT_STREAM_MAP).toString().isEmpty()) {
if (playerArgs != null && (playerArgs.has("ps") && playerArgs.get("ps").toString().equals("live") ||
playerArgs.get(URL_ENCODED_FMT_STREAM_MAP).toString().isEmpty())) {
return StreamType.LIVE_STREAM;
}
} catch (Exception e) {