Fix CheckURL for SC (WinkRU)
This commit is contained in:
parent
fa609157c5
commit
7409bb8fa9
|
@ -6,7 +6,7 @@ import com.iheartradio.m3u8.data.MasterPlaylist;
|
||||||
import com.iheartradio.m3u8.data.Playlist;
|
import com.iheartradio.m3u8.data.Playlist;
|
||||||
import com.iheartradio.m3u8.data.PlaylistData;
|
import com.iheartradio.m3u8.data.PlaylistData;
|
||||||
import ctbrec.AbstractModel;
|
import ctbrec.AbstractModel;
|
||||||
// import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.StringUtil;
|
import ctbrec.StringUtil;
|
||||||
import ctbrec.io.HttpException;
|
import ctbrec.io.HttpException;
|
||||||
import ctbrec.io.json.ObjectMapperFactory;
|
import ctbrec.io.json.ObjectMapperFactory;
|
||||||
|
@ -383,21 +383,23 @@ public class ChaturbateModel extends AbstractModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exists() throws IOException {
|
public boolean exists() throws IOException {
|
||||||
Request req = new Request.Builder() // @formatter:off
|
Request req = new Request.Builder()
|
||||||
.url(getUrl())
|
.url(getUrl())
|
||||||
.header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent())
|
.header("Accept", "*/*")
|
||||||
.header(ACCEPT_LANGUAGE, Locale.ENGLISH.getLanguage())
|
.header("Accept-Language", Locale.ENGLISH.getLanguage())
|
||||||
.build(); // @formatter:on
|
.header("User-Agent", Config.getInstance().getSettings().httpUserAgent)
|
||||||
|
.header("Referer", getUrl())
|
||||||
|
.header("Origin", getSite().getBaseUrl())
|
||||||
|
.build();
|
||||||
try (Response response = getSite().getHttpClient().execute(req)) {
|
try (Response response = getSite().getHttpClient().execute(req)) {
|
||||||
if (!response.isSuccessful() && response.code() == 404) {
|
if (response.code() == 404) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
String body = response.body().string();
|
String body = response.body().string();
|
||||||
boolean banned = body.contains("This room has been banned");
|
boolean banned = body.contains("This room has been banned");
|
||||||
boolean deleted = body.contains("This account has been deleted");
|
boolean deleted = body.contains("This account has been deleted");
|
||||||
boolean redirectedToRoot = Objects.equals("/", response.request().url().encodedPath());
|
boolean redirectedToRoot = Objects.equals("/", response.request().url().encodedPath());
|
||||||
return !(banned || deleted || redirectedToRoot);
|
return !banned && !deleted && !redirectedToRoot;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -426,18 +426,22 @@ public class StripchatModel extends AbstractModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exists() throws IOException {
|
public boolean exists() throws IOException {
|
||||||
|
try {
|
||||||
JSONObject jsonResponse = getModelInfo();
|
JSONObject jsonResponse = getModelInfo();
|
||||||
if (jsonResponse.optString("error").equals("Not Found")) {
|
|
||||||
log.info("Model not found: {}", getName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (jsonResponse.has("user")) {
|
if (jsonResponse.has("user")) {
|
||||||
JSONObject user = jsonResponse.getJSONObject("user");
|
JSONObject user = jsonResponse.getJSONObject("user").getJSONObject("user");
|
||||||
if (isBanned(user)) {
|
if (isBanned(user)) {
|
||||||
log.info("Model inactive or deleted: {}", getName());
|
log.info("Model inactive or deleted: {}", getName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (HttpException e) {
|
||||||
|
if (e.getResponseCode() == 404) {
|
||||||
|
log.info("Model not found: {}", getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue