add Spider Enlienli by 不负此生.
This commit is contained in:
parent
6f1a90a1c2
commit
4b3a2b4a2c
|
@ -14,3 +14,6 @@
|
||||||
.cxx
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
/app/proguardMapping.txt
|
/app/proguardMapping.txt
|
||||||
|
/LTDecodeSpace
|
||||||
|
/adb.exe
|
||||||
|
/LTDecodeNew3.exe
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
|
|
||||||
### 如何在自定义配置中调用我们代码包中的Spider
|
### 如何在自定义配置中调用我们代码包中的Spider
|
||||||
----
|
----
|
||||||
同样在自定义json中加入相应的播放源即可,**type=3, api对应你代码工程中自定义的爬虫类名,例如实例工程中的`Aidi`**
|
同样在自定义json中加入相应的播放源即可,**type=3, api对应你代码工程中自定义的爬虫类名(api必须是`csp_`开头),例如实例工程中的`Aidi`**
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"key": "adys_diy",
|
"key": "csp_Aidi",
|
||||||
"name": "爱迪",
|
"name": "爱迪",
|
||||||
"type": 3,
|
"type": 3,
|
||||||
"api": "Aidi",
|
"api": "csp_Aidi",
|
||||||
"searchable": 1,
|
"searchable": 1,
|
||||||
"quickSearch": 0,
|
"quickSearch": 0,
|
||||||
"filterable": 1
|
"filterable": 1
|
||||||
|
|
|
@ -77,4 +77,23 @@ public abstract class Spider {
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* webview解析时使用 可自定义判断当前加载的 url 是否是视频
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isVideoFormat(String url) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否手动检测webview中加载的url
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean manualVideoCheck() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,11 @@ import java.util.TreeMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Demo for spider
|
||||||
|
* <p>
|
||||||
|
* Author: CatVod
|
||||||
|
*/
|
||||||
public class Aidi extends Spider {
|
public class Aidi extends Spider {
|
||||||
private static final String siteUrl = "https://aidi.tv";
|
private static final String siteUrl = "https://aidi.tv";
|
||||||
private static final String siteHost = "aidi.tv";
|
private static final String siteHost = "aidi.tv";
|
||||||
|
|
|
@ -0,0 +1,264 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.github.catvod.crawler.Spider;
|
||||||
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
|
import com.github.catvod.crawler.SpiderReq;
|
||||||
|
import com.github.catvod.crawler.SpiderReqResult;
|
||||||
|
import com.github.catvod.crawler.SpiderUrl;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 嗯哩嗯哩
|
||||||
|
* <p>
|
||||||
|
* Author: 群友 不负此生
|
||||||
|
*/
|
||||||
|
public class Enlienli extends Spider {
|
||||||
|
|
||||||
|
private String siteUrl = "https://api.app.kongbuya.com";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context) {
|
||||||
|
super.init(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashMap<String, String> getHeaders(String url) {
|
||||||
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("Connection", "Keep-Alive");
|
||||||
|
headers.put("User-Agent", "okhttp/4.0.1");
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String homeContent(boolean filter) {
|
||||||
|
try {
|
||||||
|
SpiderUrl su = new SpiderUrl(siteUrl + "/api.php/provide/home_nav?", getHeaders(siteUrl));
|
||||||
|
SpiderReqResult srr = SpiderReq.get(su);
|
||||||
|
JSONArray jsonArray = new JSONArray(srr.content);
|
||||||
|
JSONArray classes = new JSONArray();
|
||||||
|
JSONObject filterConfig = new JSONObject();
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject jObj = jsonArray.getJSONObject(i);
|
||||||
|
String typeName = jObj.getString("name");
|
||||||
|
String typeId = jObj.getString("id");
|
||||||
|
if (typeName.equals("推荐")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
JSONObject newCls = new JSONObject();
|
||||||
|
newCls.put("type_id", typeId);
|
||||||
|
newCls.put("type_name", typeName);
|
||||||
|
classes.put(newCls);
|
||||||
|
try {
|
||||||
|
JSONArray typeExtend = jObj.getJSONArray("msg");
|
||||||
|
JSONArray extendsAll = new JSONArray();
|
||||||
|
for (int j = 0; j < typeExtend.length(); j++) {
|
||||||
|
JSONObject typeExtendObj = typeExtend.getJSONObject(j);
|
||||||
|
String typeExtendKey = typeExtendObj.getString("name");
|
||||||
|
JSONArray newTypeExtendKeys = typeExtendObj.getJSONArray("data");
|
||||||
|
if (newTypeExtendKeys.length() <= 1)
|
||||||
|
continue;
|
||||||
|
String typeExtendName = newTypeExtendKeys.getString(0);
|
||||||
|
JSONObject newTypeExtend = new JSONObject();
|
||||||
|
newTypeExtend.put("key", typeExtendKey);
|
||||||
|
newTypeExtend.put("name", typeExtendName);
|
||||||
|
JSONArray newTypeExtendKV = new JSONArray();
|
||||||
|
{
|
||||||
|
JSONObject kvAll = new JSONObject();
|
||||||
|
kvAll.put("n", "全部");
|
||||||
|
kvAll.put("v", "");
|
||||||
|
newTypeExtendKV.put(kvAll);
|
||||||
|
}
|
||||||
|
for (int k = 1; k < newTypeExtendKeys.length(); k++) {
|
||||||
|
JSONObject kv = new JSONObject();
|
||||||
|
kv.put("n", newTypeExtendKeys.getString(k));
|
||||||
|
kv.put("v", newTypeExtendKeys.getString(k));
|
||||||
|
newTypeExtendKV.put(kv);
|
||||||
|
}
|
||||||
|
newTypeExtend.put("value", newTypeExtendKV);
|
||||||
|
extendsAll.put(newTypeExtend);
|
||||||
|
}
|
||||||
|
filterConfig.put(typeId, extendsAll);
|
||||||
|
} catch (Exception e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("class", classes);
|
||||||
|
if (filter) {
|
||||||
|
result.put("filters", filterConfig);
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String homeVideoContent() {
|
||||||
|
try {
|
||||||
|
String url = siteUrl + "/api.php/provide/home_data?page=1&id=0";
|
||||||
|
SpiderUrl su = new SpiderUrl(url, getHeaders(url));
|
||||||
|
SpiderReqResult srr = SpiderReq.get(su);
|
||||||
|
JSONObject jsonObject = new JSONObject(srr.content);
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
if (jsonObject.has("tv")) {
|
||||||
|
JSONArray data = jsonObject.getJSONObject("tv").getJSONArray("data");
|
||||||
|
for (int i = 0; i < data.length(); i++) {
|
||||||
|
jsonArray.put(data.getJSONObject(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jsonObject.has("video")) {
|
||||||
|
JSONArray vs = jsonObject.getJSONArray("video");
|
||||||
|
for (int i = 0; i < vs.length(); i++) {
|
||||||
|
JSONArray data = vs.getJSONObject(i).getJSONArray("data");
|
||||||
|
for (int j = 0; j < data.length(); j++) {
|
||||||
|
jsonArray.put(data.getJSONObject(j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONArray videos = new JSONArray();
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject vObj = jsonArray.getJSONObject(i);
|
||||||
|
JSONObject v = new JSONObject();
|
||||||
|
v.put("vod_id", vObj.getString("id"));
|
||||||
|
v.put("vod_name", vObj.getString("name"));
|
||||||
|
v.put("vod_pic", vObj.getString("img"));
|
||||||
|
v.put("vod_remarks", vObj.getString("qingxidu"));
|
||||||
|
videos.put(v);
|
||||||
|
}
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("list", videos);
|
||||||
|
return result.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||||
|
try {
|
||||||
|
String url = siteUrl + "/api.php/provide/vod_list?page=" + pg + "&id=" + tid;
|
||||||
|
Set<String> keys = extend.keySet();
|
||||||
|
for (String key : keys) {
|
||||||
|
url += "&" + key + "=" + URLEncoder.encode(extend.get(key));
|
||||||
|
}
|
||||||
|
SpiderUrl su = new SpiderUrl(url, getHeaders(url));
|
||||||
|
SpiderReqResult srr = SpiderReq.get(su);
|
||||||
|
JSONArray jsonArray = new JSONArray(srr.content);
|
||||||
|
JSONArray videos = new JSONArray();
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject vObj = jsonArray.getJSONObject(i);
|
||||||
|
JSONObject v = new JSONObject();
|
||||||
|
v.put("vod_id", vObj.getString("id"));
|
||||||
|
v.put("vod_name", vObj.getString("name"));
|
||||||
|
v.put("vod_pic", vObj.getString("img"));
|
||||||
|
v.put("vod_remarks", vObj.getString("qingxidu"));
|
||||||
|
videos.put(v);
|
||||||
|
}
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
int limit = 20;
|
||||||
|
int page = Integer.parseInt(pg);
|
||||||
|
int total = Integer.MAX_VALUE;
|
||||||
|
int pageCount = videos.length() < 20 ? page : page + 1;
|
||||||
|
result.put("page", page);
|
||||||
|
result.put("pagecount", pageCount);
|
||||||
|
result.put("limit", limit);
|
||||||
|
result.put("total", total);
|
||||||
|
result.put("list", videos);
|
||||||
|
return result.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String detailContent(List<String> ids) {
|
||||||
|
try {
|
||||||
|
String url = siteUrl + "/api.php/provide/vod_detail?token=&id=" + ids.get(0) + "&ac=vod_detail";
|
||||||
|
SpiderUrl su = new SpiderUrl(url, getHeaders(url));
|
||||||
|
SpiderReqResult srr = SpiderReq.get(su);
|
||||||
|
JSONObject jsonObject = new JSONObject(srr.content);
|
||||||
|
JSONObject vodList = new JSONObject();
|
||||||
|
vodList.put("vod_id", ids.get(0));
|
||||||
|
vodList.put("vod_name", jsonObject.getString("name"));
|
||||||
|
vodList.put("vod_pic", jsonObject.getString("img"));
|
||||||
|
vodList.put("type_name", jsonObject.getString("type"));
|
||||||
|
vodList.put("vod_year", "");
|
||||||
|
vodList.put("vod_area", "");
|
||||||
|
vodList.put("vod_remarks", jsonObject.getString("remarks"));
|
||||||
|
vodList.put("vod_actor", jsonObject.getString("actor"));
|
||||||
|
vodList.put("vod_director", jsonObject.getString("director"));
|
||||||
|
vodList.put("vod_content", jsonObject.getString("info"));
|
||||||
|
|
||||||
|
vodList.put("vod_play_from", jsonObject.getString("playcode"));
|
||||||
|
vodList.put("vod_play_url", jsonObject.getString("playlist"));
|
||||||
|
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
JSONArray list = new JSONArray();
|
||||||
|
list.put(vodList);
|
||||||
|
result.put("list", list);
|
||||||
|
return result.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
|
try {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("parse", 0);
|
||||||
|
result.put("playUrl", "");
|
||||||
|
result.put("url", id);
|
||||||
|
return result.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String searchContent(String key, boolean quick) {
|
||||||
|
if (quick)
|
||||||
|
return "";
|
||||||
|
try {
|
||||||
|
String url = siteUrl + "/api.php/provide/search_result?video_name=" + URLEncoder.encode(key);
|
||||||
|
SpiderUrl su = new SpiderUrl(url, getHeaders(url));
|
||||||
|
SpiderReqResult srr = SpiderReq.get(su);
|
||||||
|
JSONObject jsonObject = new JSONObject(srr.content);
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONObject("result").getJSONArray("search_result");
|
||||||
|
JSONArray videos = new JSONArray();
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject vObj = jsonArray.getJSONObject(i);
|
||||||
|
JSONObject v = new JSONObject();
|
||||||
|
v.put("vod_id", vObj.getString("id"));
|
||||||
|
v.put("vod_name", vObj.getString("video_name"));
|
||||||
|
v.put("vod_pic", vObj.getString("img"));
|
||||||
|
//v.put("vod_remarks", vObj.getString(""));
|
||||||
|
videos.put(v);
|
||||||
|
}
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("list", videos);
|
||||||
|
return result.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
SpiderDebug.log(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue