Update proxy
This commit is contained in:
parent
dc4904859f
commit
6ea1a9c090
|
|
@ -11,6 +11,8 @@ import okhttp3.OkHttpClient;
|
|||
|
||||
public abstract class Spider {
|
||||
|
||||
public String siteKey;
|
||||
|
||||
public void init(Context context) throws Exception {
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +64,7 @@ public abstract class Spider {
|
|||
return null;
|
||||
}
|
||||
|
||||
public String action(String action) {
|
||||
public String action(String action) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.github.catvod.crawler.SpiderDebug;
|
|||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Util;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -35,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class AList extends Spider {
|
||||
|
||||
private ExecutorService executor;
|
||||
private List<Drive> drives;
|
||||
private String ext;
|
||||
|
||||
|
|
@ -68,12 +70,13 @@ public class AList extends Spider {
|
|||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
executor = Executors.newCachedThreadPool();
|
||||
ext = extend;
|
||||
fetchRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
List<Class> classes = new ArrayList<>();
|
||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||
for (Drive drive : drives) if (!drive.hidden()) classes.add(drive.toType());
|
||||
|
|
@ -82,7 +85,7 @@ public class AList extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
String type = extend.containsKey("type") ? extend.get("type") : "";
|
||||
String order = extend.containsKey("order") ? extend.get("order") : "";
|
||||
List<Item> folders = new ArrayList<>();
|
||||
|
|
@ -104,7 +107,7 @@ public class AList extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) {
|
||||
String id = ids.get(0);
|
||||
String key = id.contains("/") ? id.substring(0, id.indexOf("/")) : id;
|
||||
String path = id.substring(0, id.lastIndexOf("/"));
|
||||
|
|
@ -135,7 +138,6 @@ public class AList extends Spider {
|
|||
public String searchContent(String keyword, boolean quick) throws Exception {
|
||||
List<Vod> list = new ArrayList<>();
|
||||
List<Job> jobs = new ArrayList<>();
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
for (Drive drive : drives) if (drive.search()) jobs.add(new Job(drive.check(), keyword));
|
||||
for (Future<List<Vod>> future : executor.invokeAll(jobs, 15, TimeUnit.SECONDS)) list.addAll(future.get());
|
||||
return Result.string(list);
|
||||
|
|
@ -148,6 +150,11 @@ public class AList extends Spider {
|
|||
return Result.get().url(url).header(getPlayHeader(url)).subs(getSubs(ids)).string();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
private static Map<String, String> getPlayHeader(String url) {
|
||||
try {
|
||||
Uri uri = Uri.parse(url);
|
||||
|
|
@ -209,7 +216,7 @@ public class AList extends Spider {
|
|||
}
|
||||
}
|
||||
|
||||
private String getListJson(boolean isNew, String response) throws Exception {
|
||||
private String getListJson(boolean isNew, String response) throws JSONException {
|
||||
if (isNew) {
|
||||
return new JSONObject(response).getJSONObject("data").getJSONArray("content").toString();
|
||||
} else {
|
||||
|
|
@ -217,7 +224,7 @@ public class AList extends Spider {
|
|||
}
|
||||
}
|
||||
|
||||
private String getDetailJson(boolean isNew, String response) throws Exception {
|
||||
private String getDetailJson(boolean isNew, String response) throws JSONException {
|
||||
if (isNew) {
|
||||
return new JSONObject(response).getJSONObject("data").toString();
|
||||
} else {
|
||||
|
|
@ -225,7 +232,7 @@ public class AList extends Spider {
|
|||
}
|
||||
}
|
||||
|
||||
private String getSearchJson(boolean isNew, String response) throws Exception {
|
||||
private String getSearchJson(boolean isNew, String response) throws JSONException {
|
||||
if (isNew) {
|
||||
return new JSONObject(response).getJSONObject("data").getJSONArray("content").toString();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -73,13 +73,13 @@ public class Bili extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
this.extend = Json.safeObject(extend);
|
||||
setCookie();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
if (extend.has("json")) return OkHttp.string(extend.get("json").getAsString());
|
||||
List<Class> classes = new ArrayList<>();
|
||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||
|
|
@ -102,7 +102,7 @@ public class Bili extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
if (tid.endsWith("/{pg}")) {
|
||||
LinkedHashMap<String, Object> params = new LinkedHashMap<>();
|
||||
params.put("mid", tid.split("/")[0]);
|
||||
|
|
@ -125,7 +125,7 @@ public class Bili extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) {
|
||||
if (!login) checkLogin();
|
||||
|
||||
String[] split = ids.get(0).split("@");
|
||||
|
|
@ -178,17 +178,17 @@ public class Bili extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) throws Exception {
|
||||
public String searchContent(String key, boolean quick) {
|
||||
return categoryContent(key, "1", true, new HashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
||||
public String searchContent(String key, boolean quick, String pg) {
|
||||
return categoryContent(key, pg, true, new HashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
String[] ids = id.split("\\+");
|
||||
String aid = ids[0];
|
||||
String cid = ids[1];
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class Jable extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
List<Vod> list = new ArrayList<>();
|
||||
List<Class> classes = new ArrayList<>();
|
||||
Document doc = Jsoup.parse(OkHttp.string(cateUrl, getHeaders()));
|
||||
|
|
@ -53,7 +53,7 @@ public class Jable extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
List<Vod> list = new ArrayList<>();
|
||||
String target = cateUrl + tid + "/?mode=async&function=get_block&block_id=list_videos_common_videos_list&sort_by=post_date&from=" + String.format(Locale.getDefault(), "%02d", Integer.parseInt(pg)) + "&_=" + System.currentTimeMillis();
|
||||
Document doc = Jsoup.parse(OkHttp.string(target, getHeaders()));
|
||||
|
|
@ -68,7 +68,7 @@ public class Jable extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) {
|
||||
Document doc = Jsoup.parse(OkHttp.string(detailUrl.concat(ids.get(0)).concat("/"), getHeaders()));
|
||||
String name = doc.select("meta[property=og:title]").attr("content");
|
||||
String pic = doc.select("meta[property=og:image]").attr("content");
|
||||
|
|
@ -84,7 +84,7 @@ public class Jable extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) throws Exception {
|
||||
public String searchContent(String key, boolean quick) {
|
||||
List<Vod> list = new ArrayList<>();
|
||||
Document doc = Jsoup.parse(OkHttp.string(searchUrl.concat(URLEncoder.encode(key)).concat("/"), getHeaders()));
|
||||
for (Element element : doc.select("div.video-img-box")) {
|
||||
|
|
@ -98,7 +98,7 @@ public class Jable extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
return Result.get().url(id).header(getHeaders()).string();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class Jianpian extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
this.extend = extend;
|
||||
JsonObject domains = new Gson().fromJson(OkHttp.string("https://dns.alidns.com/resolve?name=swrdsfeiujo25sw.cc&type=TXT"), JsonObject.class);
|
||||
String parts = domains.getAsJsonArray("Answer").get(0).getAsJsonObject().get("data").getAsString();
|
||||
|
|
@ -57,7 +57,7 @@ public class Jianpian extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
List<Class> classes = new ArrayList<>();
|
||||
List<String> typeIds = Arrays.asList("1", "2", "3", "4", "50", "99");
|
||||
List<String> typeNames = Arrays.asList("電影", "電視劇", "動漫", "綜藝", "紀錄片", "Netflix");
|
||||
|
|
@ -75,7 +75,7 @@ public class Jianpian extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
if (tid.endsWith("/{pg}")) return searchContent(tid.split("/")[0], pg);
|
||||
if (tid.equals("50") || tid.equals("99") || tid.equals("111")) {
|
||||
List<Vod> list = new ArrayList<>();
|
||||
|
|
@ -98,7 +98,7 @@ public class Jianpian extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) {
|
||||
String url = siteUrl + "/api/video/detailv2?id=" + ids.get(0);
|
||||
Data data = Detail.objectFrom(OkHttp.string(url, getHeader())).getData();
|
||||
Vod vod = data.vod(imgDomain);
|
||||
|
|
@ -114,21 +114,21 @@ public class Jianpian extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
return Result.get().url(id).header(getHeader()).string();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) throws Exception {
|
||||
public String searchContent(String key, boolean quick) {
|
||||
return searchContent(key, "1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
||||
public String searchContent(String key, boolean quick, String pg) {
|
||||
return searchContent(key, pg);
|
||||
}
|
||||
|
||||
public String searchContent(String key, String pg) throws Exception {
|
||||
public String searchContent(String key, String pg) {
|
||||
List<Vod> list = new ArrayList<>();
|
||||
String url = siteUrl + String.format("/api/v2/search/videoV2?key=%s&category_id=88&page=%s&pageSize=20", URLEncoder.encode(key), pg);
|
||||
Search search = Search.objectFrom(OkHttp.string(url, getHeader()));
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.github.catvod.net.OkHttp;
|
|||
import com.github.catvod.utils.Util;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
|
@ -37,12 +38,12 @@ public class Kanqiu extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
if (!extend.isEmpty()) siteUrl = extend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) throws JSONException {
|
||||
List<Class> classes = new ArrayList<>();
|
||||
List<String> typeIds = Arrays.asList("", "1", "8", "21");
|
||||
List<String> typeNames = Arrays.asList("全部直播", "篮球直播", "足球直播", "其他直播");
|
||||
|
|
@ -53,7 +54,7 @@ public class Kanqiu extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
String cateId = extend.get("cateId") == null ? tid : extend.get("cateId");
|
||||
String urlPath = cateId == null || cateId.isEmpty() ? "" : String.format("/match/%s/live", cateId);
|
||||
Elements lis = Jsoup.parse(OkHttp.string(siteUrl + urlPath, getHeader())).select(".list-group-item");
|
||||
|
|
@ -72,7 +73,7 @@ public class Kanqiu extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) throws JSONException {
|
||||
if (ids.get(0).equals(siteUrl)) return Result.error("比赛尚未开始");
|
||||
String content = OkHttp.string(ids.get(0) + "-url", getHeader());
|
||||
String result = new JSONObject(content).optString("data");
|
||||
|
|
@ -95,7 +96,7 @@ public class Kanqiu extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
return Result.get().url(id.replace("***", "#")).parse().header(getHeader()).string();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class Local extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
List<Class> classes = new ArrayList<>();
|
||||
classes.add(new Class(Environment.getExternalStorageDirectory().getAbsolutePath(), "本地文件", "1"));
|
||||
File[] files = new File("/storage").listFiles();
|
||||
|
|
@ -53,7 +53,7 @@ public class Local extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
List<Vod> items = new ArrayList<>();
|
||||
List<File> files = Path.list(new File(tid));
|
||||
for (File file : files) {
|
||||
|
|
@ -78,7 +78,7 @@ public class Local extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
if (id.startsWith("http")) {
|
||||
return Result.get().url(id).string();
|
||||
} else {
|
||||
|
|
@ -86,6 +86,16 @@ public class Local extends Spider {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] proxyLocal(Map<String, String> params) {
|
||||
String path = new String(Base64.decode(params.get("path"), Base64.DEFAULT | Base64.URL_SAFE));
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "application/octet-stream";
|
||||
result[2] = new ByteArrayInputStream(getBase64(path));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Vod create(String name, String url) {
|
||||
Vod vod = new Vod();
|
||||
vod.setTypeName("FongMi");
|
||||
|
|
@ -114,13 +124,13 @@ public class Local extends Spider {
|
|||
Vod vod = new Vod();
|
||||
vod.setVodId(file.getAbsolutePath());
|
||||
vod.setVodName(file.getName());
|
||||
vod.setVodPic(file.isFile() ? "proxy://do=local&path=" + Base64.encodeToString(file.getAbsolutePath().getBytes(), Base64.DEFAULT | Base64.URL_SAFE) : Image.FOLDER);
|
||||
vod.setVodPic(file.isFile() ? Proxy.getUrl(siteKey, "&path=" + Base64.encodeToString(file.getAbsolutePath().getBytes(), Base64.DEFAULT | Base64.URL_SAFE)) : Image.FOLDER);
|
||||
vod.setVodRemarks(format.format(file.lastModified()));
|
||||
vod.setVodTag(file.isDirectory() ? "folder" : "file");
|
||||
return vod;
|
||||
}
|
||||
|
||||
private static byte[] getBase64(String path) {
|
||||
private byte[] getBase64(String path) {
|
||||
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND);
|
||||
if (bitmap == null) return Base64.decode(Image.VIDEO.split("base64,")[1], Base64.DEFAULT);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
|
@ -136,13 +146,4 @@ public class Local extends Spider {
|
|||
}
|
||||
return subs;
|
||||
}
|
||||
|
||||
public static Object[] proxy(Map<String, String> params) {
|
||||
String path = new String(Base64.decode(params.get("path"), Base64.DEFAULT | Base64.URL_SAFE));
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "application/octet-stream";
|
||||
result[2] = new ByteArrayInputStream(getBase64(path));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,19 +14,19 @@ import java.util.Map;
|
|||
|
||||
public class MQiTV extends Spider {
|
||||
|
||||
private static List<Config> configs;
|
||||
private List<Config> configs;
|
||||
|
||||
public static List<Config> getConfigs() {
|
||||
public List<Config> getConfigs() {
|
||||
return configs = configs == null ? new ArrayList<>() : configs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
configs = Config.arrayFrom(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String liveContent(String url) throws Exception {
|
||||
public String liveContent(String url) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Config config : getConfigs()) {
|
||||
if (config.getData().isEmpty()) continue;
|
||||
|
|
@ -34,22 +34,15 @@ public class MQiTV extends Spider {
|
|||
boolean hasPort = config.getUri().getPort() != -1;
|
||||
for (Data item : config.getData()) {
|
||||
String port = hasPort ? item.getPort() : "5003";
|
||||
String proxy = "proxy://do=mqitv&id=" + item.getId() + "&ip=" + config.getUrl() + "&playing=" + item.getPlaying() + "&port=" + port + "&type=m3u8";
|
||||
String proxy = Proxy.getUrl(siteKey, "&id=" + item.getId() + "&ip=" + config.getUrl() + "&playing=" + item.getPlaying() + "&port=" + port + "&type=m3u8");
|
||||
sb.append(item.getName()).append(",").append(proxy).append("\n");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static Config getConfig(String ip) {
|
||||
Config config = new Config(ip);
|
||||
int index = getConfigs().indexOf(config);
|
||||
if (index != -1) return getConfigs().get(index);
|
||||
else getConfigs().add(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static Object[] proxy(Map<String, String> params) {
|
||||
@Override
|
||||
public Object[] proxyLocal(Map<String, String> params) {
|
||||
String ip = params.get("ip");
|
||||
String port = params.get("port");
|
||||
String playing = params.get("playing");
|
||||
|
|
@ -62,13 +55,21 @@ public class MQiTV extends Spider {
|
|||
String id = params.get("id");
|
||||
String auth = config.getAuth(id, token);
|
||||
if (!"OK".equals(auth)) config.clear();
|
||||
if (!"OK".equals(auth)) return proxy(params);
|
||||
if (!"OK".equals(auth)) return proxyLocal(params);
|
||||
String m3u8 = config.getM3U8(id, token, port);
|
||||
return m3u8.isEmpty() ? get302(config.getPlayUrl(port, playing)) : get200(m3u8);
|
||||
}
|
||||
}
|
||||
|
||||
private static Object[] get302(String location) {
|
||||
private Config getConfig(String ip) {
|
||||
Config config = new Config(ip);
|
||||
int index = getConfigs().indexOf(config);
|
||||
if (index != -1) return getConfigs().get(index);
|
||||
else getConfigs().add(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
private Object[] get302(String location) {
|
||||
Map<String, String> header = new HashMap<>();
|
||||
header.put("Location", location);
|
||||
Object[] result = new Object[4];
|
||||
|
|
@ -79,7 +80,7 @@ public class MQiTV extends Spider {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static Object[] get200(String m3u8) {
|
||||
private Object[] get200(String m3u8) {
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "application/vnd.apple.mpegurl";
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.github.catvod.utils.Util;
|
|||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -30,22 +31,22 @@ public class Market extends Spider {
|
|||
private List<Data> datas;
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
if (extend.startsWith("http")) extend = OkHttp.string(extend);
|
||||
datas = Data.arrayFrom(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
List<Class> classes = new ArrayList<>();
|
||||
if (datas.size() > 1) for (int i = 1; i < datas.size(); i++) classes.add(datas.get(i).type());
|
||||
return Result.string(classes, datas.get(0).getVod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
for (Data data : datas) if (data.getName().equals(tid)) return Result.get().page().vod(data.getVod()).string();
|
||||
return super.categoryContent(tid, pg, filter, extend);
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -67,7 +68,7 @@ public class Market extends Spider {
|
|||
}
|
||||
}
|
||||
|
||||
private void download(File file, InputStream is) throws Exception {
|
||||
private void download(File file, InputStream is) throws IOException {
|
||||
try (BufferedInputStream input = new BufferedInputStream(is); FileOutputStream os = new FileOutputStream(file)) {
|
||||
byte[] buffer = new byte[16384];
|
||||
int readBytes;
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ public class PTT extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
this.extend = extend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
Document doc = Jsoup.parse(OkHttp.string(url, getHeader()));
|
||||
List<Class> classes = new ArrayList<>();
|
||||
for (Element a : doc.select("li > a.px-2.px-sm-3.py-2.nav-link")) classes.add(new Class(a.attr("href").replace("/p/", ""), a.text()));
|
||||
|
|
@ -51,7 +51,7 @@ public class PTT extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
Uri.Builder builder = Uri.parse(url + "p/" + tid).buildUpon();
|
||||
if (!TextUtils.isEmpty(extend.get("c"))) builder.appendEncodedPath("c/" + extend.get("c"));
|
||||
if (!TextUtils.isEmpty(extend.get("area"))) builder.appendQueryParameter("area_id", extend.get("area"));
|
||||
|
|
@ -72,7 +72,7 @@ public class PTT extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) {
|
||||
Document doc = Jsoup.parse(OkHttp.string(url + ids.get(0) + "/1", getHeader()));
|
||||
LinkedHashMap<String, String> flags = new LinkedHashMap<>();
|
||||
List<String> playUrls = new ArrayList<>();
|
||||
|
|
@ -93,19 +93,19 @@ public class PTT extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
Matcher m = Pattern.compile("contentUrl\":\"(.*?)\"").matcher(OkHttp.string(url + id));
|
||||
if (m.find()) return Result.get().url(m.group(1).replace("\\", "")).string();
|
||||
return Result.error("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) throws Exception {
|
||||
public String searchContent(String key, boolean quick) {
|
||||
return searchContent(key, quick, "1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
||||
public String searchContent(String key, boolean quick, String pg) {
|
||||
Document doc = Jsoup.parse(OkHttp.string(url + String.format("q/%s?page=%s", key, pg), getHeader()));
|
||||
List<Vod> list = new ArrayList<>();
|
||||
for (Element div : doc.select("div.card > div.embed-responsive")) {
|
||||
|
|
|
|||
|
|
@ -14,20 +14,12 @@ public class Proxy {
|
|||
private static int port;
|
||||
|
||||
public static Object[] proxy(Map<String, String> params) throws Exception {
|
||||
switch (params.get("do")) {
|
||||
case "ck":
|
||||
return new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream("ok".getBytes(StandardCharsets.UTF_8))};
|
||||
case "mqitv":
|
||||
return MQiTV.proxy(params);
|
||||
case "bili":
|
||||
return Bili.proxy(params);
|
||||
case "webdav":
|
||||
return WebDAV.vod(params);
|
||||
case "local":
|
||||
return Local.proxy(params);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (params.get("do")) {
|
||||
case "ck" -> new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream("ok".getBytes(StandardCharsets.UTF_8))};
|
||||
case "bili" -> Bili.proxy(params);
|
||||
case "webdav" -> WebDAV.vod(params);
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
|
@ -45,6 +37,10 @@ public class Proxy {
|
|||
return port;
|
||||
}
|
||||
|
||||
public static String getUrl(String siteKey, String param) {
|
||||
return "proxy://do=csp&siteKey=" + siteKey + param;
|
||||
}
|
||||
|
||||
public static String getUrl() {
|
||||
return getUrl(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
public class Push extends Spider {
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) {
|
||||
return Result.string(vod(ids.get(0)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class WebDAV extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
List<Class> classes = new ArrayList<>();
|
||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||
for (Drive drive : drives) classes.add(drive.toType());
|
||||
|
|
@ -75,7 +75,7 @@ public class WebDAV extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws IOException {
|
||||
String key = tid.contains("/") ? tid.substring(0, tid.indexOf("/")) : tid;
|
||||
String path = tid.contains("/") ? tid.substring(tid.indexOf("/")) : "";
|
||||
String order = extend.containsKey("order") ? extend.get("order") : "";
|
||||
|
|
@ -98,7 +98,7 @@ public class WebDAV extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) throws IOException {
|
||||
String id = ids.get(0);
|
||||
String key = id.contains("/") ? id.substring(0, id.indexOf("/")) : id;
|
||||
String parent = id.substring(0, id.lastIndexOf("/"));
|
||||
|
|
@ -124,12 +124,12 @@ public class WebDAV extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
String[] ids = id.split("~~~");
|
||||
return Result.get().url(getProxyUrl(ids[0])).subs(getSub(ids)).string();
|
||||
}
|
||||
|
||||
private List<DavResource> getList(Drive drive, String path, List<String> ext) throws Exception {
|
||||
private List<DavResource> getList(Drive drive, String path, List<String> ext) throws IOException {
|
||||
path = drive.getHost() + (path.startsWith(drive.getPath()) ? path : drive.getPath() + path);
|
||||
List<DavResource> items = drive.getWebdav().list(path);
|
||||
items.remove(0); //Remove parent
|
||||
|
|
@ -150,13 +150,13 @@ public class WebDAV extends Spider {
|
|||
|
||||
private String findSubs(Drive drive, DavResource res, List<DavResource> items) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (DavResource item : items) if (removeExt(item).equals(removeExt(res))) sb.append("~~~").append(item.getName()).append("@@@").append(getExt(item)).append("@@@").append(drive.getName() + item.getPath());
|
||||
return sb.length() > 0 ? sb.toString() : findSubs(drive, items);
|
||||
for (DavResource item : items) if (removeExt(item).equals(removeExt(res))) sb.append("~~~").append(item.getName()).append("@@@").append(getExt(item)).append("@@@").append(drive.getName()).append(item.getPath());
|
||||
return !sb.isEmpty() ? sb.toString() : findSubs(drive, items);
|
||||
}
|
||||
|
||||
private String findSubs(Drive drive, List<DavResource> items) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (DavResource item : items) sb.append("~~~").append(item.getName()).append("@@@").append(getExt(item)).append("@@@").append(drive.getName() + item.getPath());
|
||||
for (DavResource item : items) sb.append("~~~").append(item.getName()).append("@@@").append(getExt(item)).append("@@@").append(drive.getName()).append(item.getPath());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class XtreamCode extends Spider {
|
|||
private Config config;
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
config = Config.objectFrom(extend);
|
||||
groups = new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.github.catvod.net.OkHttp;
|
|||
import com.github.catvod.utils.Crypto;
|
||||
import com.github.catvod.utils.Util;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -44,12 +45,12 @@ public class YHDM extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
public void init(Context context, String extend) {
|
||||
if (!extend.isEmpty()) siteUrl = extend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String homeContent(boolean filter) throws Exception {
|
||||
public String homeContent(boolean filter) {
|
||||
List<Class> classes = new ArrayList<>();
|
||||
List<String> typeIds = Arrays.asList("guochandongman", "ribendongman", "dongmandianying", "omeidongman");
|
||||
List<String> typeNames = Arrays.asList("国产动漫", "日本动漫", "动漫电影", "欧美动漫");
|
||||
|
|
@ -68,7 +69,7 @@ public class YHDM extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||
String cateUrl = siteUrl + String.format("/type/%s-%s.html", tid, pg);
|
||||
Document doc = Jsoup.parse(OkHttp.string(cateUrl, getHeader()));
|
||||
List<Vod> list = new ArrayList<>();
|
||||
|
|
@ -84,7 +85,7 @@ public class YHDM extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
public String detailContent(List<String> ids) {
|
||||
String detailUrl = siteUrl + ids.get(0);
|
||||
Document doc = Jsoup.parse(OkHttp.string(detailUrl, getHeader()));
|
||||
Elements sources = doc.select(".myui-content__list.sort-list");
|
||||
|
|
@ -123,7 +124,7 @@ public class YHDM extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) throws Exception {
|
||||
public String searchContent(String key, boolean quick) {
|
||||
String searchUrl = siteUrl + "/search/" + Uri.encode(key) + "-------------.html";
|
||||
Document doc = Jsoup.parse(OkHttp.string(searchUrl, getHeader()));
|
||||
List<Vod> list = new ArrayList<>();
|
||||
|
|
@ -139,7 +140,7 @@ public class YHDM extends Spider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws JSONException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
|
||||
String todayDate = dateFormat.format(new Date());
|
||||
String ConfigUrl = siteUrl + "/static/js/playerconfig.js?t=" + todayDate;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'ru.cleverpumpkin.proguard-dictionaries-generator' version '1.0.8' apply false
|
||||
id 'com.android.application' version '8.13.0' apply false
|
||||
|
|
@ -10,5 +9,5 @@ tasks.register('clean', Delete) {
|
|||
}
|
||||
|
||||
project.ext {
|
||||
okhttpVersion = '5.2.1'
|
||||
okhttpVersion = '5.3.1'
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
c77efde41ebab1daf37308a1153d3f85
|
||||
a460452b3a982dc9f4cf82e75b09391b
|
||||
|
|
|
|||
Loading…
Reference in New Issue