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.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -47,10 +48,15 @@ public class BongaCamsModel extends AbstractModel {
|
||||||
@Override
|
@Override
|
||||||
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
||||||
if(ignoreCache) {
|
if(ignoreCache) {
|
||||||
String url = getStreamUrl();
|
try {
|
||||||
Request req = new Request.Builder().url(url).build();
|
String url = getStreamUrl();
|
||||||
try(Response resp = site.getHttpClient().execute(req)) {
|
Request req = new Request.Builder().url(url).build();
|
||||||
online = resp.isSuccessful();
|
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;
|
return online;
|
||||||
|
@ -141,6 +147,7 @@ public class BongaCamsModel extends AbstractModel {
|
||||||
|
|
||||||
private String getStreamUrl() throws IOException {
|
private String getStreamUrl() throws IOException {
|
||||||
JSONObject roomData = getRoomData();
|
JSONObject roomData = getRoomData();
|
||||||
|
LOG.debug(roomData.toString(2));
|
||||||
if(roomData.optString("status").equals("success")) {
|
if(roomData.optString("status").equals("success")) {
|
||||||
JSONObject localData = roomData.getJSONObject("localData");
|
JSONObject localData = roomData.getJSONObject("localData");
|
||||||
String server = localData.getString("videoServerUrl");
|
String server = localData.getString("videoServerUrl");
|
||||||
|
|
Loading…
Reference in New Issue