Code cleanup

This commit is contained in:
0xboobface 2019-12-27 13:51:48 +01:00
parent f3a13a6f06
commit b72777f6fb
1 changed files with 4 additions and 5 deletions

View File

@ -213,10 +213,9 @@ public class Cam4Model extends AbstractModel {
.url(url) .url(url)
.addHeader("X-Requested-With", "XMLHttpRequest") .addHeader("X-Requested-With", "XMLHttpRequest")
.build(); .build();
Response response = site.getHttpClient().execute(req); try (Response response = site.getHttpClient().execute(req)) {
boolean success = response.isSuccessful(); return response.isSuccessful();
response.close(); }
return success;
} }
@Override @Override
@ -231,9 +230,9 @@ public class Cam4Model extends AbstractModel {
// we have to use a client without any cam4 cookies here, otherwise // we have to use a client without any cam4 cookies here, otherwise
// this request is redirected to the login page. no idea why // this request is redirected to the login page. no idea why
try (Response response = site.getRecorder().getHttpClient().execute(req)) { try (Response response = site.getRecorder().getHttpClient().execute(req)) {
String broadCasterId = null;
if (response.isSuccessful()) { if (response.isSuccessful()) {
String content = response.body().string(); String content = response.body().string();
String broadCasterId = null;
try { try {
Element tag = HtmlParser.getTag(content, "input[name=\"broadcasterId\"]"); Element tag = HtmlParser.getTag(content, "input[name=\"broadcasterId\"]");
broadCasterId = tag.attr("value"); broadCasterId = tag.attr("value");