Refactored code
according to review
This commit is contained in:
parent
f79ce1f52a
commit
1a67ea100a
1 changed files with 4 additions and 5 deletions
|
@ -73,7 +73,8 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the initial comments token and initializes commentsDisabled.
|
* 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
|
* @return the continuation token or null if none was found
|
||||||
*/
|
*/
|
||||||
|
@ -85,14 +86,12 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||||
// Only use JsonObjects
|
// Only use JsonObjects
|
||||||
.filter(JsonObject.class::isInstance)
|
.filter(JsonObject.class::isInstance)
|
||||||
.map(JsonObject.class::cast)
|
.map(JsonObject.class::cast)
|
||||||
// Only process JsonObjects that have a itemSectionRenderer
|
|
||||||
.filter(jObj -> jObj.has("itemSectionRenderer"))
|
|
||||||
// Check if the comment-section is present
|
// Check if the comment-section is present
|
||||||
.filter(jObj -> {
|
.filter(jObj -> {
|
||||||
try {
|
try {
|
||||||
return "comments-section".equals(
|
return "comments-section".equals(
|
||||||
JsonUtils.getString(jObj, "itemSectionRenderer.targetId"));
|
JsonUtils.getString(jObj, "itemSectionRenderer.targetId"));
|
||||||
} catch (final ParsingException ex) {
|
} catch (final ParsingException ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -105,7 +104,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||||
.getObject("itemSectionRenderer")
|
.getObject("itemSectionRenderer")
|
||||||
.getArray("contents").getObject(0),
|
.getArray("contents").getObject(0),
|
||||||
"continuationItemRenderer.continuationEndpoint.continuationCommand.token");
|
"continuationItemRenderer.continuationEndpoint.continuationCommand.token");
|
||||||
} catch (final ParsingException ex) {
|
} catch (final ParsingException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue