add - bili55

This commit is contained in:
yangqiang3504
2022-09-02 10:00:16 +08:00
parent 9e4a912892
commit d2b969675f
5 changed files with 300 additions and 449 deletions
@@ -3,17 +3,14 @@ package com.github.catvod.spider;
import android.content.Context; import android.content.Context;
import android.net.UrlQuerySanitizer; import android.net.UrlQuerySanitizer;
import android.text.TextUtils; import android.text.TextUtils;
import com.github.catvod.crawler.Spider; import com.github.catvod.crawler.Spider;
import com.github.catvod.crawler.SpiderDebug; import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.utils.Misc; import com.github.catvod.utils.Misc;
import com.github.catvod.utils.okhttp.OKCallBack; import com.github.catvod.utils.okhttp.OKCallBack;
import com.github.catvod.utils.okhttp.OkHttpUtil; import com.github.catvod.utils.okhttp.OkHttpUtil;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
@@ -26,6 +23,11 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class PushAgent extends Spider { public class PushAgent extends Spider {
private static String j = ""; private static String j = "";
@@ -39,68 +41,27 @@ public class PushAgent extends Spider {
private static final String SiteUrl = "https://api.aliyundrive.com"; private static final String SiteUrl = "https://api.aliyundrive.com";
private static final Pattern AliPLink = Pattern.compile("(https://www.aliyundrive.com/s/[^\"]+)"); private static final Pattern AliPLink = Pattern.compile("(https://www.aliyundrive.com/s/[^\"]+)");
public static Pattern Folder = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?"); public static Pattern Folder = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
public static String Token="http://catvod.fun:8001/tv/ali.txt"; public static String Token="3a49cf29cf20410997247c6eb4509be9";
public static JSONObject siteRule = null;
public static String jsonUrl = "http://test.xinjun58.com/sp/d.json";
@Override @Override
public void init(Context context, String extend) { public void init(Context context, String extend) {
super.init(context, extend); super.init(context, extend);
getToken(Token); if (extend != null) {
} String[] arr = extend.split(";");
public void getToken(String token){
if(token!=null&&token.equals("")){
String[] arr = token.split(";");
if (arr.length > 0) { if (arr.length > 0) {
token = arr[0]; this.Token = arr[0];
if(arr.length>2){ if(arr.length>2){
String aid = arr[2]; String aid = arr[2];
if(Misc.isNumeric(aid)) type = Integer.valueOf(aid); if(Misc.isNumeric(aid)) type = Integer.valueOf(aid);
} }
} }else Token = extend;
if (token.startsWith("http")) { /* if (extend.startsWith("http")) {
Token = OkHttpUtil.string(token, null); Token = OkHttpUtil.string(extend, null);
}else Token = token; } */
} }
} }
public JSONObject fetchRule(boolean flag,int t) { protected static long Time() {
try {
if (flag || siteRule == null) {
String json = OkHttpUtil.string(jsonUrl+"?t="+Time(), null);
JSONObject jo = new JSONObject(json);
if(t==0) {
String[] fenleis = getRuleVal(jo,"fenlei", "").split("#");
for (String fenlei : fenleis) {
String[] info = fenlei.split("\\$");
jo.remove(info[1]);
}
siteRule = jo;
String tk = siteRule.optString("token","");
if(!tk.equals("")){
getToken(tk);
}
}
return jo;
}
} catch (JSONException e) {
}
return siteRule;
}
public String getRuleVal(JSONObject o,String key, String defaultVal) {
String v = o.optString(key);
if (v.isEmpty() || v.equals(""))
return defaultVal;
return v;
}
public String getRuleVal(JSONObject o,String key) {
return getRuleVal(o,key, "");
}
public static long Time() {
return (System.currentTimeMillis() / 1000) + n; return (System.currentTimeMillis() / 1000) + n;
} }
@@ -388,7 +349,7 @@ public class PushAgent extends Spider {
} }
} }
public String getAliContent(List<String> list,String pic,JSONObject jSONObject6) { public String getAliContent(List<String> list,String pic) {
String str; String str;
try { try {
String url = list.get(0).trim(); String url = list.get(0).trim();
@@ -438,9 +399,12 @@ public class PushAgent extends Spider {
jSONObject4 = jSONArray.getJSONObject(0); jSONObject4 = jSONArray.getJSONObject(0);
str = jSONObject4.getString("file_id"); str = jSONObject4.getString("file_id");
} }
JSONObject jSONObject6 = new JSONObject();
jSONObject6.put("vod_id", url); jSONObject6.put("vod_id", url);
String string3 = jSONObject3.getString("share_name"); String string3 = jSONObject3.getString("share_name");
jSONObject6.put("vod_name", string3); jSONObject6.put("vod_name", string3);
jSONObject6.put("vod_pic", pic);
jSONObject6.put("vod_content", url);
jSONObject6.put("vod_play_from", "AliYun"); jSONObject6.put("vod_play_from", "AliYun");
ArrayList arrayList = new ArrayList(); ArrayList arrayList = new ArrayList();
String string4 = jSONObject4.getString("type"); String string4 = jSONObject4.getString("type");
@@ -497,62 +461,48 @@ public class PushAgent extends Spider {
if (idInfo.length>1&&!idInfo[1].equals("")) { if (idInfo.length>1&&!idInfo[1].equals("")) {
pic = idInfo[1].trim(); pic = idInfo[1].trim();
} }
if(pic==null) pic = Misc.getWebName(url, 1);
Pattern pattern = Folder; Pattern pattern = Folder;
Pattern pattern2 = AliPLink; Pattern pattern2 = AliPLink;
Matcher matcher2 = pattern2.matcher(url); Matcher matcher2 = pattern2.matcher(url);
Matcher matcher = pattern.matcher(url); Matcher matcher = pattern.matcher(url);
List<String> vodItems = new ArrayList<>(); List<String> vodItems = new ArrayList<>();
ArrayList<String> aslist = new ArrayList<>();
JSONArray lists = new JSONArray();
String typeName = Misc.getWebName(url, 0);
JSONObject vodAtom = new JSONObject();
String VodName = "",director = "",actor = "",desc = "";
vodAtom.put("vod_id", url);
vodAtom.put("vod_pic", pic);
vodAtom.put("type_name", typeName);
vodAtom.put("vod_content", url);
vodAtom.put("vod_area", type + Token);
if (Misc.isVip(url) && !url.contains("qq.com") && !url.contains("mgtv.com")) { if (Misc.isVip(url) && !url.contains("qq.com") && !url.contains("mgtv.com")) {
Elements playListA = null; String typeName = "官源",vpic="";
Document doc = Jsoup.parse(OkHttpUtil.string(url, Misc.Headers(0,url))); Document doc = Jsoup.parse(OkHttpUtil.string(url, Misc.Headers(0,url)));
String baseUrl = url.replaceAll("(^https?://.*?)(:\\d+)?/.*$", "$1");//https://www.dyk9.com String VodName = doc.select("head > title").text();
if (url.contains("bilibili.com/bangumi/play/ep")) {//第一集地址
String nids = url.replaceAll(".*/ep(\\d+).*", "$1");
int nid = Integer.parseInt(nids);
Elements el = doc.select(".ep-list-progress");
if(!el.isEmpty()){
String ptext = doc.select(".ep-list-progress").text();
String t = ptext.replaceAll("\\d+/(\\d+)", "$1");
int z = Integer.parseInt(t);
for (int i = 0; i < z; i++) {
int x = nid+i;
String id = baseUrl+"/bangumi/play/ep"+x+"/";
String name = i+1+"";
vodItems.add(name + "$" + id);
}
String playList = TextUtils.join("#", vodItems);
vodAtom.put("vod_play_url", playList);
}
} else {
vodAtom.put("vod_play_url", "立即播放$" + url);
}
VodName = doc.select("head > title").text();
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
JSONArray lists = new JSONArray();
JSONObject vodAtom = new JSONObject();
if(url.contains("iqiyi")) {
typeName = "爱奇艺";
vpic = "http://image.xinjun58.com/sp/pic/bg/iqiyi.jpg";
}else if(url.contains("bili"))vpic="http://image.xinjun58.com/sp/pic/bg/bili.jpg";
vodAtom.put("vod_id", url);
vodAtom.put("vod_name", VodName); vodAtom.put("vod_name", VodName);
vodAtom.put("vod_pic", pic == null ? vpic : pic);
vodAtom.put("type_name", typeName);
vodAtom.put("vod_year", "");
vodAtom.put("vod_area", "");
vodAtom.put("vod_remarks", "");
vodAtom.put("vod_actor", "");
vodAtom.put("vod_director", "");
vodAtom.put("vod_content", url);
vodAtom.put("vod_play_from", "jx"); vodAtom.put("vod_play_from", "jx");
vodAtom.put("vod_play_url", "立即播放$" + url);
lists.put(vodAtom); lists.put(vodAtom);
result.put("list", lists); result.put("list", lists);
return result.toString(); return result.toString();
} else if (Misc.isVip(url) && url.contains("qq.com")) { } else if (Misc.isVip(url) && url.contains("qq.com")) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
JSONArray lists = new JSONArray();
JSONObject vodAtom = new JSONObject();
if (url.contains("m.v.")) { if (url.contains("m.v.")) {
String cid = url.replaceAll("https://m.v.qq.com/x/m/play\\?cid=(\\w+)&.*", "$1"); String cid = url.replaceAll("https://m.v.qq.com/x/m/play\\?cid=(\\w+)&.*", "$1");
String vid = url.replaceAll("https://m.v.qq.com/x/m/play\\?cid=\\w+&vid=(\\w+)", "$1"); String vid = url.replaceAll("https://m.v.qq.com/x/m/play\\?cid=\\w+&vid=(\\w+)", "$1");
url = "https://v.qq.com/x/cover/" + cid + "/" + vid + ".html"; url = "https://v.qq.com/x/cover/" + cid + "/" + vid + ".html";
} }
Document doc = Jsoup.parse(OkHttpUtil.string(url, sHeaders(true))); Document doc = Jsoup.parse(OkHttpUtil.string(url, sHeaders(true)));
VodName = doc.select("head > title").text(); String VodName = doc.select("head > title").text();
Elements playListA = doc.select("div.episode-list-rect__item"); Elements playListA = doc.select("div.episode-list-rect__item");
if (playListA.isEmpty()) { if (playListA.isEmpty()) {
playListA = doc.select("div.episode-list-hor .episode-item"); playListA = doc.select("div.episode-list-hor .episode-item");
@@ -576,20 +526,31 @@ public class PushAgent extends Spider {
} }
String remarks = doc.select(".intro-wrapper__update-desc").text(); String remarks = doc.select(".intro-wrapper__update-desc").text();
vodAtom.put("vod_id", url);
vodAtom.put("vod_name", VodName); vodAtom.put("vod_name", VodName);
vodAtom.put("vod_pic", pic == null ? "http://image.xinjun58.com/sp/pic/bg/qq.jpg" : pic);
vodAtom.put("type_name", "腾讯TV");
vodAtom.put("vod_year", "");
vodAtom.put("vod_area", "");
vodAtom.put("vod_remarks", remarks); vodAtom.put("vod_remarks", remarks);
vodAtom.put("vod_actor", "");
vodAtom.put("vod_director", "");
vodAtom.put("vod_content", url);
vodAtom.put("vod_play_from", "jx"); vodAtom.put("vod_play_from", "jx");
lists.put(vodAtom); lists.put(vodAtom);
result.put("list", lists); result.put("list", lists);
return result.toString(); return result.toString();
} else if (Misc.isVip(url) && url.contains("mgtv.com")) { } else if (Misc.isVip(url) && url.contains("mgtv.com")) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
JSONArray lists = new JSONArray();
JSONObject vodAtom = new JSONObject();
Pattern mgtv = Pattern.compile("https://\\S+mgtv.com/b/(\\d+)/(\\d+).html.*"); Pattern mgtv = Pattern.compile("https://\\S+mgtv.com/b/(\\d+)/(\\d+).html.*");
Matcher mgtv1 = mgtv.matcher(url); Matcher mgtv1 = mgtv.matcher(url);
String VodNames = "";
if (mgtv1.find()) { if (mgtv1.find()) {
String Ep = "https://pcweb.api.mgtv.com/episode/list?video_id=" + mgtv1.group(2); String Ep = "https://pcweb.api.mgtv.com/episode/list?video_id=" + mgtv1.group(2);
JSONObject Data = new JSONObject(OkHttpUtil.string(Ep, Headers())); JSONObject Data = new JSONObject(OkHttpUtil.string(Ep, Headers()));
VodName = Data.getJSONObject("data").getJSONObject("info").getString("title"); VodNames = Data.getJSONObject("data").getJSONObject("info").getString("title");
JSONArray a = new JSONArray(Data.getJSONObject("data").getString("list")); JSONArray a = new JSONArray(Data.getJSONObject("data").getString("list"));
if (a.length() > 0) { if (a.length() > 0) {
for (int i = 0; i < a.length(); i++) { for (int i = 0; i < a.length(); i++) {
@@ -597,7 +558,7 @@ public class PushAgent extends Spider {
String isnew = jObj.getString("isnew"); String isnew = jObj.getString("isnew");
String isvip = jObj.getString("isvip"); String isvip = jObj.getString("isvip");
if (!(isnew.equals("2")&&isvip.equals("0"))) { if (!(isnew.equals("2")&&isvip.equals("0"))) {
VodName = jObj.getString("t4"); String VodName = jObj.getString("t4");
String id = jObj.getString("video_id"); String id = jObj.getString("video_id");
String VodId = "https://www.mgtv.com/b/" + mgtv1.group(1) + "/" + id + ".html"; String VodId = "https://www.mgtv.com/b/" + mgtv1.group(1) + "/" + id + ".html";
vodItems.add(VodName + "$" + VodId); vodItems.add(VodName + "$" + VodId);
@@ -609,14 +570,28 @@ public class PushAgent extends Spider {
vodAtom.put("vod_play_url", "立即播放$" + url); vodAtom.put("vod_play_url", "立即播放$" + url);
} }
} }
vodAtom.put("vod_name", VodName); vodAtom.put("vod_id", url);
vodAtom.put("vod_name", VodNames);
vodAtom.put("vod_pic", pic == null ? "http://image.xinjun58.com/sp/pic/bg/mgtv.jpg" : pic);
vodAtom.put("type_name", "芒果TV");
vodAtom.put("vod_year", "");
vodAtom.put("vod_area", "");
vodAtom.put("vod_remarks", "");
vodAtom.put("vod_actor", "");
vodAtom.put("vod_director", "");
vodAtom.put("vod_content", url);
vodAtom.put("vod_play_from", "jx"); vodAtom.put("vod_play_from", "jx");
lists.put(vodAtom); lists.put(vodAtom);
result.put("list", lists); result.put("list", lists);
return result.toString(); return result.toString();
} else if (Misc.isVideoFormat(url)) { } else if (Misc.isVideoFormat(url)) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
vodAtom.put("vod_name", typeName); JSONArray lists = new JSONArray();
JSONObject vodAtom = new JSONObject();
vodAtom.put("vod_id", url);
vodAtom.put("vod_name", url);
vodAtom.put("vod_content", url);
vodAtom.put("vod_pic", pic == null ? "" : pic);
vodAtom.put("type_name", "直连"); vodAtom.put("type_name", "直连");
vodAtom.put("vod_play_from", "player"); vodAtom.put("vod_play_from", "player");
vodAtom.put("vod_play_url", "立即播放$" + url); vodAtom.put("vod_play_url", "立即播放$" + url);
@@ -624,12 +599,17 @@ public class PushAgent extends Spider {
result.put("list", lists); result.put("list", lists);
return result.toString(); return result.toString();
} else if (url.startsWith("magnet")) { } else if (url.startsWith("magnet")) {
VodName = url; String VodName = url;
if (url.length() > 100) { if (url.length() > 100) {
VodName = url.substring(0, 30) + "..." + url.substring(url.length() - 10); VodName = url.substring(0, 30) + "..." + url.substring(url.length() - 10);
} }
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
JSONArray lists = new JSONArray();
JSONObject vodAtom = new JSONObject();
vodAtom.put("vod_id", url);
vodAtom.put("vod_name", VodName); vodAtom.put("vod_name", VodName);
vodAtom.put("vod_content", url);
vodAtom.put("vod_pic", pic);
vodAtom.put("type_name", "磁力"); vodAtom.put("type_name", "磁力");
vodAtom.put("vod_play_from", "磁力测试"); vodAtom.put("vod_play_from", "磁力测试");
vodAtom.put("vod_play_url", "立即播放$" + url); vodAtom.put("vod_play_url", "立即播放$" + url);
@@ -637,74 +617,29 @@ public class PushAgent extends Spider {
result.put("list", lists); result.put("list", lists);
return result.toString(); return result.toString();
} else if (url.startsWith("http") && (matcher2.find())) { } else if (url.startsWith("http") && (matcher2.find())) {
return getAliContent(list,pic,vodAtom); pic = pic == null ? "http://image.xinjun58.com/sp/pic/bg/ali.jpg" : pic;
return getAliContent(list,pic);
} else if (url.startsWith("http") && (!matcher.find()) && (!matcher2.find())) { } else if (url.startsWith("http") && (!matcher.find()) && (!matcher2.find())) {
Document doc = null; JSONObject vodAtom = new JSONObject();
String baseUrl = url.replaceAll("(^https?://.*?)(:\\d+)?/.*$", "$1");//https://www.dyk9.com Document doc = Jsoup.parse(OkHttpUtil.string(url, Misc.Headers(0,url)));
Pattern urlder = Pattern.compile(".*(\\d+.html|\\d+/)$");
Pattern urlder1 = Pattern.compile(".*-?(\\d+)/");
Pattern urlder2 = Pattern.compile(".*-\\d+-\\d+");
String content=null,uri=null,a=null,b=null,hz="",text=null,prefxs=null,detailRex=null;
boolean fb = true;
Matcher mh = null;
if(url.endsWith("/")) hz = "/";
else {
hz=url.replaceAll(".*(\\..*)", "$1");
if(hz.length()>6)hz="";
}
if(!url.contains("-")&&hz.length()>0){
String site2 = fetchRule(false,0).optString("site2", "");
if (site2.contains(typeName)) {//https://www.dyk9.com/vod/detail/11203.html 详情页面再点击一次之后 才有播放地址
doc = Jsoup.parse(OkHttpUtil.string(url, Misc.Headers(0,url)));
content = doc.body().html();
hz=url.replaceAll(".*(\\..*)", "$1");
detailRex = url.replaceAll(".*/(\\d+)\\..*", "$1");
mh = Pattern.compile("href=\"(.*/"+detailRex+"-.*"+hz+")\"").matcher(content);
while (mh.find()&&fb){
fb=false;
url = baseUrl+mh.group(1);
}
setVideoDesc(vodAtom, content);
}
}
doc = Jsoup.parse(OkHttpUtil.string(url, Misc.Headers(0,url)));
VodName = doc.select("head > title").text();
doc.select("div.playon").remove(); doc.select("div.playon").remove();
content = doc.body().html();//[\u4e00-\u9fa5]+ String baseUrl = url.replaceAll("(^https?://.*?)(:\\d+)?/.*$", "$1");//https://www.dyk9.com
if(content.equals("")) return ""; String content = doc.body().html();//[\u4e00-\u9fa5]+
String VodName = doc.select("head > title").text();
Pattern urlder = Pattern.compile(".*-\\d+.html");
Pattern urlder2 = Pattern.compile(".*-\\d+-\\d+");
String uri=null,a=null,b=null,text=null,prefxs=null;
if(urlder.matcher(url).find()){//集合多个视频 if(urlder.matcher(url).find()){//集合多个视频
//String prefxUrl = url.replace(".html", ""); String prefxUrl = url.replaceAll("(.*)-\\d+.html", "$1");
//prefxUrl = url.replaceAll("(.*)-\\d+", "$1"); prefxUrl = prefxUrl.replace(baseUrl, "");// /vod/play/70631-1
//prefxUrl = prefxUrl.replace(baseUrl, "");// /vod/play/70631-1 prefxs= url.replaceAll("(.*)-\\d+-\\d+.html", "$1");
if(!url.contains("-")){
detailRex = url.replaceAll(".*/(\\d+)\\..*", "$1");
detailRex = "href=\"(.*"+detailRex+"-.*"+hz+")\"";
}else if(url.split("-").length<2&&urlder1.matcher(url).find()){
detailRex = url.replaceAll(".*-(\\d+)"+hz, "$1");
detailRex = "href=\"(.*"+detailRex+"-.*"+hz+")\"";
}
if (detailRex!=null) {
mh = Pattern.compile(detailRex).matcher(content);
while (mh.find()&&fb){
fb=false;
url = baseUrl+mh.group(1);
}
}
//https://dyxs13.com/paly-47817-10-1/
if (!hz.equals("")) {
prefxs= url.replaceAll("(.*)-\\d+-\\d+"+hz, "$1");
}else prefxs= url.replaceAll("(.*)-\\d+-\\d+", "$1");
prefxs = prefxs.replace(baseUrl, "");// /vod/play/70631 prefxs = prefxs.replace(baseUrl, "");// /vod/play/70631
prefxs = prefxs.replace(".html", "");
ArrayList<String> playList = new ArrayList<>(); ArrayList<String> playList = new ArrayList<>();
for (int i = 0; i < 12; i++) {
fb = false; for (int i = 0; i < 5; i++) {
if(!content.contains(prefxs+"-"+i+"-"))continue; if(!content.contains(prefxs+"-"+i+"-"))continue;
Map<String, String> m = new LinkedHashMap<>(); Map<String, String> m = new LinkedHashMap<>();
Matcher mat = Pattern.compile("href=\"("+prefxs+"-"+i+"-\\d+"+hz+").*?/a>").matcher(content); Matcher mat = Pattern.compile("href=\"("+prefxs+"-"+i+"-\\d+.html).*?/a>").matcher(content);
while (mat.find()){ while (mat.find()){
uri = mat.group(1); uri = mat.group(1);
a = "<"+mat.group(0); a = "<"+mat.group(0);
@@ -714,7 +649,7 @@ public class PushAgent extends Spider {
uri=baseUrl + uri; uri=baseUrl + uri;
if(m.containsKey(uri)){ if(m.containsKey(uri)){
b = m.get(uri); b = m.get(uri);
if(b.contains("线路")||b.contains("一集")||b.contains("上集")||b.contains("下集")||(!b.contains("")&&!b.contains(""))||Misc.isNumeric(b)){ if((!b.contains("")&&!b.contains(""))||Misc.isNumeric(b)){
m.remove(uri); m.remove(uri);
m.put(uri, text); m.put(uri, text);
} }
@@ -729,19 +664,16 @@ public class PushAgent extends Spider {
VodName = b; VodName = b;
} else VodName = m.get(url); } else VodName = m.get(url);
} }
fb=true;
} }
vodItems = new ArrayList<>(); vodItems = new ArrayList<>();
for (String key : m.keySet()) { for (String key : m.keySet()) {
vodItems.add(m.get(key) + "$" + key); vodItems.add(m.get(key) + "$" + key);
} }
if(fb) playList.add(0, TextUtils.join("#", vodItems)); playList.add(TextUtils.join("#", vodItems));
else playList.add(TextUtils.join("#", vodItems));
} }
ArrayList<String> playFrom = new ArrayList<>(); ArrayList<String> playFrom = new ArrayList<>();
for (int i = 0; i < playList.size(); i++) { for (int i = 0; i < playList.size(); i++) {
String k = playList.get(i);
playFrom.add("嗅探列表" + (i + 1)); playFrom.add("嗅探列表" + (i + 1));
} }
@@ -749,63 +681,63 @@ public class PushAgent extends Spider {
String vod_play_url = TextUtils.join("$$$", playList); String vod_play_url = TextUtils.join("$$$", playList);
vodAtom.put("vod_play_from", vod_play_from); vodAtom.put("vod_play_from", vod_play_from);
vodAtom.put("vod_play_url", vod_play_url); vodAtom.put("vod_play_url", vod_play_url);
}else{ }else if(urlder2.matcher(url).find()){//https://dyxs13.com/paly-215645-9-1/
Map<String, String> m = new LinkedHashMap<>();
String s = "";
if(url.endsWith("/")) s = "/";
prefxs= url.replaceAll(baseUrl+"(.*)-\\d+"+s, "$1");
Matcher mat = Pattern.compile("href=\"("+prefxs+"-\\d+"+s+").*?/a>").matcher(content);
while (mat.find()){
uri = mat.group(1);
a = "<"+mat.group(0);
text=a.replaceAll("<[^>]+>",""); //过滤html标签
text = text.replaceAll("&amp;|&nbsp;", "");
if(text.equals(""))text="其他";
uri=baseUrl + uri;
if(m.containsKey(uri)) m.remove(uri);
m.put(uri, text);
}
if(m.containsKey(url)) {
if(VodName.equals("")){
b = a.replaceAll(".*title=\"(.*)\".*","$1");
if (!b.startsWith("<")) {
b = b.replace("播放", "");
VodName = b;
} else VodName = m.get(url);
}
}
vodItems = new ArrayList<>();
for (String key : m.keySet()) {
vodItems.add(m.get(key) + "$" + key);
}
String playList = TextUtils.join("#", vodItems);
vodAtom.put("vod_play_from", "嗅探列表");
vodAtom.put("vod_play_url", playList);
} else{
vodAtom.put("vod_play_from", "嗅探"); vodAtom.put("vod_play_from", "嗅探");
vodAtom.put("vod_play_url", "立即播放嗅探$" + url); vodAtom.put("vod_play_url", "立即播放嗅探$" + url);
} }
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
JSONArray lists = new JSONArray();
vodAtom.put("vod_id", url); vodAtom.put("vod_id", url);
vodAtom.put("vod_name", VodName); vodAtom.put("vod_name", VodName);
vodAtom.put("vod_pic", pic == null ? "http://image.xinjun58.com/sp/pic/bg/zl.jpg" : pic);
vodAtom.put("type_name", "嗅探"); vodAtom.put("type_name", "嗅探");
setVideoDesc(vodAtom, content); vodAtom.put("vod_content", url);
lists.put(vodAtom); lists.put(vodAtom);
result.put("list", lists); result.put("list", lists);
return result.toString(); return result.toString();
} }
} catch (Throwable th) { } catch (Throwable throwable) {
SpiderDebug.log(th);
return "";
} }
return ""; return "";
} }
public static JSONObject setVideoDesc(JSONObject vodAtom, String content) {
try {
if(vodAtom.has("vod_actor"))return vodAtom;
ArrayList<String> aslist = new ArrayList<>();
String director = "",actor = "",desc = "";
String directorRegx = "导演:</span>",actorRegx = "主演:</span>",descRegx = "简介:</span>";
boolean fb = true;
if (!Misc.matcher("actorRegx", content).find()) {
fb=false;
actorRegx = "主演:";
directorRegx = "导演:";
}
aslist = Misc.subContent(content, actorRegx, "</[p|li]>");
if(!aslist.isEmpty()) actor = aslist.get(0);
aslist = Misc.subContent(content, directorRegx, "</[p|li]>");
if(!aslist.isEmpty()) director = aslist.get(0);
aslist = Misc.subContent(content, descRegx, "</[p|li]>");
if(!aslist.isEmpty()) {
desc = aslist.get(0);
desc = Misc.trim(desc);
desc = desc.replaceAll("<a.*>", "");
desc = Misc.delHTMLTag(desc);
}
if (!fb) {
actor = Misc.delHTMLTag(actor);
director = Misc.delHTMLTag(director);
}
vodAtom.put("vod_actor", actor);
vodAtom.put("vod_director", director);
vodAtom.put("vod_content", desc);
} catch (JSONException e) {
SpiderDebug.log(e);
}
return vodAtom;
}
@Override @Override
public String playerContent(String flag, String id, List<String> vipFlags) { public String playerContent(String flag, String id, List<String> vipFlags) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
@@ -815,10 +747,8 @@ public class PushAgent extends Spider {
result.put("parse", 1); result.put("parse", 1);
result.put("jx", "1"); result.put("jx", "1");
result.put("url", id); result.put("url", id);
result.put("playUrl", ""); if(id.contains("bilibili"))result.put("header", Misc.jHeaders(0,id).toString());
if(id.contains("bilibili")){ else result.put("header", Misc.jHeaders(type,id).toString());
result.put("header", Misc.jHeaders(0,id).toString());
} else result.put("header", Misc.jHeaders(type,id).toString());
return result.toString(); return result.toString();
} }
case "player": { case "player": {
@@ -6,7 +6,6 @@ import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.utils.Misc; import com.github.catvod.utils.Misc;
import com.github.catvod.utils.okhttp.OkHttpUtil; import com.github.catvod.utils.okhttp.OkHttpUtil;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.HashMap; import java.util.HashMap;
@@ -21,16 +20,43 @@ public class PushAgentQQ extends Spider {
@Override @Override
public void init(Context context, String extend) { public void init(Context context, String extend) {
super.init(context, extend); super.init(context, extend);
pushAgent = new PushAgent(); String token = null;
pushAgent.init(context, extend);
if (extend != null) { if (extend != null) {
if (!extend.startsWith("http")) { if (!extend.startsWith("http")) {
String[] arr = extend.split(";"); String[] arr = extend.split(";");
token = arr[0];
this.ext = arr[1]; this.ext = arr[1];
}else { }else {
this.ext = extend; this.ext = extend;
} }
} }
pushAgent = new PushAgent();
pushAgent.init(context, token);
}
protected void fetchRule(boolean flag) {
try {
if (flag || rule == null) {
String json = OkHttpUtil.string(ext+"?t="+Time(), null);
rule = new JSONObject(json);
pushAgent.type = rule.optInt("modelType", 1);
}
} catch (Exception e) {
}
}
private String getRuleVal(JSONObject o,String key, String defaultVal) {
String v = o.optString(key);
if (v.isEmpty() || v.equals(""))
return defaultVal;
return v;
}
private String getRuleVal(JSONObject o,String key) {
return getRuleVal(o,key, "");
}
protected static long Time() {
return (System.currentTimeMillis() / 1000) + n;
} }
@Override @Override
@@ -39,7 +65,7 @@ public class PushAgentQQ extends Spider {
fetchRule(true); fetchRule(true);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
JSONArray classes = new JSONArray(); JSONArray classes = new JSONArray();
String[] fenleis = pushAgent.getRuleVal(rule,"fenlei", "").split("#"); String[] fenleis = getRuleVal(rule,"fenlei", "").split("#");
for (String fenlei : fenleis) { for (String fenlei : fenleis) {
String[] info = fenlei.split("\\$"); String[] info = fenlei.split("\\$");
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
@@ -55,19 +81,16 @@ public class PushAgentQQ extends Spider {
} }
return ""; return "";
} }
protected JSONObject fetchRule(boolean flag) {
rule = pushAgent.fetchRule(flag, 0);
return rule;
}
@Override @Override
public String homeVideoContent() { public String homeVideoContent() {
try { try {
JSONObject jo = pushAgent.fetchRule(true,1); fetchRule(true);
JSONArray videos = new JSONArray(); JSONArray videos = new JSONArray();
String[] fenleis = pushAgent.getRuleVal(jo, "fenlei", "").split("#"); String[] fenleis = getRuleVal(rule, "fenlei", "").split("#");
for (String fenlei : fenleis) { for (String fenlei : fenleis) {
String[] info = fenlei.split("\\$"); String[] info = fenlei.split("\\$");
JSONObject data = category(info[1], "1", false, new HashMap<>(),jo); JSONObject data = category(info[1], "1", false, new HashMap<>());
if (data != null) { if (data != null) {
JSONArray vids = data.optJSONArray("list"); JSONArray vids = data.optJSONArray("list");
if (vids != null) { if (vids != null) {
@@ -88,35 +111,35 @@ public class PushAgentQQ extends Spider {
return ""; return "";
} }
private JSONObject category(String tid, String pg, boolean filter, HashMap<String, String> extend,JSONObject jo) { private JSONObject category(String tid, String pg, boolean filter, HashMap<String, String> extend) {
try { try {
if (jo == null) jo = pushAgent.fetchRule(true,1); fetchRule(true);
JSONArray videos = new JSONArray(); JSONArray videos = new JSONArray();
JSONArray array = jo.getJSONArray(tid);
JSONArray array = rule.getJSONArray(tid);
JSONObject jsonObject = null, v = null; JSONObject jsonObject = null, v = null;
String url=null,name=null,pic=null; String url=null,name=null,pic=null;
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
jsonObject = array.getJSONObject(i); jsonObject = array.getJSONObject(i);
url = pushAgent.getRuleVal(jsonObject, "url"); url = getRuleVal(jsonObject, "url");
name = pushAgent.getRuleVal(jsonObject, "name"); name = getRuleVal(jsonObject, "name");
pic = pushAgent.getRuleVal(jsonObject, "pic"); pic = getRuleVal(jsonObject, "pic");
if(pic.equals("")) pic = Misc.getWebName(url, 1);
v = new JSONObject(); v = new JSONObject();
v.put("vod_id", url + "$$$" + pic + "$$$" + name); v.put("vod_id", url + "$$$" + pic + "$$$" + name);
v.put("vod_name", name); v.put("vod_name", name);
v.put("vod_pic", pic); v.put("vod_pic", pic);
v.put("vod_remarks", Misc.getWebName(url,0)); v.put("vod_remarks", Misc.getWebName(url));
videos.put(v); videos.put(v);
} }
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
int limit = 20;int total = videos.length(); int limit = 20;
int page = Integer.parseInt(pg); int page = Integer.parseInt(pg);
result.put("page", page); result.put("page", page);
int pageCount = (int)Math.ceil((double)total/limit); int pageCount = videos.length() == limit ? page + 1 : page;
result.put("pagecount", pageCount); result.put("pagecount", pageCount);
result.put("limit", limit); result.put("limit", limit);
result.put("total", total); result.put("total", Integer.MAX_VALUE);
result.put("list", videos); result.put("list", videos);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
@@ -127,7 +150,7 @@ public class PushAgentQQ extends Spider {
@Override @Override
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) { public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
JSONObject obj = category(tid, pg, filter, extend,null); JSONObject obj = category(tid, pg, filter, extend);
return obj != null ? obj.toString() : ""; return obj != null ? obj.toString() : "";
} }
@@ -142,57 +165,4 @@ public class PushAgentQQ extends Spider {
return pushAgent.playerContent(str, str2, list); return pushAgent.playerContent(str, str2, list);
} }
@Override
public String searchContent(String key, boolean quick) {
if (key.equals("000")) {
PushAgent.type=0;
}if (key.equals("111")) {
PushAgent.type=1;
}
JSONObject result = new JSONObject();
JSONArray videos = new JSONArray();
try {
fetchRule(true);
String url = "",webUrl,detailRex,siteUrl,siteName;
JSONArray siteArray = rule.getJSONArray("sites");
for (int j = 0; j < siteArray.length(); j++) {
JSONObject site = siteArray.getJSONObject(j);
siteUrl = site.optString("site");
siteName = site.optString("name");
detailRex = siteUrl+site.optString("detailRex","/vod/%s.html");
webUrl = siteUrl + "/index.php/ajax/suggest?mid=1&wd="+key;
JSONObject data = new JSONObject(OkHttpUtil.string(webUrl, Misc.Headers(0)));
JSONArray vodArray = data.getJSONArray("list");
for (int i = 0; i < vodArray.length(); i++) {
JSONObject vod = vodArray.getJSONObject(i);
String name = vod.optString("name").trim();
String id = vod.optString("id").trim();
String pic = vod.optString("pic").trim();
pic = Misc.fixUrl(webUrl, pic);
url = detailRex.replace("%s",id);
JSONObject v = new JSONObject();
v.put("vod_id", url + "$$$" + pic + "$$$" + name);
v.put("vod_name", "["+siteName+"]"+name);
v.put("vod_pic", pic);
v.put("vod_remarks", "");
videos.put(v);
}
}
result.put("list", videos);
return result.toString();
} catch (Exception e) {
SpiderDebug.log(e);
if (videos.length() > 0) {
try {
result.put("list", videos);
} catch (JSONException jsonException) {
jsonException.printStackTrace();
}
return result.toString();
}
}
return "";
}
} }
@@ -22,15 +22,13 @@ import java.util.regex.Pattern;
import okhttp3.Call; import okhttp3.Call;
public class XBiubiu extends Spider { public class XBiubiu extends Spider {
private PushAgent pushAgent= null;
@Override @Override
public void init(Context context) { public void init(Context context) {
super.init(context); super.init(context);
} }
public void init(Context context, String extend) { public void init(Context context, String extend) {
pushAgent= new PushAgent();
pushAgent.init(context, "");
super.init(context, extend); super.init(context, extend);
this.ext = extend; this.ext = extend;
} }
@@ -101,11 +99,10 @@ public class XBiubiu extends Spider {
private JSONObject category(String tid, String pg, boolean filter, HashMap<String, String> extend) { private JSONObject category(String tid, String pg, boolean filter, HashMap<String, String> extend) {
try { try {
fetchRule(); fetchRule();
String baseUrl = getRuleVal("url"); String webUrl = getRuleVal("url") + tid + pg + getRuleVal("houzhui");
String webUrl = baseUrl + tid + pg + getRuleVal("houzhui");
String html = fetch(webUrl); String html = fetch(webUrl);
String parseContent = html; String parseContent = html;
boolean shifouercijiequ = getRuleVal("shifouercijiequ","1").equals("1"); boolean shifouercijiequ = getRuleVal("shifouercijiequ").equals("1");
if (shifouercijiequ) { if (shifouercijiequ) {
String jiequqian = getRuleVal("jiequqian"); String jiequqian = getRuleVal("jiequqian");
String jiequhou = getRuleVal("jiequhou"); String jiequhou = getRuleVal("jiequhou");
@@ -133,7 +130,7 @@ public class XBiubiu extends Spider {
} }
} }
JSONObject v = new JSONObject(); JSONObject v = new JSONObject();
v.put("vod_id", baseUrl+link + "$$$" + pic + "$$$" + title);// v.put("vod_id", title + "$$$" + pic + "$$$" + link); v.put("vod_id", title + "$$$" + pic + "$$$" + link);
v.put("vod_name", title); v.put("vod_name", title);
v.put("vod_pic", pic); v.put("vod_pic", pic);
v.put("vod_remarks", mark); v.put("vod_remarks", mark);
@@ -144,9 +141,12 @@ public class XBiubiu extends Spider {
//} //}
} }
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("page", pg); int limit = 20;
result.put("pagecount", Integer.MAX_VALUE); int page = Integer.parseInt(pg);
result.put("limit", 90); result.put("page", page);
int pageCount = videos.length() == limit ? page + 1 : page;
result.put("pagecount", pageCount);
result.put("limit", limit);
result.put("total", Integer.MAX_VALUE); result.put("total", Integer.MAX_VALUE);
result.put("list", videos); result.put("list", videos);
return result; return result;
@@ -166,128 +166,123 @@ public class XBiubiu extends Spider {
public String detailContent(List<String> ids) { public String detailContent(List<String> ids) {
try { try {
fetchRule(); fetchRule();
String[] idInfo = ids.get(0).split("\\$\\$\\$");
String webUrl = getRuleVal("url") + idInfo[2];
String html = fetch(webUrl);
String parseContent = html;
boolean bfshifouercijiequ = getRuleVal("bfshifouercijiequ").equals("1");
if (bfshifouercijiequ) {
String jiequqian = getRuleVal("bfjiequqian");
String jiequhou = getRuleVal("bfjiequhou");
parseContent = subContent(html, jiequqian, jiequhou).get(0);
}
ArrayList<String> playList = new ArrayList<>();
String jiequshuzuqian = getRuleVal("bfjiequshuzuqian"); String jiequshuzuqian = getRuleVal("bfjiequshuzuqian");
boolean bfjiequshuzuqian = jiequshuzuqian.equals(""); String jiequshuzuhou = getRuleVal("bfjiequshuzuhou");
if(!bfjiequshuzuqian){ boolean bfyshifouercijiequ = getRuleVal("bfyshifouercijiequ").equals("1");
String[] idInfo = ids.get(0).split("\\$\\$\\$"); ArrayList<String> jiequContents = subContent(parseContent, jiequshuzuqian, jiequshuzuhou);
String webUrl = idInfo[0]; for (int i = 0; i < jiequContents.size(); i++) {
String html = fetch(webUrl); try {
String parseContent = html; String jiequContent = jiequContents.get(i);
boolean bfshifouercijiequ = getRuleVal("bfshifouercijiequ").equals("1"); String parseJqContent = bfyshifouercijiequ ? subContent(jiequContent, getRuleVal("bfyjiequqian"), getRuleVal("bfyjiequhou")).get(0) : jiequContent;
if (bfshifouercijiequ) { ArrayList<String> lastParseContents = subContent(parseJqContent, getRuleVal("bfyjiequshuzuqian"), getRuleVal("bfyjiequshuzuhou"));
String jiequqian = getRuleVal("bfjiequqian"); List<String> vodItems = new ArrayList<>();
String jiequhou = getRuleVal("bfjiequhou"); for (int j = 0; j < lastParseContents.size(); j++) {
parseContent = subContent(html, jiequqian, jiequhou).get(0); String title = subContent(lastParseContents.get(j), getRuleVal("bfbiaotiqian"), getRuleVal("bfbiaotihou")).get(0);
} String link = subContent(lastParseContents.get(j), getRuleVal("bflianjieqian"), getRuleVal("bflianjiehou")).get(0);
vodItems.add(title + "$" + link);
ArrayList<String> playList = new ArrayList<>();
String jiequshuzuhou = getRuleVal("bfjiequshuzuhou");
boolean bfyshifouercijiequ = getRuleVal("bfyshifouercijiequ").equals("1");
ArrayList<String> jiequContents = subContent(parseContent, jiequshuzuqian, jiequshuzuhou);
for (int i = 0; i < jiequContents.size(); i++) {
try {
String jiequContent = jiequContents.get(i);
String parseJqContent = bfyshifouercijiequ ? subContent(jiequContent, getRuleVal("bfyjiequqian"), getRuleVal("bfyjiequhou")).get(0) : jiequContent;
ArrayList<String> lastParseContents = subContent(parseJqContent, getRuleVal("bfyjiequshuzuqian"), getRuleVal("bfyjiequshuzuhou"));
List<String> vodItems = new ArrayList<>();
for (int j = 0; j < lastParseContents.size(); j++) {
String title = subContent(lastParseContents.get(j), getRuleVal("bfbiaotiqian"), getRuleVal("bfbiaotihou")).get(0);
String link = subContent(lastParseContents.get(j), getRuleVal("bflianjieqian"), getRuleVal("bflianjiehou")).get(0);
vodItems.add(title + "$" + link);
}
playList.add(0, android.text.TextUtils.join("#", vodItems));
} catch (Throwable th) {
th.printStackTrace();
break;
} }
playList.add(0, TextUtils.join("#", vodItems));
} catch (Throwable th) {
th.printStackTrace();
break;
} }
}
String cover = idInfo[1], title = idInfo[2], area = ""; String cover = idInfo[1], title = idInfo[0], area = "";
String director = ""; String director = "";
String actor = ""; String actor = "";
String desc = ""; String desc = "";
String remark = ""; String remark = "";
String year = ""; String year = "";
String category = ""; String category = "";
if (!getRuleVal("leixinqian").isEmpty() && !getRuleVal("leixinhou").isEmpty()) { if (!getRuleVal("leixinqian").isEmpty() && !getRuleVal("leixinhou").isEmpty()) {
try { try {
category = subContent(html, getRuleVal("leixinqian"), getRuleVal("leixinhou")).get(0).replaceAll("\\s+", "").replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", ""); category = subContent(html, getRuleVal("leixinqian"), getRuleVal("leixinhou")).get(0).replaceAll("\\s+", "").replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
} catch (Exception e) { } catch (Exception e) {
SpiderDebug.log(e); SpiderDebug.log(e);
}
} }
if (!getRuleVal("niandaiqian").isEmpty() && !getRuleVal("niandaihou").isEmpty()) { }
try { if (!getRuleVal("niandaiqian").isEmpty() && !getRuleVal("niandaihou").isEmpty()) {
year = subContent(html, getRuleVal("niandaiqian"), getRuleVal("niandaihou")).get(0).replaceAll("\\s+", "").replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", ""); try {
} catch (Exception e) { year = subContent(html, getRuleVal("niandaiqian"), getRuleVal("niandaihou")).get(0).replaceAll("\\s+", "").replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
SpiderDebug.log(e); } catch (Exception e) {
} SpiderDebug.log(e);
} }
if (!getRuleVal("zhuangtaiqian").isEmpty() && !getRuleVal("zhuangtaihou").isEmpty()) { }
try { if (!getRuleVal("zhuangtaiqian").isEmpty() && !getRuleVal("zhuangtaihou").isEmpty()) {
remark = subContent(html, getRuleVal("zhuangtaiqian"), getRuleVal("zhuangtaihou")).get(0); try {
} catch (Exception e) { remark = subContent(html, getRuleVal("zhuangtaiqian"), getRuleVal("zhuangtaihou")).get(0);
SpiderDebug.log(e); } catch (Exception e) {
} SpiderDebug.log(e);
} }
if (!getRuleVal("zhuyanqian").isEmpty() && !getRuleVal("zhuyanhou").isEmpty()) { }
try { if (!getRuleVal("zhuyanqian").isEmpty() && !getRuleVal("zhuyanhou").isEmpty()) {
actor = subContent(html, getRuleVal("zhuyanqian"), getRuleVal("zhuyanhou")).get(0).replaceAll("\\s+", ""); try {
} catch (Exception e) { actor = subContent(html, getRuleVal("zhuyanqian"), getRuleVal("zhuyanhou")).get(0).replaceAll("\\s+", "");
SpiderDebug.log(e); } catch (Exception e) {
} SpiderDebug.log(e);
} }
if (!getRuleVal("daoyanqian").isEmpty() && !getRuleVal("daoyanhou").isEmpty()) { }
try { if (!getRuleVal("daoyanqian").isEmpty() && !getRuleVal("daoyanhou").isEmpty()) {
director = subContent(html, getRuleVal("daoyanqian"), getRuleVal("daoyanhou")).get(0).replaceAll("\\s+", ""); try {
} catch (Exception e) { director = subContent(html, getRuleVal("daoyanqian"), getRuleVal("daoyanhou")).get(0).replaceAll("\\s+", "");
SpiderDebug.log(e); } catch (Exception e) {
} SpiderDebug.log(e);
} }
if (!getRuleVal("juqingqian").isEmpty() && !getRuleVal("juqinghou").isEmpty()) { }
try { if (!getRuleVal("juqingqian").isEmpty() && !getRuleVal("juqinghou").isEmpty()) {
desc = subContent(html, getRuleVal("juqingqian"), getRuleVal("juqinghou")).get(0); try {
if(desc!=null){ desc = subContent(html, getRuleVal("juqingqian"), getRuleVal("juqinghou")).get(0);
desc = desc.replace("\t", ""); if(desc!=null){
desc = desc.replaceAll("\\.*>(.*)", "$1"); desc = desc.replace("\t", "");
} desc = desc.replaceAll("\\.*>(.*)", "$1");
} catch (Exception e) {
SpiderDebug.log(e);
} }
} catch (Exception e) {
SpiderDebug.log(e);
} }
}
JSONObject vod = new JSONObject();
vod.put("vod_id", ids.get(0));
vod.put("vod_name", title);
vod.put("vod_pic", cover);
vod.put("type_name", category);
vod.put("vod_year", year);
vod.put("vod_area", area);
vod.put("vod_remarks", remark);
vod.put("vod_actor", actor);
vod.put("vod_director", director);
vod.put("vod_content", desc);
JSONObject vod = new JSONObject(); ArrayList<String> playFrom = new ArrayList<>();
vod.put("vod_id", ids.get(0));
vod.put("vod_name", title);
vod.put("vod_pic", cover);
vod.put("type_name", category);
vod.put("vod_year", year);
vod.put("vod_area", area);
vod.put("vod_remarks", remark);
vod.put("vod_actor", actor);
vod.put("vod_director", director);
vod.put("vod_content", desc);
ArrayList<String> playFrom = new ArrayList<>(); for (int i = 0; i < playList.size(); i++) {
playFrom.add("播放列表" + (i + 1));
}
for (int i = 0; i < playList.size(); i++) { String vod_play_from = TextUtils.join("$$$", playFrom);
playFrom.add("播放列表" + (i + 1)); String vod_play_url = TextUtils.join("$$$", playList);
} vod.put("vod_play_from", vod_play_from);
vod.put("vod_play_url", vod_play_url);
String vod_play_from = android.text.TextUtils.join("$$$", playFrom); JSONObject result = new JSONObject();
String vod_play_url = TextUtils.join("$$$", playList); JSONArray list = new JSONArray();
vod.put("vod_play_from", vod_play_from); list.put(vod);
vod.put("vod_play_url", vod_play_url); result.put("list", list);
return result.toString();
JSONObject result = new JSONObject();
JSONArray list = new JSONArray();
list.put(vod);
result.put("list", list);
return result.toString();
} else return pushAgent.detailContent(ids);
} catch (Exception e) { } catch (Exception e) {
SpiderDebug.log(e); SpiderDebug.log(e);
} }
@@ -4,13 +4,12 @@ import android.os.Build;
import com.github.catvod.crawler.SpiderDebug; import com.github.catvod.crawler.SpiderDebug;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class Misc { public class Misc {
public static final String UaWinChrome = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"; public static final String UaWinChrome = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36";
public static final String DeAgent = "Dalvik/2.1.0 (Linux; U; Android " + Build.VERSION.RELEASE + "; " + Build.MODEL + " Build/" + Build.ID + ")"; public static final String DeAgent = "Dalvik/2.1.0 (Linux; U; Android " + Build.VERSION.RELEASE + "; " + Build.MODEL + " Build/" + Build.ID + ")";
@@ -52,7 +51,7 @@ public class Misc {
if(type==0){ if(type==0){
headers.put("User-Agent", UaWinChrome); headers.put("User-Agent", UaWinChrome);
}else headers.put("User-Agent", MoAgent); }else headers.put("User-Agent", MoAgent);
headers.put("Accept", " */*");
headers.put("Connection", " Keep-Alive"); headers.put("Connection", " Keep-Alive");
if (url != null) { if (url != null) {
headers.put("Referer", " " +url); headers.put("Referer", " " +url);
@@ -78,35 +77,25 @@ public class Misc {
return Headers(type,null); return Headers(type,null);
} }
public static String getWebName(String url,int type){ public static String getWebName(String url){
if (url.contains("mgtv.com")) { if (url.contains("mgtv.com")) {
if(type==0) return "芒果TV"; return "芒果TV";
if(type==1) return "http://image.xinjun58.com/sp/pic/bg/mgtv.jpg";
} }
if (url.contains("qq.com")) { if (url.contains("qq.com")) {
if(type==1) return "http://image.xinjun58.com/sp/pic/bg/qq.jpg";
return "腾讯视频"; return "腾讯视频";
} }
if (url.contains("iqiyi.com")) { if (url.contains("iqiyi.com")) {
if(type==1) return "http://image.xinjun58.com/sp/pic/bg/iqiyi.jpg";
return "爱奇艺"; return "爱奇艺";
} }
if (url.contains("youku.com")) {
if(type==1) return "http://image.xinjun58.com/sp/pic/bg/youku.jpg";
return "优酷";
}
if (url.contains("bilibili.com")) { if (url.contains("bilibili.com")) {
if(type==1) return "http://image.xinjun58.com/sp/pic/bg/bili.jpg";
return "哗哩哔哩"; return "哗哩哔哩";
} }
if (url.startsWith("magnet")) { if (url.startsWith("magnet")) {
return "磁力"; return "磁力";
} }
if (url.contains("aliyundrive")) { if (url.contains("aliyundrive")) {
if(type==1) return "http://image.xinjun58.com/sp/pic/bg/ali.jpg";
return "阿里云"; return "阿里云";
} }
if(type==1)return "http://image.xinjun58.com/sp/pic/bg/zl.jpg";
String host = Uri.parse(url).getHost(); String host = Uri.parse(url).getHost();
return host; return host;
} }
@@ -224,37 +213,4 @@ public class Misc {
} }
return ""; return "";
} }
public static Matcher matcher(String regx, String content) {
Pattern pattern = Pattern.compile(regx);
return pattern.matcher(content);
}
public static String trim(String str) {
return str == null ? str : str.replaceAll("^[\\s |\\s ]*|[\\s |\\s ]*$", "");
}
public static String delHTMLTag(String htmlStr){
String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式
Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE);
Matcher m_html=p_html.matcher(htmlStr);
htmlStr=m_html.replaceAll(""); //过滤html标签
htmlStr = htmlStr.replaceAll("&amp;|&nbsp;", " ");
return htmlStr.trim(); //返回文本字符串
}
public static ArrayList<String> subContent(String content, String startFlag, String endFlag) {
ArrayList<String> result = new ArrayList<>();
if (content != null && content.length() > 1) {
try {
Pattern pattern = Pattern.compile(startFlag + "(.*?)" + endFlag);
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
result.add(matcher.group(1));
}
} catch (Throwable th) {
th.printStackTrace();
}
}
return result;
}
} }
@@ -16,7 +16,7 @@ public class OkHttpUtil {
public static final String METHOD_GET = "GET"; public static final String METHOD_GET = "GET";
public static final String METHOD_POST = "POST"; public static final String METHOD_POST = "POST";
private static final int DEFAULT_TIMEOUT = 25; public static final int DEFAULT_TIMEOUT = 20;
private static final Object lockO = new Object(); private static final Object lockO = new Object();