leijing 源
This commit is contained in:
parent
a4dbb6eaed
commit
88933c145d
|
|
@ -0,0 +1,164 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Class;
|
||||||
|
import com.github.catvod.bean.Result;
|
||||||
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.net.OkHttp;
|
||||||
|
import com.github.catvod.utils.Json;
|
||||||
|
import com.github.catvod.utils.Util;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
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.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class LeiJing extends Cloud {
|
||||||
|
private static final String siteUrl = "https://leijing1.com/";
|
||||||
|
|
||||||
|
private final String hostUrl = siteUrl;
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String, String> getHeader() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("User-Agent", Util.CHROME);
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> getHeaderWithCookie() {
|
||||||
|
Map<String, String> header = new HashMap<>();
|
||||||
|
header.put("User-Agent", Util.CHROME);
|
||||||
|
header.put("cookie", "esc_search_captcha=1; result=43");
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context, String extend) throws Exception {
|
||||||
|
|
||||||
|
super.init(context, extend);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String homeContent(boolean filter) {
|
||||||
|
List<Class> classes = new ArrayList<>();
|
||||||
|
Document doc = Jsoup.parse(OkHttp.string(siteUrl, getHeader()));
|
||||||
|
Elements elements = doc.select(" #tabNavigation > a.tab");
|
||||||
|
for (Element e : elements) {
|
||||||
|
String url = e.attr("href");
|
||||||
|
String name = e.text();
|
||||||
|
if (StringUtils.isNoneBlank(url)) {
|
||||||
|
classes.add(new Class(url, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.string(classes, parseVodListFromDoc(doc));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Vod> parseVodListFromDoc(Document doc) {
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
|
|
||||||
|
Elements topicItems = doc.select(".topicItem");
|
||||||
|
|
||||||
|
for (Element each : topicItems) {
|
||||||
|
// 检查是否有锁定标记
|
||||||
|
if (each.select(".cms-lock-solid").size() > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提取href
|
||||||
|
String href = each.select("h2 a").attr("href");
|
||||||
|
// 提取标题并处理空格
|
||||||
|
String title = each.select("h2 a").text().trim().replaceAll("\\s+", " ");
|
||||||
|
// 提取摘要
|
||||||
|
String r = each.select(".summary").text();
|
||||||
|
// 提取标签
|
||||||
|
String tag = each.select(".tag").text();
|
||||||
|
|
||||||
|
// 过滤条件
|
||||||
|
if (r.contains("content") && !r.contains("cloud")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (tag.contains("软件") || tag.contains("游戏") || tag.contains("书籍") || tag.contains("图片") || tag.contains("公告") || tag.contains("音乐") || tag.contains("课程")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建Video对象
|
||||||
|
Vod video = new Vod(href, title, "", "");
|
||||||
|
list.add(video);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||||
|
|
||||||
|
Document doc = Jsoup.parse(OkHttp.string(String.format("%s?tagId=%s&page=%s", siteUrl, tid, pg), getHeader()));
|
||||||
|
List<Vod> list = parseVodListFromDoc(doc);
|
||||||
|
int total = (Integer.parseInt(pg) + 1) * 19;
|
||||||
|
return Result.get().vod(list).page(Integer.parseInt(pg), Integer.parseInt(pg) + 1, 19, total).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
|
String vodId = ids.get(0);
|
||||||
|
Document doc = Jsoup.parse(OkHttp.string(siteUrl + vodId, getHeader()));
|
||||||
|
|
||||||
|
|
||||||
|
Vod item = new Vod();
|
||||||
|
item.setVodId(vodId);
|
||||||
|
item.setVodName(doc.selectFirst("div.title").text());
|
||||||
|
|
||||||
|
Elements elements = doc.select("a");
|
||||||
|
List<String> shareLinks = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Element element : elements) {
|
||||||
|
if (element.attr("href").contains("https://cloud.189.cn")) {
|
||||||
|
shareLinks.add(element.attr("href"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setVodPlayUrl(super.detailContentVodPlayUrl(shareLinks));
|
||||||
|
item.setVodPlayFrom(super.detailContentVodPlayFrom(shareLinks));
|
||||||
|
|
||||||
|
return Result.string(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStrByRegex(Pattern pattern, String str) {
|
||||||
|
Matcher matcher = pattern.matcher(str);
|
||||||
|
if (matcher.find()) return matcher.group(1).trim();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String searchContent(String key, boolean quick) throws Exception {
|
||||||
|
return searchContent(key, "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
||||||
|
return searchContent(key, pg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String searchContent(String key, String pg) {
|
||||||
|
String searchURL = siteUrl + String.format("search?keyword=%s", URLEncoder.encode(key));
|
||||||
|
String html = OkHttp.string(searchURL, getHeaderWithCookie());
|
||||||
|
Document doc = Jsoup.parse(html);
|
||||||
|
|
||||||
|
return Result.string(parseVodListFromDoc(doc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import com.github.catvod.spider.BiXin;
|
||||||
|
import com.github.catvod.spider.Init;
|
||||||
|
import com.github.catvod.spider.LeiJing;
|
||||||
|
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 LeiJingTest {
|
||||||
|
|
||||||
|
private Application mockContext;
|
||||||
|
|
||||||
|
private LeiJing spider;
|
||||||
|
|
||||||
|
@org.junit.Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
mockContext = RuntimeEnvironment.application;
|
||||||
|
Init.init(mockContext);
|
||||||
|
spider = new LeiJing();
|
||||||
|
//Server.get().start();
|
||||||
|
spider.init(mockContext,"");
|
||||||
|
// 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-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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\"}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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("?tagId=42238531387459", "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("thread?topicId=35473"));
|
||||||
|
System.out.println("detailContent--" + content);
|
||||||
|
|
||||||
|
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 content = spider.playerContent("移动0", "FqijauTCWHB5yHIgvTglMzr-0MoIhFgie++2mknZaFTuu0p6", new ArrayList<>());
|
||||||
|
System.out.println("playerContent--" + content);
|
||||||
|
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 @@
|
||||||
1313d67206e3f22317acc00838701e76
|
eda488df43e7c0a7586f8418c1e5659a
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;1313d67206e3f22317acc00838701e76",
|
"spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;eda488df43e7c0a7586f8418c1e5659a",
|
||||||
"lives": [
|
"lives": [
|
||||||
{
|
{
|
||||||
"name": "电视直播",
|
"name": "电视直播",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue