diff --git a/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java b/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java index faf93c2f..8756c705 100644 --- a/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java +++ b/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java @@ -6,7 +6,7 @@ import com.iheartradio.m3u8.data.MasterPlaylist; import com.iheartradio.m3u8.data.Playlist; import com.iheartradio.m3u8.data.PlaylistData; import ctbrec.AbstractModel; -// import ctbrec.Config; +import ctbrec.Config; import ctbrec.StringUtil; import ctbrec.io.HttpException; import ctbrec.io.json.ObjectMapperFactory; @@ -383,21 +383,23 @@ public class ChaturbateModel extends AbstractModel { @Override public boolean exists() throws IOException { - Request req = new Request.Builder() // @formatter:off - .url(getUrl()) - .header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent()) - .header(ACCEPT_LANGUAGE, Locale.ENGLISH.getLanguage()) - .build(); // @formatter:on + Request req = new Request.Builder() + .url(getUrl()) + .header("Accept", "*/*") + .header("Accept-Language", Locale.ENGLISH.getLanguage()) + .header("User-Agent", Config.getInstance().getSettings().httpUserAgent) + .header("Referer", getUrl()) + .header("Origin", getSite().getBaseUrl()) + .build(); try (Response response = getSite().getHttpClient().execute(req)) { - if (!response.isSuccessful() && response.code() == 404) { + if (response.code() == 404) { return false; - } else { - String body = response.body().string(); - boolean banned = body.contains("This room has been banned"); - boolean deleted = body.contains("This account has been deleted"); - boolean redirectedToRoot = Objects.equals("/", response.request().url().encodedPath()); - return !(banned || deleted || redirectedToRoot); } + String body = response.body().string(); + boolean banned = body.contains("This room has been banned"); + boolean deleted = body.contains("This account has been deleted"); + boolean redirectedToRoot = Objects.equals("/", response.request().url().encodedPath()); + return !banned && !deleted && !redirectedToRoot; } } diff --git a/common/src/main/java/ctbrec/sites/stripchat/StripchatModel.java b/common/src/main/java/ctbrec/sites/stripchat/StripchatModel.java index 06fc443e..7720bded 100644 --- a/common/src/main/java/ctbrec/sites/stripchat/StripchatModel.java +++ b/common/src/main/java/ctbrec/sites/stripchat/StripchatModel.java @@ -426,17 +426,21 @@ public class StripchatModel extends AbstractModel { @Override public boolean exists() throws IOException { - JSONObject jsonResponse = getModelInfo(); - if (jsonResponse.optString("error").equals("Not Found")) { - log.info("Model not found: {}", getName()); - return false; - } - if (jsonResponse.has("user")) { - JSONObject user = jsonResponse.getJSONObject("user"); - if (isBanned(user)) { - log.info("Model inactive or deleted: {}", getName()); + try { + JSONObject jsonResponse = getModelInfo(); + if (jsonResponse.has("user")) { + JSONObject user = jsonResponse.getJSONObject("user").getJSONObject("user"); + if (isBanned(user)) { + log.info("Model inactive or deleted: {}", getName()); + return false; + } + } + } catch (HttpException e) { + if (e.getResponseCode() == 404) { + log.info("Model not found: {}", getName()); return false; } + throw e; } return true; }