Add files via upload
This commit is contained in:
@@ -0,0 +1,460 @@
|
||||
package com.github.catvod.spider;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.utils.okhttp.OKCallBack;
|
||||
import com.github.catvod.utils.okhttp.OkHttpUtil;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Response;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Calendar;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
|
||||
|
||||
|
||||
public class Anime1 extends Spider {
|
||||
|
||||
private String cookies = "";
|
||||
private String authority = "";
|
||||
private JSONArray srcArray = new JSONArray();
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
super.init(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) {
|
||||
try {
|
||||
long a = System.currentTimeMillis();
|
||||
String srcurl = "https://d1zquzjgwo9yb.cloudfront.net/?_=" + a;
|
||||
String srcOrignstr = OkHttpUtil.string(srcurl, getHeaders3(srcurl));
|
||||
JSONArray srcOrign = new JSONArray(srcOrignstr);
|
||||
int srclen = srcOrign.length();
|
||||
for (int i = 0; i < srclen; i++){
|
||||
JSONObject subobj= new JSONObject();
|
||||
subobj.put("link", srcOrign.getJSONArray(i).get(0).toString());
|
||||
subobj.put("name", srcOrign.getJSONArray(i).get(1).toString());
|
||||
subobj.put("hit" , srcOrign.getJSONArray(i).get(2).toString());
|
||||
subobj.put("year", srcOrign.getJSONArray(i).get(3).toString());
|
||||
subobj.put("season", srcOrign.getJSONArray(i).get(4).toString());
|
||||
subobj.put("team", srcOrign.getJSONArray(i).get(5).toString());
|
||||
srcArray.put(subobj);
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
JSONArray classes = new JSONArray();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int doy = cal.get(Calendar.YEAR) + 1;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
JSONObject cateobj = new JSONObject();
|
||||
String istr = Integer.toString(i);
|
||||
if (i == 0) {
|
||||
cateobj.put("type_name", "最近更新");
|
||||
cateobj.put("type_id", istr);
|
||||
} else if (i < 7) {
|
||||
doy = doy - 1;
|
||||
String year = Integer.toString(doy);
|
||||
cateobj.put("type_name", year);
|
||||
cateobj.put("type_id", istr);
|
||||
} else {
|
||||
cateobj.put("type_name", "更早");
|
||||
cateobj.put("type_id", istr);
|
||||
}
|
||||
classes.put(cateobj);
|
||||
}
|
||||
result.put("class", classes);
|
||||
JSONArray videos = new JSONArray();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
JSONObject v = new JSONObject();
|
||||
String id = srcArray.getJSONObject(i).getString("link");
|
||||
String name = srcArray.getJSONObject(i).getString("name");
|
||||
String mark = srcArray.getJSONObject(i).getString("hit");
|
||||
v.put("vod_id", id);
|
||||
v.put("vod_name", name);
|
||||
v.put("vod_pic","https://sta.anicdn.com/playerImg/8.jpg");
|
||||
v.put("vod_remarks", mark);
|
||||
videos.put(v);
|
||||
}
|
||||
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 {
|
||||
JSONArray srccate = new JSONArray();
|
||||
int cateId = Integer.parseInt( tid );
|
||||
int srclen = srcArray.length();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int doy = cal.get(Calendar.YEAR) + 1;
|
||||
if( cateId==0 ){
|
||||
for (int i = 0; i < 100; i++) {
|
||||
JSONObject subobj = srcArray.getJSONObject(i);
|
||||
srccate.put(subobj);
|
||||
}
|
||||
} else if( cateId > 0 && cateId < 7 ){
|
||||
int yearchk = doy - cateId;
|
||||
for (int i = 0; i < srclen; i++) {
|
||||
JSONObject subobj = srcArray.getJSONObject(i);
|
||||
String yystr = subobj.getString("year");
|
||||
if(yystr.contains("/")){
|
||||
yystr=yystr.substring(5);
|
||||
}
|
||||
int yy = Integer.parseInt( yystr );
|
||||
if( yy==yearchk ){
|
||||
srccate.put(subobj);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int yy = doy - 6 ;
|
||||
for (int i = 0; i < srclen; i++) {
|
||||
JSONObject subobj = srcArray.getJSONObject(i);
|
||||
String yearchk = subobj.getString("year");
|
||||
if(yearchk.contains("/")){
|
||||
yearchk=yearchk.substring(5);
|
||||
}
|
||||
int yearint = Integer.parseInt( yearchk );
|
||||
if(yearint < yy){
|
||||
srccate.put(subobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray videos = new JSONArray();
|
||||
for (int i = 0; i < srccate.length() ; i++) {
|
||||
JSONObject v = new JSONObject();
|
||||
String id = srccate.getJSONObject(i).getString("link");
|
||||
String name = srccate.getJSONObject(i).getString("name");
|
||||
String mark = srccate.getJSONObject(i).getString("hit");
|
||||
v.put("vod_id", id);
|
||||
v.put("vod_name", name);
|
||||
v.put("vod_pic", "https://sta.anicdn.com/playerImg/8.jpg");
|
||||
v.put("vod_remarks", mark);
|
||||
videos.put(v);
|
||||
}
|
||||
pg ="1";
|
||||
JSONObject result = new JSONObject();
|
||||
int limit = 20;
|
||||
int page = Integer.parseInt(pg);
|
||||
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("list", videos);
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) {
|
||||
try {
|
||||
String id = ids.get(0);
|
||||
JSONObject dtinfo = new JSONObject();
|
||||
for (int i = 0 ; i < srcArray.length() ; i++) {
|
||||
JSONObject dtobj = srcArray.getJSONObject(i);
|
||||
String objid = dtobj.getString("link");
|
||||
if( objid.equals(id) ){
|
||||
dtinfo = dtobj ;
|
||||
}
|
||||
}
|
||||
String title = dtinfo.getString("name");
|
||||
String mark = dtinfo.getString("hit");
|
||||
String year = dtinfo.getString("year");
|
||||
String season = dtinfo.getString("season");
|
||||
String team = dtinfo.getString("team");
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject vodList = new JSONObject();
|
||||
vodList.put("vod_id", ids.get(0));
|
||||
vodList.put("vod_name", title);
|
||||
vodList.put("vod_pic", "https://sta.anicdn.com/playerImg/8.jpg");
|
||||
vodList.put("vod_year", year);
|
||||
vodList.put("type_name", season);
|
||||
vodList.put("vod_area","日本" );
|
||||
vodList.put("vod_actor", team);
|
||||
vodList.put("vod_content", mark);
|
||||
|
||||
/**
|
||||
* 播放源配置
|
||||
*/
|
||||
String url = "https://anime1.me/?cat=" + id;
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders2(url)));
|
||||
String nextPage = "";
|
||||
Map<String, String> vod_play_Order = new TreeMap<>();
|
||||
do {
|
||||
Element nextPageEle = doc.selectFirst("div.nav-previous a");
|
||||
if( nextPageEle!=null ) {
|
||||
nextPage = nextPageEle.attr("href");
|
||||
}else{
|
||||
nextPage ="";
|
||||
}
|
||||
Elements sources = doc.select("article");
|
||||
for (int i = 0; i < sources.size(); i++) {
|
||||
Element source = sources.get(i);
|
||||
Element sno =source.selectFirst("h2 > a");
|
||||
String sourceNameori ="";
|
||||
if( sno!=null ) {
|
||||
sourceNameori = sno.text().trim();
|
||||
}else {
|
||||
Element sno2 =source.selectFirst("h2");
|
||||
if (sno2 != null) {
|
||||
sourceNameori = sno2.text().trim();
|
||||
} else {
|
||||
sourceNameori = "[No Title]";
|
||||
}
|
||||
}
|
||||
int st = sourceNameori.indexOf("[") + 1;
|
||||
int ed = sourceNameori.indexOf("]");
|
||||
String sourceName = sourceNameori.substring(st, ed);
|
||||
Elements playListA = source.select("div.vjscontainer video");
|
||||
for (int j = 0; j < playListA.size(); j++) {
|
||||
Element vod = playListA.get(j);
|
||||
String playURL = vod.attr("data-apireq");
|
||||
if (playURL.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (playListA.size() > 1) {
|
||||
if (j < 9) {
|
||||
int jj = j + 1;
|
||||
String nn = sourceName + "0" + Integer.toString(jj);
|
||||
vod_play_Order.put(nn, playURL);
|
||||
} else {
|
||||
int jj = j + 1;
|
||||
String nn = sourceName + Integer.toString(jj);
|
||||
vod_play_Order.put(nn, playURL);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
String regex=".*[a-zA-Z\\u4e00-\\u9fa5]+.*";
|
||||
Matcher m=Pattern.compile(regex).matcher(sourceName);
|
||||
if ( m.matches() == true ){
|
||||
vod_play_Order.put(sourceName, playURL);
|
||||
} else {
|
||||
float count = Float.parseFloat(sourceName);
|
||||
if(count < 100.0 ){
|
||||
String nnn = "0" + sourceName;
|
||||
vod_play_Order.put(nnn, playURL);
|
||||
}else {
|
||||
vod_play_Order.put(sourceName, playURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(nextPage != ""){
|
||||
doc = Jsoup.parse(OkHttpUtil.string(nextPage, getHeaders2(nextPage)));
|
||||
}
|
||||
}while(nextPage != "");
|
||||
String playList = "";
|
||||
List<String> vodItems = new ArrayList<>();
|
||||
Set<Map.Entry<String,String>> entrySet = vod_play_Order.entrySet();
|
||||
for(Map.Entry<String,String> entry : entrySet){
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
String pl = key + "$" + value;
|
||||
vodItems.add(pl);
|
||||
}
|
||||
if (vodItems.size() > 0)
|
||||
playList = TextUtils.join("#", vodItems);
|
||||
|
||||
if (playList.length() == 0)
|
||||
playList = "nothing here";
|
||||
Map<String, String> vod_play = new TreeMap<>();
|
||||
vod_play.put("Anime1", playList);
|
||||
if (vod_play.size() > 0) {
|
||||
String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
|
||||
String vod_play_url = TextUtils.join("$$$", vod_play.values());
|
||||
vodList.put("vod_play_from", vod_play_from);
|
||||
vodList.put("vod_play_url", vod_play_url);
|
||||
}
|
||||
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 {
|
||||
cookies = "";
|
||||
authority = "";
|
||||
String vlink = id ;
|
||||
String url = "https://v.anime1.me/api";
|
||||
JSONObject result = new JSONObject();
|
||||
String apireq = vlink;
|
||||
String jsonreq = URLDecoder.decode(apireq,"UTF-8");
|
||||
HashMap<String, String> reqpayload = new HashMap<>();
|
||||
reqpayload.put("d", jsonreq);
|
||||
OkHttpUtil.post(OkHttpUtil.defaultClient(), url, reqpayload, getHeaders2(url), new OKCallBack.OKCallBackString() {
|
||||
@Override
|
||||
public String onParseResponse(Call call, Response response) {
|
||||
try {
|
||||
Map<String, List<String>> respHeader = new HashMap<>();
|
||||
respHeader.clear();
|
||||
respHeader.putAll(response.headers().toMultimap());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
cookies = cookies + respHeader.get("set-cookie").get(i).split(";")[0];
|
||||
if ( i < 2 ) {cookies = cookies + ";";}
|
||||
}
|
||||
return response.body().string();
|
||||
} catch (IOException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call call, Exception e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(String respbody) {
|
||||
try {
|
||||
JSONObject obj = new JSONObject(respbody);
|
||||
JSONArray objarray = obj.getJSONArray("s");
|
||||
JSONObject obj2 = objarray.getJSONObject(0);
|
||||
String videolink = obj2.getString("src");
|
||||
authority = videolink.split("/")[2];
|
||||
videolink = "https:" + videolink;
|
||||
result.put("url", videolink);
|
||||
} catch (JSONException unused) {
|
||||
}
|
||||
}
|
||||
});
|
||||
result.put("header", new JSONObject(getHeaders1(url)).toString());
|
||||
result.put("parse", 0);
|
||||
result.put("playUrl", "");
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private HashMap<String, String> getHeaders3(String url) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("Authority", "d1zquzjgwo9yb.cloudfront.net");
|
||||
headers.put("Accept","application/json, text/javascript, */*; q=0.01");
|
||||
headers.put("Accept-Encoding","gzip, deflate, br");
|
||||
headers.put("Accept-Language","zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6");
|
||||
headers.put("Origin","https://anime1.me");
|
||||
headers.put("Referer","https://anime1.me/");
|
||||
headers.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.134 YaBrowser/22.7.1.755 (beta) Yowser/2.5 Safari/537.36");
|
||||
headers.put("Sec-Fetch-Dest","empty");
|
||||
headers.put("Sec-Fetch-Mode","cors");
|
||||
headers.put("Sec-Fetch-Site","cross-site");
|
||||
headers.put("sec-ch-ua-mobile","?0");
|
||||
headers.put("sec-ch-ua-platform","\"Windows\"");
|
||||
headers.put("sec-ch-ua"," \" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\" ");
|
||||
return headers;
|
||||
}
|
||||
|
||||
private HashMap<String, String> getHeaders2(String url) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("Authority", "v.anime1.me");
|
||||
headers.put("Accept","*/*");
|
||||
headers.put("Accept-Language","en,zh-TW;q=0.9,zh;q=0.8");
|
||||
headers.put("Origin","https://anime1.me");
|
||||
headers.put("Referer","https://anime1.me/");
|
||||
headers.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.134 YaBrowser/22.7.1.755 (beta) Yowser/2.5 Safari/537.36");
|
||||
headers.put("Sec-Fetch-Dest","empty");
|
||||
headers.put("Sec-Fetch-Mode","cors");
|
||||
headers.put("Sec-Fetch-Site","same-site");
|
||||
headers.put("sec-ch-ua-mobile","?0");
|
||||
headers.put("sec-ch-ua-platform","\"Windows\"");
|
||||
headers.put("sec-ch-ua"," \" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\" ");
|
||||
return headers;
|
||||
}
|
||||
|
||||
private HashMap<String, String> getHeaders1(String url) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("Accept","*/*");
|
||||
headers.put("Accept-encoding", "identity;q=1, *;q=0");
|
||||
headers.put("Accept-language", "en,zh-TW;q=0.9,zh;q=0.8");
|
||||
headers.put("Referer", "https://anime1.me");
|
||||
headers.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.134 YaBrowser/22.7.1.755 (beta) Yowser/2.5 Safari/537.36");
|
||||
headers.put("Sec-Fetch-Dest","video");
|
||||
headers.put("Sec-Fetch-Mode","no-cors");
|
||||
headers.put("Sec-Fetch-Site","same-site");
|
||||
headers.put("sec-ch-ua-mobile","?0");
|
||||
headers.put("sec-ch-ua-platform","\"Windows\"");
|
||||
headers.put("sec-ch-ua"," \" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\" ");
|
||||
headers.put("Authority", authority);
|
||||
headers.put("cookie", cookies);
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*
|
||||
* @param key
|
||||
* @param quick 是否播放页的快捷搜索
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) {
|
||||
try {
|
||||
JSONArray searchResult = new JSONArray();
|
||||
for (int i = 0; i < srcArray.length() ; i++) {
|
||||
JSONObject srobj = srcArray.getJSONObject(i);
|
||||
String kw = srobj.getString("name");
|
||||
if(kw.contains(key)) {
|
||||
searchResult.put(srobj);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
JSONArray videos = new JSONArray();
|
||||
if (searchResult.length() > 0) {
|
||||
int ch = searchResult.length() < 10 ? searchResult.length() : 10 ;
|
||||
for (int i = 0; i < ch ; i++) {
|
||||
String id = searchResult.getJSONObject(i).getString("link");
|
||||
String name = searchResult.getJSONObject(i).getString("name");
|
||||
String mark = searchResult.getJSONObject(i).getString("hit");
|
||||
JSONObject v = new JSONObject();
|
||||
v.put("vod_id", id);
|
||||
v.put("vod_name", name);
|
||||
v.put("vod_pic", "https://sta.anicdn.com/playerImg/8.jpg");
|
||||
v.put("vod_remarks", mark);
|
||||
videos.put(v);
|
||||
}
|
||||
}
|
||||
result.put("list", videos);
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -429,7 +429,8 @@ public class Cokemv extends Spider {
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) {
|
||||
try {
|
||||
String url = "https://shitu.paodekuaiweixinqun.com/search?q=site%3Acokemv.me%2Fvoddetail+" + URLEncoder.encode(key);
|
||||
//Google搜索镜像
|
||||
String url = "https://google.1qi777.com/search?q=site%3Acokemv.me%2Fvoddetail+" + URLEncoder.encode(key);
|
||||
Document docs = Jsoup.parse(OkHttpUtil.string(url, sHeaders()));
|
||||
JSONObject result = new JSONObject();
|
||||
JSONArray videos = new JSONArray();
|
||||
|
||||
@@ -0,0 +1,581 @@
|
||||
package com.github.catvod.spider;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.utils.AES;
|
||||
import com.github.catvod.utils.CBC;
|
||||
import com.github.catvod.utils.gZip;
|
||||
import com.github.catvod.utils.okhttp.OKCallBack;
|
||||
import com.github.catvod.utils.okhttp.OkHttpUtil;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.StringReader;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
/**
|
||||
* Demo for self study
|
||||
* <p>
|
||||
* Source from Author: CatVod
|
||||
*/
|
||||
|
||||
public class Ddrk extends Spider {
|
||||
|
||||
private static final String siteUrl = "https://ddrk.me";
|
||||
private static final String siteHost = "ddrk.me";
|
||||
|
||||
protected JSONObject filterConfig;
|
||||
|
||||
protected Pattern regexCategory = Pattern.compile("/category/(\\S+)/");
|
||||
protected Pattern regexVid = Pattern.compile("https://ddrk.me/(\\S+)/");
|
||||
|
||||
protected Pattern regexPage = Pattern.compile("\\S+/page/(\\S+)\\S+");
|
||||
protected Pattern m = Pattern.compile("\\S+(http\\S+g)");
|
||||
protected Pattern mark = Pattern.compile("\\S+(.*)");
|
||||
|
||||
// protected Pattern t = Pattern.compile("(\\S+)");
|
||||
|
||||
|
||||
/**
|
||||
* 爬虫headers
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
protected HashMap<String, String> getHeaders(String url) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.62 Safari/537.36");
|
||||
headers.put("Referer", "https://ddrk.me/");
|
||||
return headers;
|
||||
}
|
||||
|
||||
protected static HashMap<String, String> Headers() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
|
||||
headers.put("Referer", "https://ddrk.me/");
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类数据 + 首页最近更新视频列表数据
|
||||
*
|
||||
* @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String homeContent(boolean filter) {
|
||||
try {
|
||||
String url = siteUrl + '/';
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
|
||||
Elements elements = doc.select("li.menu-item a");
|
||||
JSONArray classes = new JSONArray();
|
||||
ArrayList<String> allClass = new ArrayList<>();
|
||||
for (Element ele : elements) {
|
||||
String name = ele.attr("title");
|
||||
boolean show = !filter || (name.equals("热映中")
|
||||
|| name.equals("欧美剧")
|
||||
|| name.equals("日剧")
|
||||
|| name.equals("韩剧")
|
||||
|| name.equals("华语剧")
|
||||
|| name.equals("其他地区")
|
||||
|| name.equals("全部")
|
||||
|| name.equals("欧美电影")
|
||||
|| name.equals("日韩电影")
|
||||
|| name.equals("华语电影")
|
||||
|| name.equals("新番")
|
||||
|| name.equals("动画")
|
||||
|| name.equals("纪录片")
|
||||
|| name.equals("综艺"));
|
||||
if (allClass.contains(name))
|
||||
show = false;
|
||||
if (show) {
|
||||
allClass.add(name);
|
||||
Matcher mather = regexCategory.matcher(ele.attr("href"));
|
||||
if (!mather.find())
|
||||
continue;
|
||||
// 把分类的id和名称取出来加到列表里
|
||||
String id = mather.group(1).trim();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type_id", id);
|
||||
jsonObject.put("type_name", name);
|
||||
classes.put(jsonObject);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
if (filter) {
|
||||
result.put("filters", filterConfig);
|
||||
}
|
||||
result.put("class", classes);
|
||||
try {
|
||||
// 取首页推荐视频列表
|
||||
Elements list = doc.select("div.post-box-container");
|
||||
JSONArray videos = new JSONArray();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Element vod = list.get(i);
|
||||
String a = vod.selectFirst(".post-box-title a").text();
|
||||
if (a.contains("(")) {
|
||||
String[] item = a.split("\\(");
|
||||
String title = item[0];
|
||||
String remark = item[1].replace(")", "");
|
||||
String cover = doReplaceRegex(m, vod.selectFirst(".post-box-image").attr("style"));
|
||||
Matcher matcher = regexVid.matcher(vod.selectFirst(".post-box-title a").attr("href"));
|
||||
if (!matcher.find())
|
||||
continue;
|
||||
String id = matcher.group(1);
|
||||
JSONObject v = new JSONObject();
|
||||
v.put("vod_id", id);
|
||||
v.put("vod_name", title);
|
||||
v.put("vod_pic", cover);
|
||||
v.put("vod_remarks", remark);
|
||||
videos.put(v);
|
||||
} else {
|
||||
String title = a;
|
||||
String cover = doReplaceRegex(m, vod.selectFirst(".post-box-image").attr("style"));
|
||||
String remark = doReplaceRegex(mark, vod.selectFirst(".post-box-title a").text());
|
||||
Matcher matcher = regexVid.matcher(vod.selectFirst(".post-box-title a").attr("href"));
|
||||
if (!matcher.find())
|
||||
continue;
|
||||
String id = matcher.group(1);
|
||||
JSONObject v = new JSONObject();
|
||||
v.put("vod_id", id);
|
||||
v.put("vod_name", title);
|
||||
v.put("vod_pic", cover);
|
||||
v.put("vod_remarks", remark);
|
||||
videos.put(v);
|
||||
}
|
||||
}
|
||||
|
||||
result.put("list", videos);
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分类信息数据
|
||||
*
|
||||
* @param tid 分类id
|
||||
* @param pg 页数
|
||||
* @param filter 同homeContent方法中的filter
|
||||
* @param extend 筛选参数{k:v, k1:v1}
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
String url = "";
|
||||
try {
|
||||
if (extend != null && extend.size() > 0) {
|
||||
for (Iterator<String> it = extend.keySet().iterator(); it.hasNext(); ) {
|
||||
String key = it.next();
|
||||
String value = extend.get(key);
|
||||
if (value != null && value.length() != 0 && value != " ") {
|
||||
url = siteUrl + "/category/" + tid + "/" + value;
|
||||
} else {
|
||||
url = siteUrl + "/category/" + tid;
|
||||
}
|
||||
;
|
||||
}
|
||||
} else {
|
||||
url = siteUrl + "/category/" + tid;
|
||||
}
|
||||
;
|
||||
if (pg.equals("1")) {
|
||||
url = url + "/";
|
||||
} else {
|
||||
url = url + "/page/" + pg + "/";
|
||||
}
|
||||
//System.out.println(url);
|
||||
String html = OkHttpUtil.string(url, getHeaders(url));
|
||||
Document doc = Jsoup.parse(html);
|
||||
JSONObject result = new JSONObject();
|
||||
int pageCount = 0;
|
||||
int page = -1;
|
||||
|
||||
// 取页码相关信息
|
||||
Elements pageInfo = doc.select("div.nav-links");
|
||||
if (pageInfo.size() == 0) {
|
||||
page = Integer.parseInt(pg);
|
||||
pageCount = page;
|
||||
} else {
|
||||
for (int i = 0; i < pageInfo.size(); i++) {
|
||||
Element li = pageInfo.get(i);
|
||||
Element a = li.selectFirst("a");
|
||||
if (a == null)
|
||||
continue;
|
||||
String wy = doc.select("div.nav-links a").last().attr("href");
|
||||
String span = doc.select("span.current").text().trim();
|
||||
if (page == -1) {
|
||||
page = Integer.parseInt(span);
|
||||
} else {
|
||||
|
||||
page = 0;
|
||||
}
|
||||
Matcher matcher = regexPage.matcher(wy);
|
||||
if (matcher.find()) {
|
||||
//System.out.println("尾页" + matcher.group(1));
|
||||
pageCount = Integer.parseInt(matcher.group(1));
|
||||
} else {
|
||||
pageCount = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
JSONArray videos = new JSONArray();
|
||||
if (!html.contains("没有找到您想要的结果哦")) {
|
||||
// 取当前分类页的视频列表
|
||||
Elements list = doc.select("div.post-box-container");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Element vod = list.get(i);
|
||||
String a = vod.selectFirst(".post-box-title a").text();
|
||||
if (a.contains("(")) {
|
||||
String[] item = a.split("\\(");
|
||||
String title = item[0];
|
||||
String remark = item[1].replace(")", "");
|
||||
String cover = doReplaceRegex(m, vod.selectFirst(".post-box-image").attr("style"));
|
||||
Matcher matcher = regexVid.matcher(vod.selectFirst(".post-box-title a").attr("href"));
|
||||
if (!matcher.find())
|
||||
continue;
|
||||
String id = matcher.group(1);
|
||||
JSONObject v = new JSONObject();
|
||||
v.put("vod_id", id);
|
||||
v.put("vod_name", title);
|
||||
v.put("vod_pic", cover);
|
||||
v.put("vod_remarks", remark);
|
||||
videos.put(v);
|
||||
} else {
|
||||
String title = a;
|
||||
String cover = doReplaceRegex(m, vod.selectFirst(".post-box-image").attr("style"));
|
||||
String remark = doReplaceRegex(mark, vod.selectFirst(".post-box-title a").text());
|
||||
Matcher matcher = regexVid.matcher(vod.selectFirst(".post-box-title a").attr("href"));
|
||||
if (!matcher.find())
|
||||
continue;
|
||||
String id = matcher.group(1);
|
||||
JSONObject v = new JSONObject();
|
||||
v.put("vod_id", id);
|
||||
v.put("vod_name", title);
|
||||
v.put("vod_pic", cover);
|
||||
v.put("vod_remarks", remark);
|
||||
videos.put(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.put("page", page);
|
||||
result.put("pagecount", pageCount);
|
||||
result.put("limit", 24);
|
||||
result.put("total", pageCount <= 1 ? videos.length() : pageCount * 24);
|
||||
|
||||
result.put("list", videos);
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频详情信息
|
||||
*
|
||||
* @param ids 视频id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String detailContent(List<String> ids) {
|
||||
try {
|
||||
// 视频详情url
|
||||
String url = siteUrl + "/" + ids.get(0) + "/";
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject vodList = new JSONObject();
|
||||
|
||||
// 取基本数据
|
||||
String cover = doc.select("div.post img").attr("src");
|
||||
String ab = doc.select("h1.post-title").text();
|
||||
if (ab.contains("(")) {
|
||||
String[] b = ab.split("\\(");
|
||||
String title = b[0];
|
||||
String remark = b[1].replace("(", "");
|
||||
vodList.put("vod_name", title);
|
||||
vodList.put("vod_remarks", remark);
|
||||
} else {
|
||||
vodList.put("vod_name", ab);
|
||||
String remark = doc.select("time").text().trim();
|
||||
vodList.put("vod_remarks", "全");
|
||||
}
|
||||
String str2 = doc.select("div.abstract").text().replace(" ", "");
|
||||
String replace = str2.replace("<br>", "");
|
||||
String text = replace.replace("<p></p>", "");
|
||||
Pattern categorys = Pattern.compile("类型:(.*)制");
|
||||
String category = doReplaceRegex(categorys, text);
|
||||
Pattern a = Pattern.compile("年份:(.*)简");
|
||||
String year = doReplaceRegex(a, text);
|
||||
Pattern b = Pattern.compile("地区:(.*)年份");
|
||||
String area = doReplaceRegex(b, text);
|
||||
Pattern c = Pattern.compile("演员:(.*)类");
|
||||
String actor = doReplaceRegex(c, text);
|
||||
Pattern d = Pattern.compile("导演:(.*)演");
|
||||
String director = doReplaceRegex(d, text);
|
||||
Pattern e = Pattern.compile("简介:(.*)");
|
||||
String desc = doReplaceRegex(e, text);
|
||||
|
||||
|
||||
vodList.put("vod_id", ids.get(0));
|
||||
vodList.put("vod_pic", cover);
|
||||
vodList.put("type_name", category);
|
||||
vodList.put("vod_year", year);
|
||||
vodList.put("vod_area", area);
|
||||
vodList.put("vod_actor", actor);
|
||||
vodList.put("vod_director", director);
|
||||
vodList.put("vod_content", desc);
|
||||
|
||||
List<String> vodItems = new ArrayList<>();
|
||||
List<String> vodItems2 = new ArrayList<>();
|
||||
Map<String, String> vod_play = new LinkedHashMap<>();
|
||||
|
||||
Elements allScript = doc.select(".wp-playlist-script");
|
||||
String sourceName = "第1季";
|
||||
for (int j = 0; j < allScript.size(); j++) {
|
||||
String scContent = allScript.get(j).html().trim();
|
||||
int start = scContent.indexOf('{');
|
||||
int end = scContent.lastIndexOf('}') + 1;
|
||||
String json = scContent.substring(start, end);
|
||||
JSONObject UJson = new JSONObject(json);
|
||||
JSONArray Track = UJson.getJSONArray("tracks");
|
||||
for (int k = 0; k < Track.length(); k++) {
|
||||
JSONObject src = Track.getJSONObject(k);
|
||||
String adk = src.getString("src1");
|
||||
String vodName = src.getString("caption");
|
||||
String playURL = "https://ddrk.me/getvddr/video?id=" + adk + "&type=mix";
|
||||
String zm = "https://ddrk.me/subddr/" + src.getString("subsrc");
|
||||
String pzm = playURL + "|" + zm;
|
||||
vodItems.add(vodName + "$" + pzm);
|
||||
}
|
||||
vod_play.put(sourceName, TextUtils.join("#", vodItems));
|
||||
}
|
||||
Elements sources = doc.select(".post-page-numbers");
|
||||
if (!sources.isEmpty())
|
||||
for (int i = 0; i < sources.size(); i++) {
|
||||
Element source = sources.get(i);
|
||||
sourceName = "第" + source.text() + "季";
|
||||
String Purl = siteUrl + "/" + ids.get(0) + "/" + source.text() + "/";
|
||||
Document docs = Jsoup.parse(OkHttpUtil.string(Purl, getHeaders(Purl)));
|
||||
Elements allScripts = docs.select(".wp-playlist-script");
|
||||
for (int j = 0; j < allScripts.size(); j++) {
|
||||
String scContent = allScripts.get(j).html().trim();
|
||||
int start = scContent.indexOf('{');
|
||||
int end = scContent.lastIndexOf('}') + 1;
|
||||
String json = scContent.substring(start, end);
|
||||
JSONObject UJson = new JSONObject(json);
|
||||
JSONArray Track = UJson.getJSONArray("tracks");
|
||||
for (int k = 0; k < Track.length(); k++) {
|
||||
JSONObject src = Track.getJSONObject(k);
|
||||
String adk = src.getString("src1");
|
||||
String vodName = src.getString("caption");
|
||||
String playURL = "https://ddrk.me/getvddr/video?id=" + adk + "&type=mix";
|
||||
String zm = "https://ddrk.me/subddr/" + src.getString("subsrc");
|
||||
String pzm = playURL + "|" + zm;
|
||||
vodItems2.add(vodName + "$" + pzm);
|
||||
}
|
||||
vod_play.put(sourceName, TextUtils.join("#", vodItems2));
|
||||
}
|
||||
vodItems2.removeAll(vodItems2);
|
||||
}
|
||||
|
||||
String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
|
||||
String vod_play_url = TextUtils.join("$$$", vod_play.values());
|
||||
vodList.put("vod_play_from", vod_play_from);
|
||||
vodList.put("vod_play_url", vod_play_url);
|
||||
|
||||
JSONArray list = new JSONArray();
|
||||
list.put(vodList);
|
||||
result.put("list", list);
|
||||
return result.toString();
|
||||
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static Object[] loadsub(String sub) {
|
||||
try {
|
||||
OKCallBack.OKCallBackDefault callBack = new OKCallBack.OKCallBackDefault() {
|
||||
@Override
|
||||
protected void onFailure(Call call, Exception e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResponse(Response response) {
|
||||
|
||||
}
|
||||
};
|
||||
OkHttpClient YM = OkHttpUtil.defaultClient();
|
||||
OkHttpUtil.get(YM, sub, null, Headers(), callBack);
|
||||
Response result = callBack.getResult();
|
||||
int code = result.code();
|
||||
if (code == 404) {
|
||||
return new Object[]{200, "application/octet-stream", new ByteArrayInputStream("WEBVTT".getBytes())};
|
||||
}
|
||||
ResponseBody body = result.body();
|
||||
byte[] bytes = body.bytes();
|
||||
byte[] tokenkey = Arrays.copyOfRange(bytes, 0, 16);
|
||||
byte[] data = Arrays.copyOfRange(bytes, 16, bytes.length);
|
||||
byte[] KS = CBC.CBC(data, tokenkey, tokenkey);
|
||||
String vtt = gZip.KS(KS);
|
||||
|
||||
|
||||
vtt = vtt.replaceAll("(\\d{2}:\\d{2}:\\d{2}.\\d{3}.+\\d{2}:\\d{2}:\\d{2}.\\d{3}).*", "$1");
|
||||
vtt = vtt.replaceAll("(\\d{2}:\\d{2}.\\d{3}).*?( --> )(\\d{2}:\\d{2}.\\d{3}).*", "00:$1$200:$3");
|
||||
BufferedReader br = new BufferedReader(new StringReader(vtt));
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
int captionNumber = 1;
|
||||
String line = br.readLine();
|
||||
while (line != null) {
|
||||
if (line.matches("\\d{2}:\\d{2}:\\d{2}.\\d{3}.+\\d{2}:\\d{2}:\\d{2}.\\d{3}")) {
|
||||
if (lines.get(lines.size() - 1).trim().isEmpty()) {
|
||||
lines.add(captionNumber + "");
|
||||
captionNumber++;
|
||||
}
|
||||
}
|
||||
lines.add(line);
|
||||
line = br.readLine();
|
||||
}
|
||||
String join = TextUtils.join("\n", lines);
|
||||
|
||||
return new Object[]{200, "application/octet-stream", new ByteArrayInputStream(join.getBytes())};
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SpiderDebug.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取视频播放信息
|
||||
*
|
||||
* @param flag 播放源
|
||||
* @param id 视频id
|
||||
* @param vipFlags 所有可能需要vip解析的源
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
try {
|
||||
String[] item = id.split("\\|");
|
||||
String playUrl = item[0];
|
||||
String ZiMu = item[1];
|
||||
|
||||
String content = OkHttpUtil.string(playUrl, getHeaders(playUrl));
|
||||
JSONObject obj = new JSONObject(content);
|
||||
String RealUrl = obj.optString("url");
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("parse", 0);
|
||||
result.put("playUrl", "");
|
||||
result.put("url", RealUrl);
|
||||
result.put("header", "");
|
||||
// if (!TextUtils.isEmpty(str4)) {
|
||||
result.put("subf", "/vtt/utf-8");
|
||||
result.put("subt", Proxy.localProxyUrl() + "?do=ddrk&url=" + URLEncoder.encode(ZiMu));
|
||||
// result.put("subt", ZiMu);
|
||||
// }
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) {
|
||||
try {
|
||||
String url = "https://www.google.com/search?q=site%3Addrk.me+" + URLEncoder.encode(key);
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
|
||||
JSONObject result = new JSONObject();
|
||||
JSONArray videos = new JSONArray();
|
||||
String sourceName = doc.select("div.yuRUbf a h3").text();
|
||||
if (sourceName.contains(key)) {
|
||||
String list1 = doc.select("div.yuRUbf a").attr("href");
|
||||
Document ddrklink = Jsoup.parse(OkHttpUtil.string(list1, getHeaders(list1)));
|
||||
String DDlink = ddrklink.select("link[rel=canonical]").attr("href");
|
||||
Matcher matcher = regexVid.matcher(DDlink);
|
||||
if (matcher.find()) {
|
||||
JSONObject v = new JSONObject();
|
||||
String group = matcher.group(1);
|
||||
String ab = ddrklink.select("h1.post-title").text();
|
||||
String cover = ddrklink.select("div.post img").attr("src");
|
||||
if (ab.contains("(")) {
|
||||
String[] b = ab.split("\\(");
|
||||
String title = b[0];
|
||||
String remark = b[1].replace("(", "");
|
||||
v.put("vod_name", title);
|
||||
v.put("vod_remarks", remark);
|
||||
} else {
|
||||
v.put("vod_name", ab);
|
||||
String remark = "全";
|
||||
v.put("vod_remarks", remark);
|
||||
}
|
||||
v.put("vod_id", group);
|
||||
v.put("vod_pic", cover);
|
||||
videos.put(v);
|
||||
}
|
||||
}
|
||||
result.put("list", videos);
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String doReplaceRegex(Pattern pattern, String src) {
|
||||
if (pattern == null)
|
||||
return src;
|
||||
try {
|
||||
Matcher matcher = pattern.matcher(src);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1).trim();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user