forked from j62/ctbrec
1
0
Fork 0

Catch JSON parse exception

This commit is contained in:
0xb00bface 2020-10-04 15:20:23 +02:00
parent 5fa939ae65
commit a2e2dbda6d
1 changed files with 14 additions and 9 deletions

View File

@ -98,16 +98,21 @@ public class BongaCamsModel extends AbstractModel {
return online;
}
private boolean isStreamAvailable() throws IOException {
String url = getStreamUrl();
Request req = new Request.Builder().url(url).build();
try(Response resp = site.getHttpClient().execute(req)) {
if(resp.isSuccessful()) {
String body = resp.body().string();
return body.contains("#EXT-X-STREAM-INF");
} else {
return false;
private boolean isStreamAvailable() {
try {
String url = getStreamUrl();
Request req = new Request.Builder().url(url).build();
try (Response resp = site.getHttpClient().execute(req)) {
if (resp.isSuccessful()) {
String body = resp.body().string();
return body.contains("#EXT-X-STREAM-INF");
} else {
return false;
}
}
} catch(Exception e) {
LOG.warn("Couldn't check if stream is available: {}", e.getLocalizedMessage());
return false;
}
}