From eb6f58baa06de63a1237601f8b0259d92d3f7ba7 Mon Sep 17 00:00:00 2001 From: haitao <758277560@qq.com> Date: Sat, 21 Jan 2023 11:36:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=BE=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/github/catvod/spider/Zhaozy.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) 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 9aabca9a..55d99730 100644 --- a/app/src/main/java/com/github/catvod/spider/Zhaozy.java +++ b/app/src/main/java/com/github/catvod/spider/Zhaozy.java @@ -8,6 +8,8 @@ import com.github.catvod.crawler.Spider; import com.github.catvod.net.OkHttp; import com.github.catvod.utils.Misc; +import org.json.JSONArray; +import org.json.JSONObject; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -25,6 +27,8 @@ public class Zhaozy extends Spider { private final Pattern regexAli = Pattern.compile("(https://www.aliyundrive.com/s/[^\"]+)"); private final Pattern regexVid = Pattern.compile("(\\S+)"); private final String siteUrl = "https://zhaoziyuan.la/"; + private String username = "nikalo8893@bitvoo.com"; + private String password = "P@ssw0rd"; private Map getHeader() { Map headers = new HashMap<>(); @@ -36,8 +40,8 @@ public class Zhaozy extends Spider { private String getCookie() { Map params = new HashMap<>(); - params.put("username", "nikalo8893@bitvoo.com"); - params.put("password", "P@ssw0rd"); + params.put("username", username); + params.put("password", password); Map headers = new HashMap<>(); headers.put("User-Agent", Misc.CHROME); headers.put("Referer", siteUrl + "login.html"); @@ -51,15 +55,30 @@ public class Zhaozy extends Spider { @Override public void init(Context context, String extend) { - Ali.get().init(extend); + String strs[] = extend.split("\\$\\$\\$"); + String url = strs[0]; + if (strs.length > 2) { + username = strs[1]; + password = strs[2]; + } + Ali.get().init(url); } @Override public String detailContent(List ids) throws Exception { Matcher matcher = regexAli.matcher(OkHttp.string(siteUrl + ids.get(0), getHeader())); if (!matcher.find()) return ""; + String videoId = ids.get(0); ids.set(0, matcher.group(1)); - return Ali.get().detailContent(ids); + String json = Ali.get().detailContent(ids); + if ("".equals(json)){ + return ""; + } + JSONObject result = new JSONObject(json); + JSONArray jsonList = result.getJSONArray("list"); + JSONObject jsonObject = jsonList.getJSONObject(0); + jsonObject.put("vod_id",videoId); + return result.toString(); } @Override