forked from j62/ctbrec
Fix json exception in online check for BongaCams
This commit is contained in:
parent
14b2911651
commit
6dbdac6df5
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue