Refactored code

according to review
This commit is contained in:
litetex 2022-02-21 19:55:33 +01:00
parent f79ce1f52a
commit 1a67ea100a
1 changed files with 4 additions and 5 deletions

View File

@ -73,7 +73,8 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
/**
* Finds the initial comments token and initializes commentsDisabled.
* Also set
* <br/>
* Also sets {@link #optCommentsDisabled}.
*
* @return the continuation token or null if none was found
*/
@ -85,14 +86,12 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
// Only use JsonObjects
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
// Only process JsonObjects that have a itemSectionRenderer
.filter(jObj -> jObj.has("itemSectionRenderer"))
// Check if the comment-section is present
.filter(jObj -> {
try {
return "comments-section".equals(
JsonUtils.getString(jObj, "itemSectionRenderer.targetId"));
} catch (final ParsingException ex) {
} catch (final ParsingException ignored) {
return false;
}
})
@ -105,7 +104,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
.getObject("itemSectionRenderer")
.getArray("contents").getObject(0),
"continuationItemRenderer.continuationEndpoint.continuationCommand.token");
} catch (final ParsingException ex) {
} catch (final ParsingException ignored) {
return null;
}
})