forked from j62/ctbrec
1
0
Fork 0

Fix json exception in online check for BongaCams

This commit is contained in:
0xboobface 2019-02-20 13:44:56 +01:00
parent 14b2911651
commit 6dbdac6df5
1 changed files with 11 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.nodes.Element;
import org.slf4j.Logger;
@ -47,10 +48,15 @@ public class BongaCamsModel extends AbstractModel {
@Override
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
if(ignoreCache) {
String url = getStreamUrl();
Request req = new Request.Builder().url(url).build();
try(Response resp = site.getHttpClient().execute(req)) {
online = resp.isSuccessful();
try {
String url = getStreamUrl();
Request req = new Request.Builder().url(url).build();
try(Response resp = site.getHttpClient().execute(req)) {
online = resp.isSuccessful();
}
} catch (JSONException e) {
LOG.info("Video Server URL not available for {}. Assuming she's offline", getDisplayName());
online = false;
}
}
return online;
@ -141,6 +147,7 @@ public class BongaCamsModel extends AbstractModel {
private String getStreamUrl() throws IOException {
JSONObject roomData = getRoomData();
LOG.debug(roomData.toString(2));
if(roomData.optString("status").equals("success")) {
JSONObject localData = roomData.getJSONObject("localData");
String server = localData.getString("videoServerUrl");