mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-23 22:14:06 +02:00
reddit, report exception in loop instead of throwing it.
fixes #60, #83.
This commit is contained in:
@@ -112,14 +112,18 @@ public class RedditRipper extends AlbumRipper {
|
|||||||
}
|
}
|
||||||
children = data.getJSONArray("children");
|
children = data.getJSONArray("children");
|
||||||
for (int j = 0; j < children.length(); j++) {
|
for (int j = 0; j < children.length(); j++) {
|
||||||
parseJsonChild(children.getJSONObject(j));
|
try {
|
||||||
|
parseJsonChild(children.getJSONObject(j));
|
||||||
|
|
||||||
if (children.getJSONObject(j).getString("kind").equals("t3") &&
|
if (children.getJSONObject(j).getString("kind").equals("t3") &&
|
||||||
children.getJSONObject(j).getJSONObject("data").getBoolean("is_self")
|
children.getJSONObject(j).getJSONObject("data").getBoolean("is_self")
|
||||||
) {
|
) {
|
||||||
URL selfPostURL = new URL(children.getJSONObject(j).getJSONObject("data").getString("url"));
|
URL selfPostURL = new URL(children.getJSONObject(j).getJSONObject("data").getString("url"));
|
||||||
System.out.println(selfPostURL.toExternalForm());
|
System.out.println(selfPostURL.toExternalForm());
|
||||||
saveText(getJsonArrayFromURL(getJsonURL(selfPostURL)));
|
saveText(getJsonArrayFromURL(getJsonURL(selfPostURL)));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.debug("at index " + i + ", for this data: " + data.toString() + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.has("after") && !data.isNull("after")) {
|
if (data.has("after") && !data.isNull("after")) {
|
||||||
@@ -316,15 +320,18 @@ public class RedditRipper extends AlbumRipper {
|
|||||||
for (int i = 0; i < comments.length(); i++) {
|
for (int i = 0; i < comments.length(); i++) {
|
||||||
JSONObject data = comments.getJSONObject(i).getJSONObject("data");
|
JSONObject data = comments.getJSONObject(i).getJSONObject("data");
|
||||||
|
|
||||||
ContainerTag<DivTag> commentDiv =
|
try {
|
||||||
|
ContainerTag<DivTag> commentDiv =
|
||||||
div(
|
div(
|
||||||
span(data.getString("author")).withClasses("author", iff(data.getString("author").equals(author), "op")),
|
span(data.getString("author")).withClasses("author", iff(data.getString("author").equals(author), "op")),
|
||||||
a(new Date((long) data.getInt("created") * 1000).toString()).withHref("#" + data.getString("name"))
|
a(new Date((long) data.getInt("created") * 1000).toString()).withHref("#" + data.getString("name"))
|
||||||
).withClass("thing comment").withId(data.getString("name"))
|
).withClass("thing comment").withId(data.getString("name"))
|
||||||
.with(rawHtml(Jsoup.parse(data.getString("body_html")).text()));
|
.with(rawHtml(Jsoup.parse(data.getString("body_html")).text()));
|
||||||
|
getNestedComments(data, commentDiv, author);
|
||||||
getNestedComments(data, commentDiv, author);
|
commentsDiv.with(commentDiv);
|
||||||
commentsDiv.with(commentDiv);
|
} catch (Exception e) {
|
||||||
|
LOGGER.debug("at index " + i + ", for this data: " + data.toString() + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return commentsDiv;
|
return commentsDiv;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user