From 4cf4ee394f91fd95fa6444e5c578a19776d65e7c Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 27 Feb 2018 18:16:29 -0800 Subject: [PATCH] -Fixed youtube stream type to no longer return none. -Fixed search result errors on empty. --- .../extractor/search/SearchResult.java | 19 +++---------------- .../youtube/YoutubeStreamExtractor.java | 6 ++---- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java b/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java index 2b2618e3..3effd29d 100644 --- a/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java +++ b/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java @@ -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() { diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java index a3896a67..91d43b79 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java @@ -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) {