mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-07 06:16:42 +02:00
Fix to not fail on deleted comments
This commit is contained in:
@@ -311,7 +311,7 @@ public class RedditRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContainerTag getComments(JSONArray comments, String author) {
|
private ContainerTag<DivTag> getComments(JSONArray comments, String author) {
|
||||||
ContainerTag<DivTag> commentsDiv = div().withId("comments");
|
ContainerTag<DivTag> commentsDiv = div().withId("comments");
|
||||||
|
|
||||||
for (int i = 0; i < comments.length(); i++) {
|
for (int i = 0; i < comments.length(); i++) {
|
||||||
@@ -330,24 +330,26 @@ public class RedditRipper extends AlbumRipper {
|
|||||||
return commentsDiv;
|
return commentsDiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContainerTag getNestedComments(JSONObject data, ContainerTag parentDiv, String author) {
|
private ContainerTag<DivTag> getNestedComments(JSONObject data, ContainerTag<DivTag> parentDiv, String author) {
|
||||||
if (data.has("replies") && data.get("replies") instanceof JSONObject) {
|
if (data.has("replies") && data.get("replies") instanceof JSONObject) {
|
||||||
for (int i = 0; i <= data.getJSONObject("replies").getJSONObject("data").getJSONArray("children").length() - 1; i++) {
|
JSONArray commentChildren = data.getJSONObject("replies").getJSONObject("data").getJSONArray("children");
|
||||||
JSONObject nestedComment = data.getJSONObject("replies")
|
for (int i = 0; i < commentChildren.length(); i++) {
|
||||||
.getJSONObject("data")
|
JSONObject nestedComment = commentChildren
|
||||||
.getJSONArray("children")
|
|
||||||
.getJSONObject(i).getJSONObject("data");
|
.getJSONObject(i).getJSONObject("data");
|
||||||
|
|
||||||
ContainerTag<DivTag> childDiv =
|
String nestedCommentAuthor = nestedComment.optString("author");
|
||||||
div(
|
if (!nestedCommentAuthor.isBlank()) {
|
||||||
div(
|
ContainerTag<DivTag> childDiv =
|
||||||
span(nestedComment.getString("author")).withClasses("author", iff(nestedComment.getString("author").equals(author), "op")),
|
div(
|
||||||
a(new Date((long) nestedComment.getInt("created") * 1000).toString()).withHref("#" + nestedComment.getString("name"))
|
div(
|
||||||
).withClass("comment").withId(nestedComment.getString("name"))
|
span(nestedCommentAuthor).withClasses("author", iff(nestedCommentAuthor.equals(author), "op")),
|
||||||
.with(rawHtml(Jsoup.parse(nestedComment.getString("body_html")).text()))
|
a(new Date((long) nestedComment.getInt("created") * 1000).toString()).withHref("#" + nestedComment.getString("name"))
|
||||||
).withClass("child");
|
).withClass("comment").withId(nestedComment.getString("name"))
|
||||||
|
.with(rawHtml(Jsoup.parse(nestedComment.getString("body_html")).text()))
|
||||||
|
).withClass("child");
|
||||||
|
|
||||||
parentDiv.with(getNestedComments(nestedComment, childDiv, author));
|
parentDiv.with(getNestedComments(nestedComment, childDiv, author));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parentDiv;
|
return parentDiv;
|
||||||
|
Reference in New Issue
Block a user