hktv 修复
This commit is contained in:
parent
918628cb41
commit
48dc96139b
|
|
@ -26,11 +26,11 @@ import java.util.regex.Pattern;
|
|||
|
||||
public class HkTv extends Spider {
|
||||
|
||||
private static final String siteUrl = "http://www.tvyb04.com";
|
||||
private static final String siteUrl = "http://www.tvyb03.com";
|
||||
private static final String cateUrl = siteUrl + "/vod/type/id/";
|
||||
private static final String detailUrl = siteUrl + "/vod/detail/id/";
|
||||
private static final String playUrl = siteUrl + "/vod/play/id/";
|
||||
private static final String searchUrl = siteUrl + "/search--------------.html?wd=";
|
||||
private static final String searchUrl = siteUrl + "/vod/search.html?wd=";
|
||||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
|
|
@ -69,7 +69,7 @@ public class HkTv extends Spider {
|
|||
List<Vod> list = new ArrayList<>();
|
||||
String target = cateUrl + tid + ".html";
|
||||
if (!"1".equals(pg)) {
|
||||
target = pg + "/page/" + tid + ".html";
|
||||
target =cateUrl + pg + "/page/" + tid + ".html";
|
||||
}
|
||||
Document doc = Jsoup.parse(OkHttp.string(target, getHeaders()));
|
||||
for (Element element : doc.select("ul.myui-vodlist li a.myui-vodlist__thumb")) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,96 @@
|
|||
import android.app.Application;
|
||||
|
||||
import com.github.catvod.spider.DaGongRen;
|
||||
import com.github.catvod.spider.HkTv;
|
||||
import com.github.catvod.spider.Init;
|
||||
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 HKTvTest {
|
||||
// @Mock
|
||||
private Application mockContext;
|
||||
|
||||
private HkTv spider;
|
||||
|
||||
@org.junit.Before
|
||||
public void setUp() throws Exception {
|
||||
mockContext = RuntimeEnvironment.application;
|
||||
Init.init(mockContext);
|
||||
spider = new HkTv();
|
||||
spider.init(mockContext, "");
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void homeContent() throws Exception {
|
||||
String content = spider.homeContent(true);
|
||||
JsonObject map = Json.safeObject(content);
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
System.out.println("homeContent--" + gson.toJson(map));
|
||||
|
||||
//Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void homeVideoContent() throws Exception {
|
||||
String content = spider.homeVideoContent();
|
||||
JsonObject map = Json.safeObject(content);
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
System.out.println("homeVideoContent--" + gson.toJson(map));
|
||||
|
||||
//Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void categoryContent() throws Exception {
|
||||
String content = spider.categoryContent("1", "2", true, null);
|
||||
JsonObject map = Json.safeObject(content);
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
System.out.println("categoryContent--" + gson.toJson(map));
|
||||
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void detailContent() throws Exception {
|
||||
|
||||
String content = spider.detailContent(Arrays.asList("174240.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());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void playerContent() throws Exception {
|
||||
String froms = "量子线路$$$暴风线路$$$非凡线路";
|
||||
String urls = "第01集$174240/sid/1/nid/1.html#第02集$174240/sid/1/nid/2.html#第03集$174240/sid/1/nid/3.html#第04集$174240/sid/1/nid/4.html#第05集$174240/sid/1/nid/5.html#第06集$174240/sid/1/nid/6.html#第07集$174240/sid/1/nid/7.html#第08集$174240/sid/1/nid/8.html#第09集$174240/sid/1/nid/9.html#第10集$174240/sid/1/nid/10.html$$$第01集$174240/sid/3/nid/1.html#第02集$174240/sid/3/nid/2.html#第03集$174240/sid/3/nid/3.html#第04集$174240/sid/3/nid/4.html#第05集$174240/sid/3/nid/5.html#第06集$174240/sid/3/nid/6.html#第07集$174240/sid/3/nid/7.html#第08集$174240/sid/3/nid/8.html#第09集$174240/sid/3/nid/9.html#第10集$174240/sid/3/nid/10.html$$$第01集$174240/sid/2/nid/1.html#第02集$174240/sid/2/nid/2.html#第03集$174240/sid/2/nid/3.html#第04集$174240/sid/2/nid/4.html#第05集$174240/sid/2/nid/5.html#第06集$174240/sid/2/nid/6.html#第07集$174240/sid/2/nid/7.html#第08集$174240/sid/2/nid/8.html#第09集$174240/sid/2/nid/9.html#第10集$174240/sid/2/nid/10.html";
|
||||
for (int i = 0; i < urls.split("\\$\\$\\$").length; i++) {
|
||||
String content = spider.playerContent(froms.split("\\$\\$\\$")[i], urls.split("\\$\\$\\$")[i].split("\\$")[1], 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
|
||||
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());
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
14daee5041b18644a7c510121ea5f2c2
|
||||
7ae661c64fbec918195dff6cae87a439
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "../jar/custom_spider.jar;md5;14daee5041b18644a7c510121ea5f2c2",
|
||||
"spider": "../jar/custom_spider.jar;md5;7ae661c64fbec918195dff6cae87a439",
|
||||
"lives": [
|
||||
{
|
||||
"name": "直播ipv6",
|
||||
|
|
|
|||
Loading…
Reference in New Issue