diff --git a/app/src/main/java/com/github/catvod/spider/PanSearch.java b/app/src/main/java/com/github/catvod/spider/PanSearch.java index 7d0220c3..5e1530a2 100644 --- a/app/src/main/java/com/github/catvod/spider/PanSearch.java +++ b/app/src/main/java/com/github/catvod/spider/PanSearch.java @@ -10,6 +10,7 @@ import org.json.JSONObject; import org.jsoup.Jsoup; import java.net.URLEncoder; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -18,7 +19,7 @@ import java.util.Map; /** * @author zhixc */ -public class PanSearch extends Ali { +public class PanSearch extends Cloud { private final String URL = "https://www.pansearch.me/"; @@ -40,21 +41,26 @@ public class PanSearch extends Ali { String html = OkHttp.string(URL, getHeader()); String data = Jsoup.parse(html).select("script[id=__NEXT_DATA__]").get(0).data(); String buildId = new JSONObject(data).getString("buildId"); - String url = URL + "_next/data/" + buildId + "/search.json?keyword=" + URLEncoder.encode(key) + "&pan=aliyundrive"; - String result = OkHttp.string(url, getSearchHeader()); - JSONArray array = new JSONObject(result).getJSONObject("pageProps").getJSONObject("data").getJSONArray("data"); + List types = List.of("quark", "aliyundrive"); List list = new ArrayList<>(); - for (int i = 0; i < array.length(); i++) { - JSONObject item = array.getJSONObject(i); - String content = item.optString("content"); - String[] split = content.split("\\n"); - if (split.length == 0) continue; - String vodId = Jsoup.parse(content).select("a").attr("href"); - String name = split[0].replaceAll("]+>", ""); - String remark = item.optString("time"); - String pic = item.optString("image"); - list.add(new Vod(vodId, name, pic, remark)); + + for (String type : types) { + String url = URL + "_next/data/" + buildId + "/search.json?keyword=" + URLEncoder.encode(key, Charset.defaultCharset().name()) + "&pan=" + type; + String result = OkHttp.string(url, getSearchHeader()); + JSONArray array = new JSONObject(result).getJSONObject("pageProps").getJSONObject("data").getJSONArray("data"); + for (int i = 0; i < array.length(); i++) { + JSONObject item = array.getJSONObject(i); + String content = item.optString("content"); + String[] split = content.split("\\n"); + if (split.length == 0) continue; + String vodId = Jsoup.parse(content).select("a").attr("href"); + String name = split[0].replaceAll("]+>", ""); + String remark = item.optString("time"); + String pic = item.optString("image"); + list.add(new Vod(vodId, name, pic, remark)); + } } + return Result.string(list); } } diff --git a/app/src/main/java/com/github/catvod/spider/QiLeSo.java b/app/src/main/java/com/github/catvod/spider/QiLeSo.java new file mode 100644 index 00000000..1bb9c06a --- /dev/null +++ b/app/src/main/java/com/github/catvod/spider/QiLeSo.java @@ -0,0 +1,61 @@ +package com.github.catvod.spider; + +import com.github.catvod.bean.Result; +import com.github.catvod.bean.Vod; +import com.github.catvod.net.OkHttp; +import com.github.catvod.utils.Util; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author zhixc + */ +public class QiLeSo extends Cloud { + + private final String URL = "https://www.qileso.com/"; + + private Map getHeader() { + Map header = new HashMap<>(); + header.put("User-Agent", Util.CHROME); + return header; + } + + @Override + public String detailContent(List shareUrl) throws Exception { + String html = OkHttp.string(shareUrl.get(0), getHeader()); + Document doc = Jsoup.parse(html); + Element elements = doc.selectFirst("#body > div > div.thread-body > div.thread-content.message.break-all > p > a"); + return super.detailContent(List.of(elements.attr("href"))); + } + + @Override + public String searchContent(String key, boolean quick) throws Exception { + String url = URL + "?s=" + URLEncoder.encode(key, Charset.defaultCharset().name()); + + String html = OkHttp.string(url, getHeader()); + Document doc = Jsoup.parse(html); + List list = new ArrayList<>(); + + Elements elements = doc.select(" ul.list-group > li.list-group-item > div.subject > h2 > a"); + for (Element element : elements) { + String id = element.attr("href"); + String name = element.text(); + list.add(new Vod(id, name, "")); + } + + + return Result.string(list); + } +} diff --git a/app/src/test/java/PanSearchTest.java b/app/src/test/java/PanSearchTest.java new file mode 100644 index 00000000..ee8474a8 --- /dev/null +++ b/app/src/test/java/PanSearchTest.java @@ -0,0 +1,51 @@ +import android.app.Application; + +import com.github.catvod.server.Server; +import com.github.catvod.spider.Init; +import com.github.catvod.spider.PanSearch; +import com.github.catvod.spider.Wogg; +import com.github.catvod.utils.Json; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; + +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + +import java.util.ArrayList; +import java.util.Arrays; + +@RunWith(RobolectricTestRunner.class) +public class PanSearchTest { + + private Application mockContext; + + private PanSearch spider; + + @org.junit.Before + public void setUp() throws Exception { + mockContext = RuntimeEnvironment.application; + Init.init(mockContext); + spider = new PanSearch(); + Server.get().start(); + // spider.init(mockContext, "{\"cookie\":\"b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; _UP_A4A_11_=wb9661c6dfb642f88f73d8e0c7edd398; b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; ctoken=wla6p3EUOLyn1FSB8IKp1SEW; grey-id=5583e32b-39df-4bf0-f39f-1adf83f604a2; grey-id.sig=p8ReBIMG2BeZu1sYvsuOAZxYbx-MVrsfKEiCv87MsTM; isQuark=true; isQuark.sig=hUgqObykqFom5Y09bll94T1sS9abT1X-4Df_lzgl8nM; _UP_F7E_8D_=ZkyvVHnrBLp1A1NFJIjWi0PwKLOVbxJPcg0RzQPI6KmBtV6ZMgPh38l93pgubgHDQqhaZ2Sfc0qv%2BRantbfg1mWGAUpRMP4RqXP78Wvu%2FCfvkWWGc5NhCTV71tGOIGgDBR3%2Bu6%2Fjj44KlE5biSNDOWW7Bigcz27lvOTidzNw8s%2FWtKAIxWbnCzZn4%2FJMBUub1SIMcW89g57k4mfPmDlCgpZKzxwl6beSfdtZ4RUWXmZOn5v5NkxVKhU4wR0Pq7NklczEGdRq2nIAcu7v22Uw2o%2FxMY0xBdeC9Korm5%2FNHnxl6K%2Bd6FXSoT9a3XIMQO359auZPiZWzrNlZe%2BqnOahXcx7KAhQIRqSOapSmL4ygJor4r5isJhRuDoXy7vJAVuH%2FRDtEJJ8rZTq0BdC23Bz%2B0MrsdgbK%2BiW; _UP_D_=pc; __wpkreporterwid_=3d3f74a7-99b7-4916-3f78-911fc2eb9d87; tfstk=fIoZNxjnbhKwPOu0TWZ4LsaRqirTcudSSmNbnxD0C5VgClMm8xMyB-GsnSu4tjpOflAOmSD-9PNiGl120XrgkVNb1SrqHbJBN3tSBAEYoQOWVUUg9qZ8n1bGGkD3CqGYINKSBABhjnXgp3_Vywz6gSc0Syj3BWf0mr2DLW24eZfiiovEKWefj1q0swq3E82iNEMinMy7SLrcpA4Fh3z_ZAViCfih3PbtdW5N_DuU77AaTijmYRkL2Wq54ENoy5a7ZXxCbok33XzS7QSZgxD-oyoVsdGotql0p2dVu7umC4nLStbiLmParc4FELHrI-c0u2dPVRrs8zoZWKCnIbNZrlHfUCMUz2z8KyXVSlgSFmUojh58OzeqTzgwaGll4YCYKwctDV5coP2LL79eKHxpNTXHmre1kZU32JPWCR_AkP2LL79eLZQY-WeUNdw1.; __pus=2051c82285199d8be553be41dd5a2100AAQ+mmv35G4FDDZ5x+3Mhe2OMbNgweQ1ODbW8zDt9YuP1LQVqHUuAAz9KWLsPjpNtim0AVGHusN4MCosTmbq/khM; __kp=e6604120-6051-11ef-bfe4-c31b6cdd0766; __kps=AATcZArVgS76EPn0FMaV4HEj; __ktd=sii/iz4ePzEaoVirXul7QQ==; __uid=AATcZArVgS76EPn0FMaV4HEj; __itrace_wid=5829b95d-dac1-48d3-bfd5-f60cd9462786; __puus=7da0b96cb710fa1b376934485f977e05AATp/q8/QupT7IiBR1GWqZhxlIRT677smMvoHlLxQA0Lk6CkP0YJBOTl+p9DZgzlMz6w4hPXPgWsokukk8PW7ZfhFfPmv8tKMgLpCGLW+tk57luhNghmSdTeVPkAF59STtyCPBEtiNzNAd/zZJ6qILJDi5ywEBAAAg+gOyWHoLHNUR+QxeHRuQa8g5WWA95J8jebIlrr8rCvI1vjTbtiYktT\",\"token\":\"26fc6787afff43e78b78992e782502f1\"}"); + spider.init(mockContext, "{\"cookie\":\"ctoken=rldVUeNBAbGyhJdbpC4wEUE-;__pus=75e54cf66f9ea5ed1497838782a90a78AATTBUV9c9w7KXUiHDEl6VdV8Wxki4L9R5kIIjSKQnX1wedJe3s8weva95YKUkRqI1aBY/MA+YBNvaTO0JkXvLp+;__kp=be6b9e10-74f8-11ef-aa08-7d8956cd7603;__kps=AATcZArVgS76EPn0FMaV4HEj;__ktd=sii/iz4ePzEaoVirXul7QQ==;__uid=AATcZArVgS76EPn0FMaV4HEj\"}"); + // spider.init(mockContext, ""); + } + + + + + @org.junit.Test + public void searchContent() throws Exception { + String content = spider.searchContent("红海", false); + JsonObject map = Json.safeObject(content); + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + System.out.println("searchContent--" + gson.toJson(map)); + Assert.assertFalse(map.getAsJsonArray("list").isEmpty()); + } + + +} \ No newline at end of file diff --git a/app/src/test/java/QiLeSoTest.java b/app/src/test/java/QiLeSoTest.java new file mode 100644 index 00000000..5b298084 --- /dev/null +++ b/app/src/test/java/QiLeSoTest.java @@ -0,0 +1,58 @@ +import android.app.Application; + +import com.github.catvod.server.Server; +import com.github.catvod.spider.Init; +import com.github.catvod.spider.PanSearch; +import com.github.catvod.spider.QiLeSo; +import com.github.catvod.utils.Json; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; + +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + +import java.util.List; + +@RunWith(RobolectricTestRunner.class) +public class QiLeSoTest { + + private Application mockContext; + + private QiLeSo spider; + + @org.junit.Before + public void setUp() throws Exception { + mockContext = RuntimeEnvironment.application; + Init.init(mockContext); + spider = new QiLeSo(); + Server.get().start(); + // spider.init(mockContext, "{\"cookie\":\"b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; _UP_A4A_11_=wb9661c6dfb642f88f73d8e0c7edd398; b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; ctoken=wla6p3EUOLyn1FSB8IKp1SEW; grey-id=5583e32b-39df-4bf0-f39f-1adf83f604a2; grey-id.sig=p8ReBIMG2BeZu1sYvsuOAZxYbx-MVrsfKEiCv87MsTM; isQuark=true; isQuark.sig=hUgqObykqFom5Y09bll94T1sS9abT1X-4Df_lzgl8nM; _UP_F7E_8D_=ZkyvVHnrBLp1A1NFJIjWi0PwKLOVbxJPcg0RzQPI6KmBtV6ZMgPh38l93pgubgHDQqhaZ2Sfc0qv%2BRantbfg1mWGAUpRMP4RqXP78Wvu%2FCfvkWWGc5NhCTV71tGOIGgDBR3%2Bu6%2Fjj44KlE5biSNDOWW7Bigcz27lvOTidzNw8s%2FWtKAIxWbnCzZn4%2FJMBUub1SIMcW89g57k4mfPmDlCgpZKzxwl6beSfdtZ4RUWXmZOn5v5NkxVKhU4wR0Pq7NklczEGdRq2nIAcu7v22Uw2o%2FxMY0xBdeC9Korm5%2FNHnxl6K%2Bd6FXSoT9a3XIMQO359auZPiZWzrNlZe%2BqnOahXcx7KAhQIRqSOapSmL4ygJor4r5isJhRuDoXy7vJAVuH%2FRDtEJJ8rZTq0BdC23Bz%2B0MrsdgbK%2BiW; _UP_D_=pc; __wpkreporterwid_=3d3f74a7-99b7-4916-3f78-911fc2eb9d87; tfstk=fIoZNxjnbhKwPOu0TWZ4LsaRqirTcudSSmNbnxD0C5VgClMm8xMyB-GsnSu4tjpOflAOmSD-9PNiGl120XrgkVNb1SrqHbJBN3tSBAEYoQOWVUUg9qZ8n1bGGkD3CqGYINKSBABhjnXgp3_Vywz6gSc0Syj3BWf0mr2DLW24eZfiiovEKWefj1q0swq3E82iNEMinMy7SLrcpA4Fh3z_ZAViCfih3PbtdW5N_DuU77AaTijmYRkL2Wq54ENoy5a7ZXxCbok33XzS7QSZgxD-oyoVsdGotql0p2dVu7umC4nLStbiLmParc4FELHrI-c0u2dPVRrs8zoZWKCnIbNZrlHfUCMUz2z8KyXVSlgSFmUojh58OzeqTzgwaGll4YCYKwctDV5coP2LL79eKHxpNTXHmre1kZU32JPWCR_AkP2LL79eLZQY-WeUNdw1.; __pus=2051c82285199d8be553be41dd5a2100AAQ+mmv35G4FDDZ5x+3Mhe2OMbNgweQ1ODbW8zDt9YuP1LQVqHUuAAz9KWLsPjpNtim0AVGHusN4MCosTmbq/khM; __kp=e6604120-6051-11ef-bfe4-c31b6cdd0766; __kps=AATcZArVgS76EPn0FMaV4HEj; __ktd=sii/iz4ePzEaoVirXul7QQ==; __uid=AATcZArVgS76EPn0FMaV4HEj; __itrace_wid=5829b95d-dac1-48d3-bfd5-f60cd9462786; __puus=7da0b96cb710fa1b376934485f977e05AATp/q8/QupT7IiBR1GWqZhxlIRT677smMvoHlLxQA0Lk6CkP0YJBOTl+p9DZgzlMz6w4hPXPgWsokukk8PW7ZfhFfPmv8tKMgLpCGLW+tk57luhNghmSdTeVPkAF59STtyCPBEtiNzNAd/zZJ6qILJDi5ywEBAAAg+gOyWHoLHNUR+QxeHRuQa8g5WWA95J8jebIlrr8rCvI1vjTbtiYktT\",\"token\":\"26fc6787afff43e78b78992e782502f1\"}"); + spider.init(mockContext, "{\"cookie\":\"ctoken=rldVUeNBAbGyhJdbpC4wEUE-;__pus=75e54cf66f9ea5ed1497838782a90a78AATTBUV9c9w7KXUiHDEl6VdV8Wxki4L9R5kIIjSKQnX1wedJe3s8weva95YKUkRqI1aBY/MA+YBNvaTO0JkXvLp+;__kp=be6b9e10-74f8-11ef-aa08-7d8956cd7603;__kps=AATcZArVgS76EPn0FMaV4HEj;__ktd=sii/iz4ePzEaoVirXul7QQ==;__uid=AATcZArVgS76EPn0FMaV4HEj\"}"); + // spider.init(mockContext, ""); + } + + + @org.junit.Test + public void searchContent() throws Exception { + String content = spider.searchContent("红海", false); + JsonObject map = Json.safeObject(content); + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + System.out.println("searchContent--" + gson.toJson(map)); + Assert.assertFalse(map.getAsJsonArray("list").isEmpty()); + } + + @org.junit.Test + public void detailContent() throws Exception { + String content = spider.detailContent(List.of("https://www.qileso.com/52567.html")); + JsonObject map = Json.safeObject(content); + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + System.out.println("detailContent--" + gson.toJson(map)); + Assert.assertFalse(map.getAsJsonArray("list").isEmpty()); + } + + + +} \ No newline at end of file diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index 6cb2eb10..7077613c 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 109a7dfc..2ac112dd 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -046039ed47e1967e85fbc358683fb76a +94ac5701c2ae84b5f8361994d6e17b3b diff --git a/json/index.json b/json/index.json index 59f779bb..50ad8b9c 100644 --- a/json/index.json +++ b/json/index.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;046039ed47e1967e85fbc358683fb76a", + "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;94ac5701c2ae84b5f8361994d6e17b3b", "lives": [ { "name": "直播ipv6", @@ -210,6 +210,24 @@ "changeable": 0, "ext": {} }, + { + "key": "QiLeSo", + "name": "奇乐搜┃搜索", + "type": 3, + "api": "csp_QiLeSo", + "searchable": 1, + "changeable": 1, + "timeout": 30 + }, + { + "key": "PanSearch", + "name": "盘搜┃搜索", + "type": 3, + "api": "csp_PanSearch", + "searchable": 1, + "changeable": 1, + "timeout": 30 + }, { "key": "newvision", "name": "(js)新视觉影院(不稳定)", diff --git a/json/index1.json b/json/index1.json index d09b9946..879061d9 100644 --- a/json/index1.json +++ b/json/index1.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;046039ed47e1967e85fbc358683fb76a", + "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;94ac5701c2ae84b5f8361994d6e17b3b", "lives": [ { "name": "直播ipv6", diff --git a/json/index2.json b/json/index2.json index fbf4acec..0f35554c 100644 --- a/json/index2.json +++ b/json/index2.json @@ -1,5 +1,5 @@ { - "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;046039ed47e1967e85fbc358683fb76a", + "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;94ac5701c2ae84b5f8361994d6e17b3b", "lives": [ { "name": "直播ipv6", @@ -207,6 +207,23 @@ "searchable": 1, "changeable": 0, "ext": {} + },{ + "key": "QiLeSo", + "name": "奇乐搜┃搜索", + "type": 3, + "api": "csp_QiLeSo", + "searchable": 1, + "changeable": 1, + "timeout": 30 + }, + { + "key": "PanSearch", + "name": "盘搜┃搜索", + "type": 3, + "api": "csp_PanSearch", + "searchable": 1, + "changeable": 1, + "timeout": 30 }, { "key": "newvision",