修复zxzj

This commit is contained in:
lushunming 2024-07-29 14:01:00 +08:00
parent 9a9bdeadd4
commit 9315ab7bcb
5 changed files with 40 additions and 29 deletions

View File

@ -33,13 +33,13 @@ import java.util.regex.Pattern;
public class Zxzj extends Spider { public class Zxzj extends Spider {
private final String siteUrl = "https://www.zxzja.com"; private final String siteUrl = "http://zxzj.shop";
private Map<String, String> getHeader() { private Map<String, String> getHeader() {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 16_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/100.0.4896.77 Mobile/15E148 Safari/604.1"); header.put("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 16_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/100.0.4896.77 Mobile/15E148 Safari/604.1");
header.put("Connection", "keep-alive"); header.put("Connection", "keep-alive");
header.put("Referer", "https://www.zxzj.com/"); header.put("Referer", "http://zxzj.shop/");
header.put("sec-fetch-dest", "iframe"); header.put("sec-fetch-dest", "iframe");
header.put("sec-fetch-mode", "navigate"); header.put("sec-fetch-mode", "navigate");
header.put("sec-fetch-site", "cross-site"); header.put("sec-fetch-site", "cross-site");
@ -164,7 +164,15 @@ public class Zxzj extends Spider {
} }
Document document = Jsoup.parse(html); Document document = Jsoup.parse(html);
List<Vod> list = new ArrayList<>(); List<Vod> list = new ArrayList<>();
getVods(list, document); for (Element div : document.select(".stui-vodlist__media >li")) {
String id = div.select("a.stui-vodlist__thumb").attr("href");
String name = div.select(".detail >h3.title > a").text();
String pic = div.select("a.stui-vodlist__thumb").attr("data-original");
if (pic.isEmpty()) pic = div.select("img").attr("src");
String remark = div.select("a.stui-vodlist__thumb > span.pic-text").text();
list.add(new Vod(id, name, pic, remark));
}
return Result.string(list); return Result.string(list);
} }
@ -177,6 +185,9 @@ public class Zxzj extends Spider {
String json = matcher.find() ? matcher.group(1) : ""; String json = matcher.find() ? matcher.group(1) : "";
org.json.JSONObject player = new JSONObject(json); org.json.JSONObject player = new JSONObject(json);
String realUrl = player.getString("url"); String realUrl = player.getString("url");
if(realUrl.indexOf("m3u8")>-1){
return Result.get().url(realUrl).header(getVideoHeader()).string();
}
String videoContent = OkHttp.string(realUrl, getHeader()); String videoContent = OkHttp.string(realUrl, getHeader());
Matcher matcher2 = Pattern.compile("result_v2 =(.*?);").matcher(videoContent); Matcher matcher2 = Pattern.compile("result_v2 =(.*?);").matcher(videoContent);
String json2 = matcher2.find() ? matcher2.group(1) : ""; String json2 = matcher2.find() ? matcher2.group(1) : "";

View File

@ -12,11 +12,13 @@ import org.junit.Assert;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@RunWith(MockitoJUnitRunner.class) @RunWith(RobolectricTestRunner.class)
public class ZxzjTest { public class ZxzjTest {
@Mock @Mock
private Application mockContext; private Application mockContext;
@ -25,6 +27,7 @@ public class ZxzjTest {
@org.junit.Before @org.junit.Before
public void setUp() throws Exception { public void setUp() throws Exception {
mockContext = RuntimeEnvironment.application;
Init.init(mockContext); Init.init(mockContext);
spider = new Zxzj(); spider = new Zxzj();
spider.init(mockContext, ""); spider.init(mockContext, "");
@ -43,7 +46,7 @@ public class ZxzjTest {
@org.junit.Test @org.junit.Test
public void categoryContent() throws Exception { public void categoryContent() throws Exception {
String content = spider.categoryContent("/list/1.html", "2", true, null); String content = spider.categoryContent("/type/1.html", "2", true, null);
JsonObject map = Json.safeObject(content); JsonObject map = Json.safeObject(content);
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println("categoryContent--" + gson.toJson(map)); System.out.println("categoryContent--" + gson.toJson(map));
@ -53,28 +56,28 @@ public class ZxzjTest {
@org.junit.Test @org.junit.Test
public void detailContent() throws Exception { public void detailContent() throws Exception {
String content = spider.detailContent(Arrays.asList("/detail/4463.html")); String content = spider.detailContent(Arrays.asList("/detail/354820.html"));
JsonObject map = Json.safeObject(content); JsonObject map = Json.safeObject(content);
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println("detailContent--" + gson.toJson(map)); System.out.println("detailContent--" + gson.toJson(map));
Assert.assertFalse(map.getAsJsonArray("list").isEmpty()); Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
} }
@org.junit.Test
public void playerContent() throws Exception {
String content = spider.playerContent("HD", "/video/354820-2-1.html", new ArrayList<>());
JsonObject map = Json.safeObject(content);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println("playerContent--" + gson.toJson(map));
Assert.assertFalse(map.getAsJsonPrimitive("url").getAsString().isEmpty());
}
@org.junit.Test @org.junit.Test
public void searchContent() throws Exception { public void searchContent() throws Exception {
String content = spider.playerContent("", "/video/4463-1-1.html", new ArrayList<>()); String content = spider.searchContent("", false);
JsonObject map = Json.safeObject(content); JsonObject map = Json.safeObject(content);
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println("searchContent--" + gson.toJson(map)); System.out.println("searchContent--" + gson.toJson(map));
Assert.assertFalse(map.getAsJsonArray("list").isEmpty()); Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
} }
@org.junit.Test
public void playerContent() throws Exception {
String content = spider.searchContent("我的人间烟火", false);
JsonObject map = Json.safeObject(content);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println("playerContent--" + gson.toJson(map));
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
}
} }

Binary file not shown.

View File

@ -1 +1 @@
1823faf92e43593a4caa80d664204b94 ee482f7aaf35e8b539e99292d0bad07f

View File

@ -1,5 +1,5 @@
{ {
"spider": "https://gh.idayer.com/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/mine/jar/custom_spider.jar;md5;1823faf92e43593a4caa80d664204b94", "spider": "https://gh.idayer.com/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/mine/jar/custom_spider.jar;md5;ee482f7aaf35e8b539e99292d0bad07f",
"lives": [ "lives": [
{ {
"name": "直播ipv6", "name": "直播ipv6",
@ -44,7 +44,14 @@
"changeable": 1, "changeable": 1,
"ext": {} "ext": {}
}, },
{
"key": "NCat",
"name": "\uD83D\uDE3C 网飞猫 | 影视",
"type": 3,
"api": "csp_NCat",
"searchable": 1,
"filterable": 1
},
{ {
"key": "Zxzj", "key": "Zxzj",
"name": "在线之家", "name": "在线之家",
@ -55,14 +62,6 @@
"changeable": 0, "changeable": 0,
"ext": {} "ext": {}
}, },
{
"key": "NCat",
"name": "\uD83D\uDE3C 网飞猫 | 影视",
"type": 3,
"api": "csp_NCat",
"searchable": 1,
"filterable": 1
},
{ {
"key": "TvDy", "key": "TvDy",
"name": "\uD83D\uDE07 电影天堂 | 影视", "name": "\uD83D\uDE07 电影天堂 | 影视",
@ -119,7 +118,6 @@
"searchable": 1, "searchable": 1,
"filterable": 1 "filterable": 1
}, },
{ {
"key": "Ying", "key": "Ying",
"name": "\uD83C\uDF38 樱花动漫 | 动漫", "name": "\uD83C\uDF38 樱花动漫 | 动漫",
@ -162,7 +160,6 @@
"timeout": 30, "timeout": 30,
"ext": "{\"box\": \"TVBox\", \"danmu\": false}" "ext": "{\"box\": \"TVBox\", \"danmu\": false}"
} }
], ],
"parses": [ "parses": [
{ {