pull/1/head
FongMi 4 years ago
parent f1e2034460
commit ed09b1a37a
  1. 4
      app/src/main/java/com/github/catvod/bean/Class.java
  2. 263
      app/src/main/java/com/github/catvod/spider/Anime1.java
  3. 1
      app/src/main/java/com/github/catvod/spider/Tangrenjie.java

@ -9,6 +9,10 @@ public class Class {
@SerializedName("type_name")
private String typeName;
public Class(int typeId, String typeName) {
this(String.valueOf(typeId), typeName);
}
public Class(String typeId, String typeName) {
this.typeId = typeId;
this.typeName = typeName;

@ -2,10 +2,14 @@ package com.github.catvod.spider;
import android.text.TextUtils;
import com.github.catvod.bean.Class;
import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod;
import com.github.catvod.crawler.Spider;
import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.net.OKCallBack;
import com.github.catvod.net.OkHttpUtil;
import com.google.gson.Gson;
import org.json.JSONArray;
import org.json.JSONObject;
@ -16,6 +20,7 @@ import org.jsoup.select.Elements;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
@ -33,9 +38,63 @@ import okhttp3.Response;
*/
public class Anime1 extends Spider {
private String cookies = "";
private String authority = "";
private final JSONArray srcArray = new JSONArray();
private final String vodPic = "https://sta.anicdn.com/playerImg/8.jpg";
private String authority = "";
private String cookies = "";
private HashMap<String, String> getHeaders3() {
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() {
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() {
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;
}
@Override
public String homeContent(boolean filter) {
@ -54,41 +113,29 @@ public class Anime1 extends Spider {
subobj.put("team", srcOrign.getJSONArray(i).get(5).toString());
srcArray.put(subobj);
}
JSONObject result = new JSONObject();
JSONArray classes = new JSONArray();
Result result = new Result();
List<Class> classes = new ArrayList<>();
Calendar cal = Calendar.getInstance();
int doy = cal.get(Calendar.YEAR) + 1;
int year = 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);
classes.add(new Class(i, "最近更新"));
} else if (i < 7) {
doy = doy - 1;
String year = Integer.toString(doy);
cateobj.put("type_name", year);
cateobj.put("type_id", istr);
year = year - 1;
classes.add(new Class(i, String.valueOf(year)));
} else {
cateobj.put("type_name", "更早");
cateobj.put("type_id", istr);
classes.add(new Class(i, "更早"));
}
classes.put(cateobj);
}
result.put("class", classes);
JSONArray videos = new JSONArray();
List<Vod> videos = new ArrayList<>();
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);
videos.add(new Vod(id, name, vodPic, mark));
}
result.put("list", videos);
result.setClasses(classes);
result.setList(videos);
return result.toString();
} catch (Exception e) {
SpiderDebug.log(e);
@ -99,57 +146,44 @@ public class Anime1 extends Spider {
@Override
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
try {
JSONArray srccate = new JSONArray();
JSONArray array = 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);
array.put(srcArray.getJSONObject(i));
}
} else if (cateId > 0 && cateId < 7) {
int yearchk = doy - cateId;
for (int i = 0; i < srclen; i++) {
for (int i = 0; i < srcArray.length(); i++) {
JSONObject subobj = srcArray.getJSONObject(i);
String yystr = subobj.getString("year");
if (yystr.contains("/")) {
yystr = yystr.substring(5);
}
if (yystr.contains("/")) yystr = yystr.substring(5);
int yy = Integer.parseInt(yystr);
if (yy == yearchk) {
srccate.put(subobj);
}
if (yy == yearchk) array.put(subobj);
}
} else {
int yy = doy - 6;
for (int i = 0; i < srclen; i++) {
for (int i = 0; i < srcArray.length(); 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);
}
if (yearint < yy) array.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);
List<Vod> videos = new ArrayList<>();
for (int i = 0; i < array.length(); i++) {
String id = array.getJSONObject(i).getString("link");
String name = array.getJSONObject(i).getString("name");
String mark = array.getJSONObject(i).getString("hit");
videos.add(new Vod(id, name, vodPic, mark));
}
JSONObject result = new JSONObject();
result.put("list", videos);
Result result = new Result();
result.setList(videos);
return result.toString();
} catch (Exception e) {
SpiderDebug.log(e);
@ -165,29 +199,28 @@ public class Anime1 extends Spider {
for (int i = 0; i < srcArray.length(); i++) {
JSONObject dtobj = srcArray.getJSONObject(i);
String objid = dtobj.getString("link");
if (objid.equals(id)) {
dtinfo = dtobj;
}
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);
Result result = new Result();
Vod vod = new Vod();
vod.setVodId(ids.get(0));
vod.setVodName(title);
vod.setVodPic(vodPic);
vod.setVodYear(year);
vod.setTypeName(season);
vod.setVodArea("日本");
vod.setVodActor(team);
vod.setVodContent(mark);
String url = "https://anime1.me/?cat=" + id;
Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders2()));
String nextPage = "";
String nextPage;
Map<String, String> vod_play_Order = new TreeMap<>();
do {
Element nextPageEle = doc.selectFirst("div.nav-previous a");
@ -216,11 +249,8 @@ public class Anime1 extends Spider {
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;
}
String playURL = playListA.get(j).attr("data-apireq");
if (playURL.isEmpty()) continue;
if (playListA.size() > 1) {
if (j < 9) {
int jj = j + 1;
@ -265,13 +295,9 @@ public class Anime1 extends Spider {
if (playList.length() == 0) playList = "nothing here";
Map<String, String> vod_play = new TreeMap<>();
vod_play.put("Anime1", playList);
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);
vod.setVodPlayFrom(TextUtils.join("$$$", vod_play.keySet()));
vod.setVodPlayUrl(TextUtils.join("$$$", vod_play.values()));
result.setList(Arrays.asList(vod));
return result.toString();
} catch (Exception e) {
SpiderDebug.log(e);
@ -285,7 +311,7 @@ public class Anime1 extends Spider {
cookies = "";
authority = "";
String url = "https://v.anime1.me/api";
JSONObject result = new JSONObject();
Result result = new Result();
String jsonreq = URLDecoder.decode(id, "UTF-8");
HashMap<String, String> reqpayload = new HashMap<>();
reqpayload.put("d", jsonreq);
@ -312,14 +338,13 @@ public class Anime1 extends Spider {
String videolink = obj2.getString("src");
authority = videolink.split("/")[2];
videolink = "https:" + videolink;
result.put("url", videolink);
result.setUrl(videolink);
} catch (Exception ignored) {
}
}
});
result.put("header", new JSONObject(getHeaders1()).toString());
result.put("parse", 0);
result.put("playUrl", "");
result.setHeader(new Gson().toJson(getHeaders1()));
result.setParse("0");
return result.toString();
} catch (Exception e) {
SpiderDebug.log(e);
@ -327,59 +352,6 @@ public class Anime1 extends Spider {
}
}
private HashMap<String, String> getHeaders3() {
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() {
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() {
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;
}
@Override
public String searchContent(String key, boolean quick) {
try {
@ -387,27 +359,20 @@ public class Anime1 extends Spider {
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);
}
if (kw.contains(key)) searchResult.put(srobj);
}
JSONObject result = new JSONObject();
JSONArray videos = new JSONArray();
Result result = new Result();
List<Vod> videos = new ArrayList<>();
if (searchResult.length() > 0) {
int ch = Math.min(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);
videos.add(new Vod(id, name, vodPic, mark));
}
}
result.put("list", videos);
result.setList(videos);
return result.toString();
} catch (Exception e) {
SpiderDebug.log(e);

@ -39,7 +39,6 @@ public class Tangrenjie extends Spider {
private final Pattern regexCategory = Pattern.compile("/vod/type/id/(\\d+).html");
private final Pattern regexVid = Pattern.compile("/vod/detail/id/(\\d+).html");
private final Pattern regexPlay = Pattern.compile("/vod/play/id/(\\d+)/sid/(\\d+)/nid/(\\d+).html");
private final Pattern regexPage = Pattern.compile("\\S+/page/(\\d+)\\S+");
private JSONObject playerConfig;
private JSONObject filterConfig;

Loading…
Cancel
Save