Merge remote-tracking branch 'up/main'

# Conflicts:
#	app/src/main/java/com/github/catvod/debug/MainActivity.java
#	app/src/main/java/com/github/catvod/spider/JavDb.java
#	jar/custom_spider.jar
#	jar/custom_spider.jar.md5
This commit is contained in:
fatkun 2024-02-24 15:39:50 +08:00
commit 48d44dcf7e
18 changed files with 248 additions and 354 deletions

View File

@ -1,96 +0,0 @@
package com.github.catvod.bean.star;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class Detail {
@SerializedName("id")
private String id;
@SerializedName("videos")
private List<Video> videos;
@SerializedName("actor")
private String actor;
@SerializedName("country")
private String country;
@SerializedName("desc")
private String desc;
@SerializedName("label")
private String label;
@SerializedName("director")
private String director;
@SerializedName("name")
private String name;
@SerializedName("picurl")
private String picurl;
@SerializedName("time")
private String time;
@SerializedName("countStr")
private String countStr;
public static Detail objectFrom(String str) {
return new Gson().fromJson(str, Detail.class);
}
public String getId() {
return id;
}
public List<Video> getVideos() {
return videos;
}
public String getActor() {
return actor;
}
public String getCountry() {
return country;
}
public String getDesc() {
return desc;
}
public String getLabel() {
return label;
}
public String getDirector() {
return director;
}
public String getName() {
return name;
}
public String getPicurl() {
return picurl;
}
public String getTime() {
return time;
}
public String getCountStr() {
return countStr;
}
public static class Video {
@SerializedName("eporder")
private Integer eporder;
@SerializedName("purl")
private String purl;
public Integer getEporder() {
return eporder;
}
public String getPurl() {
return purl;
}
}
}

View File

@ -0,0 +1,24 @@
package com.github.catvod.bean.star;
import android.text.TextUtils;
import com.google.gson.annotations.SerializedName;
import java.util.Collections;
import java.util.List;
public class Group {
@SerializedName("name")
private String name;
@SerializedName("videos")
private List<Video> videos;
public String getName() {
return TextUtils.isEmpty(name) ? "" : name;
}
public List<Video> getVideos() {
return videos == null ? Collections.emptyList() : videos;
}
}

View File

@ -0,0 +1,71 @@
package com.github.catvod.bean.star;
import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.Collections;
import java.util.List;
public class Info {
@SerializedName("videosGroup")
private List<Group> videosGroup;
@SerializedName("actor")
private List<Person> actor;
@SerializedName("country")
private String country;
@SerializedName("desc")
private String desc;
@SerializedName("director")
private List<Person> director;
@SerializedName("name")
private String name;
@SerializedName("picurl")
private String picurl;
@SerializedName("time")
private String time;
@SerializedName("countStr")
private String countStr;
public static Info objectFrom(String str) {
return new Gson().fromJson(str, Info.class);
}
public List<Group> getVideosGroup() {
return videosGroup == null ? Collections.emptyList() : videosGroup;
}
public List<Person> getActor() {
return actor == null ? Collections.emptyList() : actor;
}
public String getCountry() {
return TextUtils.isEmpty(country) ? "" : country;
}
public String getDesc() {
return TextUtils.isEmpty(desc) ? "" : desc;
}
public List<Person> getDirector() {
return director == null ? Collections.emptyList() : director;
}
public String getName() {
return TextUtils.isEmpty(name) ? "" : name;
}
public String getPicurl() {
return TextUtils.isEmpty(picurl) ? "" : picurl;
}
public String getTime() {
return TextUtils.isEmpty(time) ? "" : time;
}
public String getCountStr() {
return TextUtils.isEmpty(countStr) ? "" : countStr;
}
}

View File

@ -0,0 +1,21 @@
package com.github.catvod.bean.star;
import android.text.TextUtils;
import com.google.gson.annotations.SerializedName;
public class Person {
@SerializedName("id")
private int id;
@SerializedName("name")
private String name;
public int getId() {
return id;
}
public String getName() {
return TextUtils.isEmpty(name) ? "" : name;
}
}

View File

@ -0,0 +1,21 @@
package com.github.catvod.bean.star;
import android.text.TextUtils;
import com.google.gson.annotations.SerializedName;
public class Video {
@SerializedName("purl")
private String purl;
@SerializedName("eporder")
private int eporder;
public String getPurl() {
return TextUtils.isEmpty(purl) ? "" : purl;
}
public int getEporder() {
return eporder;
}
}

View File

@ -106,6 +106,6 @@ public class OkHttp {
}
public static OkHttpClient.Builder getBuilder() {
return new OkHttpClient.Builder().addInterceptor(new OkhttpInterceptor()).dns(dns()).connectTimeout(30, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).hostnameVerifier((hostname, session) -> true).sslSocketFactory(new SSLCompat(), SSLCompat.TM);
return new OkHttpClient.Builder().dns(dns()).connectTimeout(30, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).hostnameVerifier((hostname, session) -> true).sslSocketFactory(new SSLCompat(), SSLCompat.TM);
}
}

View File

@ -1,48 +0,0 @@
package com.github.catvod.net;
import com.github.catvod.utils.Util;
import java.io.IOException;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okio.BufferedSource;
import okio.Okio;
public class OkhttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Response response = chain.proceed(getRequest(chain));
String encoding = response.header("Content-Encoding");
if (response.body() == null || encoding == null || !encoding.equals("deflate")) return response;
InflaterInputStream is = new InflaterInputStream(response.body().byteStream(), new Inflater(true));
return response.newBuilder().headers(response.headers()).body(new ResponseBody() {
@Override
public MediaType contentType() {
return response.body().contentType();
}
@Override
public long contentLength() {
return response.body().contentLength();
}
@Override
public BufferedSource source() {
return Okio.buffer(Okio.source(is));
}
}).build();
}
private Request getRequest(Chain chain) {
Request request = chain.request();
if (request.url().host().equals("gitcode.net")) return request.newBuilder().addHeader("User-Agent", Util.CHROME).build();
return request;
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,7 @@
package com.github.catvod.spider;
import android.content.Context;
import com.github.catvod.bean.Class;
import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod;
@ -13,16 +15,37 @@ import org.jsoup.nodes.Element;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Eighteen extends Spider {
private final String url = "https://maa1815.com/zh/";
private final String url = "https://mjv002.com/zh/";
private String cookie;
private void getCookie() {
try {
cookie = OkHttp.newCall("https://mjv002.com/zh/chinese_IamOverEighteenYearsOld/19/index.html").headers("set-cookie").get(0).split(";")[0];
} catch (Exception e) {
e.printStackTrace();
}
}
private Map<String, String> getHeader() {
Map<String, String> header = new HashMap<>();
header.put("Cookie", cookie);
return header;
}
@Override
public void init(Context context, String extend) throws Exception {
getCookie();
}
@Override
public String homeContent(boolean filter) throws Exception {
List<Class> classes = new ArrayList<>();
List<Vod> list = new ArrayList<>();
Document doc = Jsoup.parse(OkHttp.string(url));
Document doc = Jsoup.parse(OkHttp.string(url, getHeader()));
for (Element a : doc.select("ul.animenu__nav > li > a")) {
String typeName = a.text();
String typeId = a.attr("href").replace(url, "");
@ -45,7 +68,7 @@ public class Eighteen extends Spider {
List<Vod> list = new ArrayList<>();
tid = tid.replace("random", "list");
tid = tid.replace("index", pg);
Document doc = Jsoup.parse(OkHttp.string(url + tid));
Document doc = Jsoup.parse(OkHttp.string(url + tid, getHeader()));
for (Element div : doc.select("div.post")) {
String id = div.select("a").attr("href").replace(url, "");
String name = div.select("h3").text();
@ -58,7 +81,7 @@ public class Eighteen extends Spider {
@Override
public String detailContent(List<String> ids) throws Exception {
Document doc = Jsoup.parse(OkHttp.string(url + ids.get(0)));
Document doc = Jsoup.parse(OkHttp.string(url + ids.get(0), getHeader()));
Element wrap = doc.select("div.video-wrap").get(0);
String name = wrap.select("div.archive-title > h1").text();
String pic = wrap.select("div.player-wrap > img").attr("src");
@ -83,7 +106,7 @@ public class Eighteen extends Spider {
@Override
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
return Result.get().parse().url(url + id).string();
return Result.get().parse().url(url + id).header(getHeader()).string();
}
private String searchContent(String key, String pg) {
@ -91,7 +114,7 @@ public class Eighteen extends Spider {
params.put("search_keyword", key);
params.put("search_type", "fc");
params.put("op", "search");
String res = OkHttp.post(url + "searchform_search/all/" + pg + ".html", params);
String res = OkHttp.post(url + "searchform_search/all/" + pg + ".html", params, getHeader()).getBody();
List<Vod> list = new ArrayList<>();
for (Element div : Jsoup.parse(res).select("div.post")) {
String id = div.select("a").attr("href").replace(url, "");

View File

@ -27,14 +27,13 @@ import java.util.Map;
/**
* @author Qile
*/
public class JavDb extends Spider {
private static String siteUrl = "https://javdb524.com";
private static String siteUrl = "https://javdb523.com";
@Override
public void init(Context context, String extend) throws Exception {
if(!extend.isEmpty())
siteUrl = extend;
if (!extend.isEmpty()) siteUrl = extend;
}
private Map<String, String> getHeader() {

View File

@ -86,10 +86,10 @@ public class Market extends Spider {
setBusy(true);
Init.run(this::setDialog, 500);
Response response = OkHttp.newCall(url);
File file = new File(Path.download(), Uri.parse(url).getLastPathSegment());
File file = Path.create(new File(Path.download(), Uri.parse(url).getLastPathSegment()));
download(file, response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1")));
if (file.getName().endsWith(".zip")) FileUtil.unzip(file, Path.download());
if (file.getName().endsWith(".apk")) FileUtil.openFile(Path.chmod(file));
if (file.getName().endsWith(".apk")) FileUtil.openFile(file);
else Notify.show("下載完成");
checkCopy(url);
dismiss();

View File

@ -41,6 +41,7 @@ public class Push extends Spider {
if (flag.equals("直連")) return Result.get().url(id).subs(getSubs(id)).string();
if (flag.equals("解析")) return Result.get().parse().jx().url(id).string();
if (flag.equals("嗅探")) return Result.get().parse().url(id).string();
if (flag.equals("迅雷")) return Result.get().url(id).string();
return ali.playerContent(flag, id, vipFlags);
}
@ -51,8 +52,10 @@ public class Push extends Spider {
vod.setVodName(url.startsWith("file://") ? new File(url).getName() : url);
if (url.startsWith("http") && url.contains("#")) url = url.replace("#", "***");
vod.setVodPic("https://pic.rmb.bdstatic.com/bjh/1d0b02d0f57f0a42201f92caba5107ed.jpeg");
vod.setVodPlayFrom(TextUtils.join("$$$", Arrays.asList("直連", "嗅探", "解析")));
vod.setVodPlayUrl(TextUtils.join("$$$", Arrays.asList("播放$" + url, "播放$" + url, "播放$" + url)));
String play = "播放$" + url;
boolean thunder = Util.isThunder(url);
vod.setVodPlayUrl(thunder ? play : TextUtils.join("$$$", Arrays.asList(play, play, play)));
vod.setVodPlayFrom(thunder ? "迅雷" : TextUtils.join("$$$", Arrays.asList("直連", "嗅探", "解析")));
return vod;
}

View File

@ -9,8 +9,11 @@ import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod;
import com.github.catvod.bean.star.Card;
import com.github.catvod.bean.star.Condition;
import com.github.catvod.bean.star.Detail;
import com.github.catvod.bean.star.Group;
import com.github.catvod.bean.star.Info;
import com.github.catvod.bean.star.Person;
import com.github.catvod.bean.star.Query;
import com.github.catvod.bean.star.Video;
import com.github.catvod.crawler.Spider;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Util;
@ -40,7 +43,7 @@ public class Star extends Spider {
private Map<String, String> getHeader() {
Map<String, String> headers = new HashMap<>();
headers.put("User-Agent", Util.CHROME);
headers.put("Cookie", "userIP=127.0.0.1; aws-waf-token=");
headers.put("Cookie", "userIP=64.252.112.99;");
headers.put("Referer", siteUrl);
return headers;
}
@ -66,7 +69,6 @@ public class Star extends Spider {
map.put("drama", "电视剧");
map.put("animation", "动漫");
map.put("variety", "综艺");
map.put("documentary", "纪录片");
ver = getVer();
}
@ -95,6 +97,7 @@ public class Star extends Spider {
@Override
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
if (tid.endsWith("/{pg}")) return searchContent(tid.split("/")[0], true);
String year = extend.containsKey("year") ? extend.get("year") : "";
String type = extend.containsKey("type") ? extend.get("type") : "";
String area = extend.containsKey("area") ? extend.get("area") : "";
@ -115,22 +118,27 @@ public class Star extends Spider {
@Override
public String detailContent(List<String> ids) throws Exception {
Element script = Jsoup.parse(OkHttp.string(client(), detail.concat(ids.get(0)), getHeader())).select("#__NEXT_DATA__").get(0);
Detail detail = Detail.objectFrom(new JSONObject(script.data()).getJSONObject("props").getJSONObject("pageProps").getJSONObject("pageData").toString());
Info detail = Info.objectFrom(new JSONObject(script.data()).getJSONObject("props").getJSONObject("pageProps").getJSONObject("collectionInfo").toString());
Vod vod = new Vod();
vod.setVodId(ids.get(0));
vod.setVodPic(detail.getPicurl());
vod.setVodYear(detail.getTime());
vod.setVodName(detail.getName());
vod.setVodPic(detail.getPicurl());
vod.setVodArea(detail.getCountry());
vod.setVodActor(detail.getActor());
vod.setVodRemarks(detail.getCountStr());
vod.setVodContent(detail.getDesc());
vod.setVodDirector(detail.getDirector());
vod.setTypeName(detail.getLabel());
vod.setVodPlayFrom("FongMi");
vod.setVodRemarks(detail.getCountStr());
vod.setVodActor(convert(detail.getActor()));
vod.setVodDirector(convert(detail.getDirector()));
List<String> playFrom = new ArrayList<>();
List<String> playUrls = new ArrayList<>();
for (Detail.Video video : detail.getVideos()) playUrls.add(video.getEporder() + "$" + video.getPurl());
vod.setVodPlayUrl(TextUtils.join("#", playUrls));
for (Group group : detail.getVideosGroup()) {
List<String> urls = new ArrayList<>();
for (Video video : group.getVideos()) urls.add(video.getEporder() + "$" + video.getPurl());
playUrls.add(TextUtils.join("#", urls));
playFrom.add(group.getName());
}
vod.setVodPlayUrl(TextUtils.join("$$$", playUrls));
vod.setVodPlayFrom(TextUtils.join("$$$", playFrom));
return Result.string(vod);
}
@ -140,12 +148,18 @@ public class Star extends Spider {
String json = OkHttp.string(client(), siteUrl + data + ver + "/search.json?word=" + URLEncoder.encode(key), getHeader());
List<Card> items = Card.arrayFrom(new JSONObject(json).getJSONObject("pageProps").getJSONArray("initList").toString());
for (Card item : items) list.add(item.vod());
return Result.string(list);
return Result.get().vod(list).page().string();
}
@Override
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
return Result.get().url(id).string();
}
private String convert(List<Person> items) {
StringBuilder sb = new StringBuilder();
for (Person item : items) sb.append(String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}/]%s[/a]", item.getName() + "/{pg}", item.getName(), item.getName())).append(",");
return Util.substring(sb.toString());
}
}

View File

@ -7,14 +7,13 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Path {
private static File check(File file) {
private static File mkdir(File file) {
if (!file.exists()) file.mkdirs();
return file;
}
@ -28,7 +27,7 @@ public class Path {
}
public static File tv() {
return check(new File(root() + File.separator + "TV"));
return mkdir(new File(root() + File.separator + "TV"));
}
public static File tv(String name) {
@ -62,11 +61,10 @@ public class Path {
public static File write(File file, byte[] data) {
try {
FileOutputStream fos = new FileOutputStream(file);
FileOutputStream fos = new FileOutputStream(create(file));
fos.write(data);
fos.flush();
fos.close();
chmod(file);
return file;
} catch (Exception ignored) {
return file;
@ -75,16 +73,13 @@ public class Path {
public static void copy(InputStream in, File out) {
try {
copy(in, new FileOutputStream(out));
} catch (Exception ignored) {
}
}
public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
int read;
byte[] buffer = new byte[8192];
int amountRead;
while ((amountRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, amountRead);
FileOutputStream fos = new FileOutputStream(create(out));
while ((read = in.read(buffer)) != -1) fos.write(buffer, 0, read);
fos.close();
in.close();
} catch (Exception ignored) {
}
}
@ -93,10 +88,11 @@ public class Path {
return files == null ? Collections.emptyList() : Arrays.asList(files);
}
public static File chmod(File file) {
public static File create(File file) throws Exception {
try {
Process process = Runtime.getRuntime().exec("chmod 777 " + file);
process.waitFor();
if (!file.canWrite()) file.setWritable(true);
if (!file.exists()) file.createNewFile();
Shell.exec("chmod 777 " + file);
return file;
} catch (Exception e) {
e.printStackTrace();

View File

@ -0,0 +1,13 @@
package com.github.catvod.utils;
public class Shell {
public static void exec(String command) {
try {
int code = Runtime.getRuntime().exec(command).waitFor();
if (code != 0) throw new RuntimeException("Shell command failed with exit code " + code);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -26,6 +26,7 @@ import java.util.regex.Pattern;
public class Util {
public static final Pattern RULE = Pattern.compile("http((?!http).){12,}?\\.(m3u8|mp4|mkv|flv|mp3|m4a|aac)\\?.*|http((?!http).){12,}\\.(m3u8|mp4|mkv|flv|mp3|m4a|aac)|http((?!http).)*?video/tos*");
public static final Pattern THUNDER = Pattern.compile("(magnet|thunder|ed2k):.*");
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36";
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "iso", "mpg", "ts", "mp3", "aac", "flac", "m4a", "ape", "ogg");
@ -43,6 +44,14 @@ public class Util {
return false;
}
public static boolean isThunder(String url) {
return THUNDER.matcher(url).find() || isTorrent(url);
}
public static boolean isTorrent(String url) {
return !url.startsWith("magnet") && url.split(";")[0].endsWith(".torrent");
}
public static boolean isVideoFormat(String url) {
if (url.contains("url=http") || url.contains(".js") || url.contains(".css") || url.contains(".html")) return false;
return RULE.matcher(url).find();

View File

@ -99,12 +99,13 @@
"haiwaikan"
],
"regex": [
"8.16",
"8.1748",
"10.0099",
"10.3333",
"16.0599",
"8.1748",
"10.85",
"12.33",
"10.85"
"16.0599"
]
},
{
@ -153,9 +154,7 @@
"hd.ffzy"
],
"regex": [
"25.0666",
"25.08",
"20.52"
"25.1"
]
},
{
@ -214,6 +213,7 @@
}
],
"ads": [
"static-mozai.4gtv.tv"
"static-mozai.4gtv.tv",
"s3t3d2y8.afcdn.net"
]
}

View File

@ -1 +0,0 @@
DedeUserID=690781341;DedeUserID__ckMd5=cabc96906269c5b6;SESSDATA=2245ba24%2C1684212125%2C466fd%2Ab2;bili_jct=de6fdb60c10f8a83910aa55d79407b4e;