Fix: BongaCams search fails with JSON exceptions

This commit is contained in:
0xboobface 2018-12-17 18:10:55 +01:00
parent 2a1dc77a89
commit 6dd7de9762
1 changed files with 10 additions and 8 deletions

View File

@ -157,15 +157,17 @@ public class BongaCams extends AbstractSite {
JSONArray results = json.getJSONArray("models"); JSONArray results = json.getJSONArray("models");
for (int i = 0; i < results.length(); i++) { for (int i = 0; i < results.length(); i++) {
JSONObject result = results.getJSONObject(i); JSONObject result = results.getJSONObject(i);
Model model = createModel(result.getString("username")); if(result.has("username")) {
String thumb = result.getString("thumb_image"); Model model = createModel(result.getString("username"));
if(thumb != null) { String thumb = result.getString("thumb_image");
model.setPreview("https:" + thumb); if(thumb != null) {
model.setPreview("https:" + thumb);
}
if(result.has("display_name")) {
model.setDisplayName(result.getString("display_name"));
}
models.add(model);
} }
if(result.has("display_name")) {
model.setDisplayName(result.getString("display_name"));
}
models.add(model);
} }
return models; return models;
} else { } else {