diff --git a/app/src/main/java/com/github/catvod/bean/Result.java b/app/src/main/java/com/github/catvod/bean/Result.java index 8ba94fe4..5f114f09 100644 --- a/app/src/main/java/com/github/catvod/bean/Result.java +++ b/app/src/main/java/com/github/catvod/bean/Result.java @@ -28,6 +28,8 @@ public class Result { private String format; @SerializedName("danmaku") private String danmaku; + @SerializedName("msg") + private String msg; @SerializedName("url") private Object url; @SerializedName("subs") @@ -85,6 +87,10 @@ public class Result { return Result.get().vod(item).string(); } + public static String error(String msg) { + return Result.get().vod(Collections.emptyList()).msg(msg).string(); + } + public static Result get() { return new Result(); } @@ -159,6 +165,11 @@ public class Result { return this; } + public Result msg(String msg) { + this.msg = msg; + return this; + } + public Result format(String format) { this.format = format; return this; diff --git a/app/src/main/java/com/github/catvod/debug/MainActivity.java b/app/src/main/java/com/github/catvod/debug/MainActivity.java index 0a6b1e34..17ff9de0 100644 --- a/app/src/main/java/com/github/catvod/debug/MainActivity.java +++ b/app/src/main/java/com/github/catvod/debug/MainActivity.java @@ -1,10 +1,19 @@ package com.github.catvod.debug; import android.app.Activity; -import android.os.Bundle; +import android.os.*; +import android.view.ViewGroup; +import android.webkit.CookieManager; +import android.webkit.WebView; +import android.webkit.WebViewClient; import com.github.catvod.R; -import com.github.catvod.spider.Init; +import com.github.catvod.net.OkHttp; +import com.github.catvod.spider.*; +import org.apache.commons.lang3.StringEscapeUtils; + +import static com.github.catvod.utils.Util.addView; +import static com.github.catvod.utils.Util.removeView; public class MainActivity extends Activity { @@ -14,12 +23,64 @@ public class MainActivity extends Activity { setContentView(R.layout.activity_main); //Logger.addLogAdapter(new AndroidLogAdapter()); Init.init(getApplicationContext()); + // It is usually init in the application. new Thread(() -> { try { + bypassCf("https://www.czzy88.com/xssearch?q=斗罗"); + while (cookie[0] == null) SystemClock.sleep(1000); + System.out.println(html); + + + } catch (Exception e) { e.printStackTrace(); } }).start(); } + + + static final String[] cookie = new String[1]; + static String html = ""; + public static void bypassCf(String url) { + String content = OkHttp.string(url); + if (content.contains("Just a moment...")) { + Init.run(() -> { + WebView webView = new WebView(Init.context()); + webView.getSettings().setDatabaseEnabled(true); + webView.getSettings().setDomStorageEnabled(true); + webView.getSettings().setJavaScriptEnabled(true); + ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(0, 0); + addView(webView, layoutParams); + webView.setWebViewClient(new WebViewClient() { + @Override + public void onPageFinished(WebView view, String url1) { + cookie[0] = CookieManager.getInstance().getCookie(url1); + if (cookie[0] != null && cookie[0].contains("cf_clearance")) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + view.evaluateJavascript("(function() { return document.documentElement.outerHTML; })();", + html -> { + if (html != null && !html.isEmpty()) { + String htmlString = html.replaceAll("^\"+|\"+$", ""); + MainActivity.html = StringEscapeUtils.unescapeJava(htmlString); + + } + }); + } + if (view != null) { + new Handler(Looper.getMainLooper()).post(() -> { + removeView(webView); + webView.destroy(); + }); + } + } + } + }); + webView.loadUrl(url); + }); + } else { + html = content; + } + } + } \ No newline at end of file diff --git a/app/src/main/java/com/github/catvod/spider/Kanqiu.java b/app/src/main/java/com/github/catvod/spider/Kanqiu.java index ff3e82cf..e881e499 100644 --- a/app/src/main/java/com/github/catvod/spider/Kanqiu.java +++ b/app/src/main/java/com/github/catvod/spider/Kanqiu.java @@ -84,13 +84,14 @@ public class Kanqiu extends Spider { @Override public String detailContent(List ids) throws Exception { - Document doc = Jsoup.parse(OkHttp.string(ids.get(0) + "-url", getHeader())); - JSONArray jsonArray = new JSONArray(doc.text()); + if (ids.get(0).equals(siteUrl)) return Result.error("比賽尚未開始"); + String content = OkHttp.string(ids.get(0) + "-url", getHeader()); + JSONArray linksArray = new JSONObject(content).getJSONArray("links"); List vodItems = new ArrayList<>(); - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject dataObject = jsonArray.getJSONObject(i); - String text = dataObject.optString("name"); - String href = dataObject.optString("url"); + for (int i = 0; i < linksArray.length(); i++) { + JSONObject linkObject = linksArray.getJSONObject(i); + String text = linkObject.optString("name"); + String href = linkObject.optString("url"); vodItems.add(text + "$" + href); } String vod_play_from = "Qile"; diff --git a/app/src/main/java/com/github/catvod/spider/Zhaozy.java b/app/src/main/java/com/github/catvod/spider/Zhaozy.java index 46c1d350..6a78b553 100644 --- a/app/src/main/java/com/github/catvod/spider/Zhaozy.java +++ b/app/src/main/java/com/github/catvod/spider/Zhaozy.java @@ -24,7 +24,7 @@ public class Zhaozy extends Ali { private final Pattern regexAli = Pattern.compile("(https://www.aliyundrive.com/s/[^\"]+)"); private final Pattern regexVid = Pattern.compile("(\\S+)"); - private final String siteUrl = "https://zhaoziyuan.me/"; + private final String siteUrl = "https://zhaoziyuan.pw/"; private String username; private String password; diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index b0bd9cbe..b31437ea 100644 Binary files a/jar/custom_spider.jar and b/jar/custom_spider.jar differ diff --git a/jar/custom_spider.jar.md5 b/jar/custom_spider.jar.md5 index be75967b..9d92789f 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -d793cc92ea62550b731392d15bacb859 +55c157414346e3ff571baad0a223bf15 diff --git a/json/adult.json b/json/adult.json index 5214979d..136f2be9 100644 --- a/json/adult.json +++ b/json/adult.json @@ -1,5 +1,5 @@ { - "spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;d793cc92ea62550b731392d15bacb859", + "spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;55c157414346e3ff571baad0a223bf15", "wallpaper": "https://gao.chuqiuyu.workers.dev", "sites": [ { diff --git a/json/config.json b/json/config.json index 5ee91b15..d417bd61 100644 --- a/json/config.json +++ b/json/config.json @@ -1,5 +1,5 @@ { - "spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;d793cc92ea62550b731392d15bacb859", + "spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;55c157414346e3ff571baad0a223bf15", "wallpaper": "http://饭太硬.top/深色壁纸/api.php", "sites": [ {