removing catch exception

This commit is contained in:
Ritvik Saraf 2018-08-20 04:58:33 +05:30
parent 53d3997904
commit 8b8779b176
1 changed files with 7 additions and 6 deletions

View File

@ -9,6 +9,7 @@ import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
@ -54,15 +55,15 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
} }
private String getNextPageUrl(JsonNode ajaxJson) throws IOException, ExtractionException { private String getNextPageUrl(JsonNode ajaxJson) throws IOException, ExtractionException {
String continuation; Optional<JsonNode> element = Optional.ofNullable(ajaxJson.findValue("itemSectionContinuation"))
try { .map(e -> e.get("continuations")).map(e -> e.findValue("continuation"));
continuation = ajaxJson.findValue("itemSectionContinuation").get("continuations").findValue("continuation")
.asText(); if (element.isPresent()) {
} catch (Exception e) { return getNextPageUrl(element.get().asText());
} else {
// no more comments // no more comments
return ""; return "";
} }
return getNextPageUrl(continuation);
} }
private String getNextPageUrl(String continuation) throws ParsingException { private String getNextPageUrl(String continuation) throws ParsingException {