pull/199/head
FongMi 2 years ago
parent 02e1672d4a
commit 679fe197de
  1. 4
      app/src/main/java/com/fongmi/android/tv/player/ParseJob.java
  2. 15
      app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java

@ -176,8 +176,8 @@ public class ParseJob implements ParseCallback {
startWeb("", "", headers, url);
}
private void startWeb(String key, String form, Map<String, String> headers, String url) {
App.post(() -> webViews.add(CustomWebView.create(App.get()).start(key, form, headers, url, this)));
private void startWeb(String key, String from, Map<String, String> headers, String url) {
App.post(() -> webViews.add(CustomWebView.create(App.get()).start(key, from, headers, url, this, true)));
}
private Map<String, String> getHeader(JsonObject object) {

@ -38,6 +38,7 @@ public class CustomWebView extends WebView {
private AlertDialog dialog;
private Runnable timer;
private String from;
private boolean sub;
private String key;
public static CustomWebView create(@NonNull Context context) {
@ -72,13 +73,14 @@ public class CustomWebView extends WebView {
}
}
public CustomWebView start(String key, String from, Map<String, String> headers, String url, ParseCallback callback) {
public CustomWebView start(String key, String from, Map<String, String> headers, String url, ParseCallback callback, boolean sub) {
App.post(timer, Constant.TIMEOUT_PARSE_WEB);
this.callback = callback;
setUserAgent(headers);
loadUrl(url, headers);
this.from = from;
this.key = key;
this.sub = sub;
return this;
}
@ -88,10 +90,11 @@ public class CustomWebView extends WebView {
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
String url = request.getUrl().toString();
String host = request.getUrl().getHost();
if (TextUtils.isEmpty(host) || ApiConfig.get().getAds().contains(host)) return empty;
if (url.contains("challenges.cloudflare.com/cdn-cgi/")) App.post(() -> showDialog());
Map<String, String> headers = request.getRequestHeaders();
if (isVideoFormat(headers, url)) interrupt(headers, url);
if (TextUtils.isEmpty(host) || ApiConfig.get().getAds().contains(host)) return empty;
if (url.contains("challenges.cloudflare.com/cdn-cgi")) App.post(() -> showDialog());
if (sub && url.contains("player/?url=")) onParseAdd(headers, url);
else if (isVideoFormat(headers, url)) interrupt(headers, url);
return super.shouldInterceptRequest(view, request);
}
@ -152,6 +155,10 @@ public class CustomWebView extends WebView {
onParseSuccess(headers, url);
}
private void onParseAdd(Map<String, String> headers, String url) {
App.post(() -> CustomWebView.create(App.get()).start(key, from, headers, url, callback, false));
}
private void onParseSuccess(Map<String, String> headers, String url) {
if (callback != null) callback.onParseSuccess(headers, url, from);
App.post(() -> stop(false));

Loading…
Cancel
Save