Push demo。
This commit is contained in:
parent
b75206cd6a
commit
75f67a197d
19
README.md
19
README.md
|
@ -102,6 +102,25 @@
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
**推送功能扩展(需v2.1.0.Beta6及以上版本)**
|
||||||
|
|
||||||
|
入口 [PushAgent](/app/src/main/java/com/github/catvod/spider/PushAgent.java)
|
||||||
|
|
||||||
|
需要在配置文件中,加入key为`push_agent`的站点,数据返回格式和普通爬虫一致
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": "push_agent",
|
||||||
|
"name": "推送",
|
||||||
|
"type": 3,
|
||||||
|
"api": "csp_PushAgent",
|
||||||
|
"searchable": 0,
|
||||||
|
"quickSearch": 0,
|
||||||
|
"filterable": 0
|
||||||
|
}
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
## 基础类
|
## 基础类
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import com.github.catvod.crawler.Spider;
|
||||||
|
import com.github.catvod.utils.Misc;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author: @SDL
|
||||||
|
*/
|
||||||
|
public class PushAgent extends Spider {
|
||||||
|
@Override
|
||||||
|
public String detailContent(List<String> ids) {
|
||||||
|
try {
|
||||||
|
String url = ids.get(0);
|
||||||
|
if (Misc.isVip(url)) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
JSONArray list = new JSONArray();
|
||||||
|
JSONObject vodAtom = new JSONObject();
|
||||||
|
vodAtom.put("vod_id", url);
|
||||||
|
vodAtom.put("vod_name", url);
|
||||||
|
vodAtom.put("vod_pic", "https://pic.rmb.bdstatic.com/bjh/1d0b02d0f57f0a42201f92caba5107ed.jpeg");
|
||||||
|
vodAtom.put("type_name", "官源");
|
||||||
|
vodAtom.put("vod_year", "");
|
||||||
|
vodAtom.put("vod_area", "");
|
||||||
|
vodAtom.put("vod_remarks", "");
|
||||||
|
vodAtom.put("vod_actor", "");
|
||||||
|
vodAtom.put("vod_director", "");
|
||||||
|
vodAtom.put("vod_content", "");
|
||||||
|
vodAtom.put("vod_play_from", "jx");
|
||||||
|
vodAtom.put("vod_play_url", "立即播放$" + url);
|
||||||
|
list.put(vodAtom);
|
||||||
|
result.put("list", list);
|
||||||
|
return result.toString();
|
||||||
|
} else if (Misc.isVideoFormat(url)) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
JSONArray list = new JSONArray();
|
||||||
|
JSONObject vodAtom = new JSONObject();
|
||||||
|
vodAtom.put("vod_id", url);
|
||||||
|
vodAtom.put("vod_name", url);
|
||||||
|
vodAtom.put("vod_pic", "https://pic.rmb.bdstatic.com/bjh/1d0b02d0f57f0a42201f92caba5107ed.jpeg");
|
||||||
|
vodAtom.put("type_name", "直连");
|
||||||
|
vodAtom.put("vod_play_from", "player");
|
||||||
|
vodAtom.put("vod_play_url", "立即播放$" + url);
|
||||||
|
list.put(vodAtom);
|
||||||
|
result.put("list", list);
|
||||||
|
return result.toString();
|
||||||
|
} else if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
JSONArray list = new JSONArray();
|
||||||
|
JSONObject vodAtom = new JSONObject();
|
||||||
|
vodAtom.put("vod_id", url);
|
||||||
|
vodAtom.put("vod_name", url);
|
||||||
|
vodAtom.put("vod_pic", "https://pic.rmb.bdstatic.com/bjh/1d0b02d0f57f0a42201f92caba5107ed.jpeg");
|
||||||
|
vodAtom.put("type_name", "网页");
|
||||||
|
vodAtom.put("vod_play_from", "parse");
|
||||||
|
vodAtom.put("vod_play_url", "立即播放$" + url);
|
||||||
|
list.put(vodAtom);
|
||||||
|
result.put("list", list);
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
|
try {
|
||||||
|
if (flag.equals("jx")) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("parse", 1);
|
||||||
|
result.put("jx", "1");
|
||||||
|
result.put("url", id);
|
||||||
|
return result.toString();
|
||||||
|
} else if (flag.equals("parse")) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("parse", 1);
|
||||||
|
result.put("playUrl", "");
|
||||||
|
result.put("url", id);
|
||||||
|
return result.toString();
|
||||||
|
} else if (flag.equals("player")) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("parse", 0);
|
||||||
|
result.put("playUrl", "");
|
||||||
|
result.put("url", id);
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue