pull/137/head
FongMi 3 years ago
parent 2a99b17cdd
commit 89534cde4f
  1. 2
      app/src/main/java/com/fongmi/android/tv/event/ErrorEvent.java
  2. 16
      app/src/main/java/com/fongmi/android/tv/player/parse/ParseJob.java

@ -53,7 +53,7 @@ public class ErrorEvent {
}
public boolean isFormat() {
return getType() == Type.FORMAT;
return Type.FORMAT.equals(getType());
}
public String getMsg() {

@ -97,13 +97,13 @@ public class ParseJob implements ParseCallback {
}
}
private void jsonParse(Parse item, String webUrl, boolean error) throws Exception {
private void jsonParse(Parse item, String webUrl, boolean simple) throws Exception {
String body = OkHttp.newCall(item.getUrl() + webUrl, Headers.of(item.getHeaders())).execute().body().string();
JsonObject object = JsonParser.parseString(body).getAsJsonObject();
object = object.has("data") ? object.getAsJsonObject("data") : object;
boolean illegal = body.contains("不存在") || body.contains("已过期");
String url = illegal ? "" : Json.safeString(object, "url");
checkResult(getHeader(object), url, item.getName(), error);
checkResult(getHeader(object), url, item.getName(), simple);
}
private void jsonExtend(String webUrl) throws Exception {
@ -138,12 +138,8 @@ public class ParseJob implements ParseCallback {
}
}
private void checkResult(Map<String, String> headers, String url, String from, boolean error) {
if (isPass(headers, url)) {
onParseSuccess(headers, url, from);
} else if (error) {
onParseError();
}
private void checkResult(Map<String, String> headers, String url, String from, boolean simple) {
if (simple || isPass(headers, url)) onParseSuccess(headers, url, from);
}
private void checkResult(Result result) {
@ -154,8 +150,8 @@ public class ParseJob implements ParseCallback {
private boolean isPass(Map<String, String> headers, String url) {
try {
int code = OkHttp.newCall(url, Headers.of(headers)).execute().code();
return code == 200 && url.length() >= 40;
if (url.length() < 40) return false;
return OkHttp.newCall(url, Headers.of(headers)).execute().code() == 200;
} catch (Exception e) {
return false;
}

Loading…
Cancel
Save