Update
This commit is contained in:
parent
258bb9bdc7
commit
2fd1ffc00f
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.github.catvod.bean.yiso;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Item {
|
||||||
|
|
||||||
|
@SerializedName("data")
|
||||||
|
private DataDTO data;
|
||||||
|
|
||||||
|
public static Item objectFrom(String str) {
|
||||||
|
try {
|
||||||
|
return new Gson().fromJson(str, Item.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new Item();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataDTO getData() {
|
||||||
|
return data == null ? new DataDTO() : data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DataDTO {
|
||||||
|
|
||||||
|
@SerializedName("list")
|
||||||
|
private List<ListDTO> list;
|
||||||
|
|
||||||
|
public List<Vod> getList() {
|
||||||
|
List<Vod> items = new ArrayList<>();
|
||||||
|
list = list == null ? Collections.emptyList() : list;
|
||||||
|
for (ListDTO item : list) items.add(item.getVod());
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ListDTO {
|
||||||
|
|
||||||
|
@SerializedName("url")
|
||||||
|
private String url;
|
||||||
|
@SerializedName("gmtCreate")
|
||||||
|
private String gmtCreate;
|
||||||
|
@SerializedName("fileInfos")
|
||||||
|
private List<FileInfoDTO> fileInfos;
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtCreate() {
|
||||||
|
return gmtCreate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FileInfoDTO> getFileInfos() {
|
||||||
|
return fileInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vod getVod() {
|
||||||
|
String id = getUrl();
|
||||||
|
String name = getFileInfos().get(0).getFileName();
|
||||||
|
String remark = getGmtCreate();
|
||||||
|
String pic = "https://inews.gtimg.com/newsapp_bt/0/13263837859/1000";
|
||||||
|
return new Vod(id, name, pic, remark);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FileInfoDTO {
|
||||||
|
|
||||||
|
@SerializedName("fileName")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Alist extends Spider {
|
public class AList extends Spider {
|
||||||
|
|
||||||
private Map<String, String> map;
|
private Map<String, String> map;
|
||||||
private JSONObject ext;
|
private JSONObject ext;
|
||||||
|
|
@ -0,0 +1,285 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Result;
|
||||||
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.net.OkHttpUtil;
|
||||||
|
import com.github.catvod.utils.Misc;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ColaMint & Adam & FongMi
|
||||||
|
*/
|
||||||
|
public class Ali {
|
||||||
|
|
||||||
|
private final Pattern pattern = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
|
||||||
|
private static String accessToken;
|
||||||
|
private String refreshToken;
|
||||||
|
|
||||||
|
public Ali(String token) {
|
||||||
|
checkToken(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkToken(String token) {
|
||||||
|
if (TextUtils.isEmpty(token)) Init.show("尚未設定阿里Token");
|
||||||
|
refreshToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashMap<String, String> getHeaders() {
|
||||||
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("User-Agent", Misc.CHROME);
|
||||||
|
headers.put("Referer", "https://www.aliyundrive.com/");
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashMap<String, String> getHeaders(String shareToken) {
|
||||||
|
HashMap<String, String> headers = getHeaders();
|
||||||
|
if (accessToken != null) headers.put("authorization", accessToken);
|
||||||
|
headers.put("x-share-token", shareToken);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String post(String url, JSONObject body) {
|
||||||
|
return OkHttpUtil.postJson("https://api.aliyundrive.com/" + url, body.toString(), getHeaders());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String post(String url, JSONObject body, String shareToken) {
|
||||||
|
return OkHttpUtil.postJson("https://api.aliyundrive.com/" + url, body.toString(), getHeaders(shareToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
|
String url = ids.get(0).trim();
|
||||||
|
Matcher matcher = pattern.matcher(url);
|
||||||
|
if (matcher.find()) return Result.string(getVod(matcher, url));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String playerContent(String flag, String id) {
|
||||||
|
String[] ids = id.split("\\+");
|
||||||
|
String shareId = ids[0];
|
||||||
|
String shareToken = ids[1];
|
||||||
|
String fileId = ids[2];
|
||||||
|
String sub = getSub(shareId, shareToken, ids);
|
||||||
|
refreshAccessToken();
|
||||||
|
if (TextUtils.isEmpty(accessToken)) return "";
|
||||||
|
if (flag.contains("原畫")) {
|
||||||
|
return Result.get().url(getDownloadUrl(shareId, shareToken, fileId)).sub(sub).header(getHeaders()).string();
|
||||||
|
} else {
|
||||||
|
return Result.get().url(getPreviewUrl(shareId, shareToken, fileId)).sub(sub).header(getHeaders()).string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vod getVod(Matcher matcher, String url) throws Exception {
|
||||||
|
String shareId = matcher.group(1);
|
||||||
|
String shareToken = getShareToken(shareId);
|
||||||
|
String fileId = matcher.groupCount() == 3 ? matcher.group(3) : "";
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("share_id", shareId);
|
||||||
|
String json = post("adrive/v3/share_link/get_share_by_anonymous", body);
|
||||||
|
JSONObject object = new JSONObject(json);
|
||||||
|
Map<String, String> name2id = new HashMap<>();
|
||||||
|
Map<String, List<String>> subMap = new HashMap<>();
|
||||||
|
listFiles(0, name2id, subMap, shareId, shareToken, getParentFileId(fileId, object));
|
||||||
|
List<String> playUrls = new ArrayList<>();
|
||||||
|
List<String> names = new ArrayList<>(name2id.keySet());
|
||||||
|
Collections.sort(names);
|
||||||
|
for (String name : names) playUrls.add(name + "$" + name2id.get(name) + findSubs(name, subMap));
|
||||||
|
List<String> sourceUrls = new ArrayList<>();
|
||||||
|
sourceUrls.add(TextUtils.join("#", playUrls));
|
||||||
|
sourceUrls.add(TextUtils.join("#", playUrls));
|
||||||
|
Vod vod = new Vod();
|
||||||
|
vod.setVodId(url);
|
||||||
|
vod.setVodContent(url);
|
||||||
|
vod.setVodPic(object.getString("avatar"));
|
||||||
|
vod.setVodName(object.getString("share_name"));
|
||||||
|
vod.setVodPlayUrl(TextUtils.join("$$$", sourceUrls));
|
||||||
|
vod.setVodPlayFrom("AliYun$$$AliYun原畫");
|
||||||
|
vod.setTypeName("阿里雲盤");
|
||||||
|
return vod;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listFiles(int level, Map<String, String> name2id, Map<String, List<String>> subMap, String shareId, String shareToken, String parentFileId) throws Exception {
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("marker", "");
|
||||||
|
body.put("limit", 200);
|
||||||
|
body.put("share_id", shareId);
|
||||||
|
body.put("parent_file_id", parentFileId);
|
||||||
|
body.put("order_by", "updated_at");
|
||||||
|
body.put("order_direction", "DESC");
|
||||||
|
body.put("image_url_process", "image/resize,w_1920/format,jpeg");
|
||||||
|
body.put("image_thumbnail_process", "image/resize,w_160/format,jpeg");
|
||||||
|
body.put("video_thumbnail_process", "video/snapshot,t_1000,f_jpg,ar_auto,w_300");
|
||||||
|
String json = post("adrive/v3/file/list", body, shareToken);
|
||||||
|
JSONArray items = new JSONObject(json).getJSONArray("items");
|
||||||
|
List<String> folders = new ArrayList<>();
|
||||||
|
for (int j = 0; j < items.length(); ++j) {
|
||||||
|
JSONObject item = items.getJSONObject(j);
|
||||||
|
String type = item.optString("type");
|
||||||
|
String name = item.optString("name");
|
||||||
|
String fileId = item.optString("file_id");
|
||||||
|
String category = item.optString("category", "");
|
||||||
|
String ext = item.optString("file_extension", "");
|
||||||
|
if (type.equals("folder")) {
|
||||||
|
folders.add(fileId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (category.equals("video")) {
|
||||||
|
name2id.put(name, shareId + "+" + shareToken + "+" + fileId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isSubFile(ext)) {
|
||||||
|
name = name.replace("." + ext, "");
|
||||||
|
if (!subMap.containsKey(name)) subMap.put(name, new ArrayList<>());
|
||||||
|
Objects.requireNonNull(subMap.get(name)).add(name + "@" + fileId + "@" + ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String folder : folders) {
|
||||||
|
if (level == 2) break;
|
||||||
|
listFiles(++level, name2id, subMap, shareId, shareToken, folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getParentFileId(String fileId, JSONObject shareInfo) throws Exception {
|
||||||
|
JSONArray array = shareInfo.getJSONArray("file_infos");
|
||||||
|
if (!TextUtils.isEmpty(fileId)) return fileId;
|
||||||
|
if (array.length() == 0) return "";
|
||||||
|
JSONObject fileInfo = array.getJSONObject(0);
|
||||||
|
if (fileInfo.getString("type").equals("folder")) return fileInfo.getString("file_id");
|
||||||
|
if (fileInfo.getString("type").equals("file") && fileInfo.getString("category").equals("video")) return "root";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshAccessToken() {
|
||||||
|
try {
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("refresh_token", refreshToken);
|
||||||
|
JSONObject object = new JSONObject(post("token/refresh", body));
|
||||||
|
accessToken = object.getString("token_type") + " " + object.getString("access_token");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Init.show("阿里Token已失效");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findSubs(String name, Map<String, List<String>> subMap) {
|
||||||
|
name = name.substring(0, name.lastIndexOf("."));
|
||||||
|
List<String> subs = subMap.get(name);
|
||||||
|
if (subs != null && subs.size() > 0) return combineSubs(subs);
|
||||||
|
for (Map.Entry<String, List<String>> entry : subMap.entrySet()) if (entry.getKey().contains(name)) return combineSubs(entry.getValue());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String combineSubs(List<String> subs) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String sub : subs) sb.append("+").append(sub);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSub(String shareId, String shareToken, String[] ids) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String text : ids) {
|
||||||
|
if (!text.contains("@")) continue;
|
||||||
|
String[] arr = text.split("@");
|
||||||
|
String url = Proxy.getUrl() + "?do=ali&type=sub&share_id=" + shareId + "&share_token=" + shareToken + "&file_id=" + arr[1];
|
||||||
|
sb.append(arr[0]).append("#").append(getSubMimeType(arr[2])).append("#").append(url).append("$$$");
|
||||||
|
return Misc.substring(sb.toString(), 3);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSubFile(String ext) {
|
||||||
|
return ext.equals("srt") || ext.equals("ass") || ext.equals("ssa");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSubMimeType(String type) {
|
||||||
|
if (type.equals("srt")) return "application/x-subrip";
|
||||||
|
if (type.equals("ass") || type.equals("ssa")) return "text/x-ssa";
|
||||||
|
return "application/x-subrip";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getShareToken(String shareId) {
|
||||||
|
try {
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("share_id", shareId);
|
||||||
|
body.put("share_pwd", "");
|
||||||
|
String json = post("v2/share_link/get_share_token", body);
|
||||||
|
return new JSONObject(json).getString("share_token");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPreviewQuality(JSONArray taskList) throws Exception {
|
||||||
|
for (String templateId : Arrays.asList("UHD", "QHD", "FHD", "HD", "SD", "LD")) {
|
||||||
|
for (int i = 0; i < taskList.length(); ++i) {
|
||||||
|
JSONObject task = taskList.getJSONObject(i);
|
||||||
|
if (task.getString("template_id").equals(templateId)) {
|
||||||
|
return task.getString("url");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return taskList.getJSONObject(0).getString("url");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPreviewUrl(String shareId, String shareToken, String fileId) {
|
||||||
|
try {
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("file_id", fileId);
|
||||||
|
body.put("share_id", shareId);
|
||||||
|
body.put("template_id", "");
|
||||||
|
body.put("category", "live_transcoding");
|
||||||
|
String json = post("v2/file/get_share_link_video_preview_play_info", body, shareToken);
|
||||||
|
JSONArray taskList = new JSONObject(json).getJSONObject("video_preview_play_info").getJSONArray("live_transcoding_task_list");
|
||||||
|
Map<String, List<String>> respHeaders = new HashMap<>();
|
||||||
|
OkHttpUtil.stringNoRedirect(getPreviewQuality(taskList), getHeaders(), respHeaders);
|
||||||
|
return respHeaders.get("location").get(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getDownloadUrl(String shareId, String shareToken, String fileId) {
|
||||||
|
try {
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("file_id", fileId);
|
||||||
|
body.put("share_id", shareId);
|
||||||
|
String json = post("v2/file/get_share_link_download_url", body, shareToken);
|
||||||
|
String url = new JSONObject(json).optString("download_url");
|
||||||
|
Map<String, List<String>> respHeaders = new HashMap<>();
|
||||||
|
OkHttpUtil.stringNoRedirect(url, getHeaders(), respHeaders);
|
||||||
|
return respHeaders.get("location").get(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object[] vod(Map<String, String> params) {
|
||||||
|
String shareId = params.get("share_id");
|
||||||
|
String shareToken = params.get("share_token");
|
||||||
|
String fileId = params.get("file_id");
|
||||||
|
String text = OkHttpUtil.string(getDownloadUrl(shareId, shareToken, fileId), getHeaders(shareToken));
|
||||||
|
Object[] result = new Object[3];
|
||||||
|
result[0] = 200;
|
||||||
|
result[1] = "application/octet-stream";
|
||||||
|
result[2] = new ByteArrayInputStream(text.getBytes());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.github.catvod.spider;
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
@ -9,6 +10,9 @@ import android.widget.Toast;
|
||||||
import com.github.catvod.crawler.SpiderDebug;
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
import com.github.catvod.utils.Trans;
|
import com.github.catvod.utils.Trans;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Init {
|
public class Init {
|
||||||
|
|
||||||
private final Handler handler;
|
private final Handler handler;
|
||||||
|
|
@ -36,7 +40,36 @@ public class Init {
|
||||||
Trans.init();
|
Trans.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void run(Runnable runnable) {
|
||||||
|
get().handler.post(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
public static void show(String msg) {
|
public static void show(String msg) {
|
||||||
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_SHORT).show());
|
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_SHORT).show());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Activity getActivity() {
|
||||||
|
try {
|
||||||
|
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
||||||
|
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
||||||
|
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
|
||||||
|
activitiesField.setAccessible(true);
|
||||||
|
Map<?, ?> activities = (Map<?, ?>) activitiesField.get(activityThread);
|
||||||
|
for (Object activityRecord : activities.values()) {
|
||||||
|
Class<?> activityRecordClass = activityRecord.getClass();
|
||||||
|
Field pausedField = activityRecordClass.getDeclaredField("paused");
|
||||||
|
pausedField.setAccessible(true);
|
||||||
|
if (!pausedField.getBoolean(activityRecord)) {
|
||||||
|
Field activityField = activityRecordClass.getDeclaredField("activity");
|
||||||
|
activityField.setAccessible(true);
|
||||||
|
Activity activity = (Activity) activityField.get(activityRecord);
|
||||||
|
SpiderDebug.log(activity.getComponentName().getClassName());
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Result;
|
||||||
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.crawler.Spider;
|
||||||
|
import com.github.catvod.net.OkHttpUtil;
|
||||||
|
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ColaMint & FongMi
|
||||||
|
*/
|
||||||
|
public class PanSou extends Spider {
|
||||||
|
|
||||||
|
private final Pattern regexAliUrl = Pattern.compile("(https:\\/\\/www.aliyundrive.com\\/s\\/[^\\\"]+)");
|
||||||
|
private final String siteUrl = "https://www.alipansou.com";
|
||||||
|
private Ali ali;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context, String extend) {
|
||||||
|
ali = new Ali(extend);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
|
String url = ids.get(0);
|
||||||
|
Matcher matcher = regexAliUrl.matcher(url);
|
||||||
|
if (matcher.find()) return ali.detailContent(ids);
|
||||||
|
url = siteUrl + ids.get(0);
|
||||||
|
String html = OkHttpUtil.string(url);
|
||||||
|
matcher = regexAliUrl.matcher(html);
|
||||||
|
if (!matcher.find()) return "";
|
||||||
|
ids.set(0, matcher.group(1).replace("\\/", "/"));
|
||||||
|
return ali.detailContent(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String searchContent(String key, boolean quick) {
|
||||||
|
Map<String, String> types = new HashMap<>();
|
||||||
|
types.put("7", "資料夾");
|
||||||
|
types.put("1", "影片");
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, String> entry : types.entrySet()) {
|
||||||
|
String typeId = entry.getKey();
|
||||||
|
String typeName = entry.getValue();
|
||||||
|
String url = siteUrl + "/search?k=" + URLEncoder.encode(key) + "&t=" + typeId;
|
||||||
|
Elements items = Jsoup.parse(OkHttpUtil.string(url)).select("van-row > a");
|
||||||
|
for (Element item : items) {
|
||||||
|
String title = item.selectFirst("template").text().trim();
|
||||||
|
if (!title.contains(key)) continue;
|
||||||
|
Vod vod = new Vod();
|
||||||
|
vod.setVodId(item.attr("href"));
|
||||||
|
vod.setVodName("[" + typeName + "] " + title);
|
||||||
|
vod.setVodPic("https://inews.gtimg.com/newsapp_bt/0/13263837859/1000");
|
||||||
|
list.add(vod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.string(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
|
return ali.playerContent(flag, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Class;
|
||||||
|
import com.github.catvod.bean.Filter;
|
||||||
|
import com.github.catvod.bean.Result;
|
||||||
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.bean.paper.Data;
|
||||||
|
import com.github.catvod.bean.paper.Item;
|
||||||
|
import com.github.catvod.crawler.Spider;
|
||||||
|
import com.github.catvod.net.OkHttpUtil;
|
||||||
|
import com.github.catvod.utils.Misc;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
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.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ColaMint & FongMi
|
||||||
|
*/
|
||||||
|
public class Paper extends Spider {
|
||||||
|
|
||||||
|
private List<String> types;
|
||||||
|
private List<Data> all;
|
||||||
|
private Ali ali;
|
||||||
|
|
||||||
|
private HashMap<String, String> getHeaders() {
|
||||||
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("User-Agent", Misc.CHROME);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Data> getAll() {
|
||||||
|
return all = all != null ? all : Item.objectFrom(OkHttpUtil.string("https://gitcafe.net/alipaper/all.json", getHeaders())).getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context, String extend) {
|
||||||
|
types = new ArrayList<>();
|
||||||
|
ali = new Ali(extend);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String homeContent(boolean filter) throws JSONException {
|
||||||
|
Document doc = Jsoup.parse(OkHttpUtil.string("https://u.gitcafe.net/", getHeaders()));
|
||||||
|
Elements trs = doc.select("table.tableizer-table > tbody > tr");
|
||||||
|
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||||
|
List<Class> classes = new ArrayList<>();
|
||||||
|
for (Element tr : trs) {
|
||||||
|
if (tr.text().contains("音乐")) break;
|
||||||
|
List<Filter.Value> values = new ArrayList<>();
|
||||||
|
for (Element td : tr.select("td")) {
|
||||||
|
if (td.hasClass("tableizer-title")) {
|
||||||
|
String typeId = td.select("a").attr("href").replace("#", "");
|
||||||
|
classes.add(new Class(typeId, td.text()));
|
||||||
|
filters.put(typeId, Arrays.asList(new Filter("type", "類型", values)));
|
||||||
|
} else {
|
||||||
|
String value = td.select("a").attr("onclick").split("'")[1];
|
||||||
|
values.add(new Filter.Value(td.text(), value));
|
||||||
|
types.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
|
JSONObject homeData = new JSONObject(OkHttpUtil.string("https://gitcafe.net/alipaper/home.json", getHeaders()));
|
||||||
|
List<Data> items = Data.arrayFrom(homeData.getJSONObject("info").getJSONArray("new").toString());
|
||||||
|
for (Data item : items) if (types.contains(item.getCat())) list.add(item.getVod());
|
||||||
|
return Result.string(classes, list, filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
|
String type = extend.containsKey("type") ? extend.get("type") : tid;
|
||||||
|
List<Data> items = Data.arrayFrom(OkHttpUtil.string("https://gitcafe.net/alipaper/data/" + type + ".json", getHeaders()));
|
||||||
|
for (Data item : items) list.add(item.getVod());
|
||||||
|
return Result.string(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
|
return ali.detailContent(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String searchContent(String key, boolean quick) {
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
|
for (Data item : getAll()) if (types.contains(item.getCat()) && item.getTitle().contains(key)) list.add(item.getVod());
|
||||||
|
return Result.string(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||||
|
return ali.playerContent(flag, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,6 +22,8 @@ public class Proxy extends Spider {
|
||||||
return new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream("ok".getBytes(StandardCharsets.UTF_8))};
|
return new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream("ok".getBytes(StandardCharsets.UTF_8))};
|
||||||
case "live":
|
case "live":
|
||||||
return TxtSubscribe.load(new String(Base64.decode(params.get("ext"), Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP), StandardCharsets.UTF_8));
|
return TxtSubscribe.load(new String(Base64.decode(params.get("ext"), Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP), StandardCharsets.UTF_8));
|
||||||
|
case "ali":
|
||||||
|
return Ali.vod(params);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.github.catvod.spider;
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
|
|
@ -9,9 +11,17 @@ import java.util.List;
|
||||||
|
|
||||||
public class Push extends Spider {
|
public class Push extends Spider {
|
||||||
|
|
||||||
|
private Ali ali;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String detailContent(List<String> ids) {
|
public void init(Context context, String extend) {
|
||||||
|
ali = new Ali(extend);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
String url = ids.get(0).trim();
|
String url = ids.get(0).trim();
|
||||||
|
if (url.contains("aliyundrive")) return ali.detailContent(ids);
|
||||||
if (Misc.isVip(url)) return Result.string(vod(url, "官源"));
|
if (Misc.isVip(url)) return Result.string(vod(url, "官源"));
|
||||||
else if (Misc.isVideoFormat(url)) return Result.string(vod(url, "直連"));
|
else if (Misc.isVideoFormat(url)) return Result.string(vod(url, "直連"));
|
||||||
else if (url.startsWith("magnet")) return Result.string(vod(url, "磁力"));
|
else if (url.startsWith("magnet")) return Result.string(vod(url, "磁力"));
|
||||||
|
|
@ -21,14 +31,11 @@ public class Push extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
if (flag.equals("官源")) {
|
if (flag.contains("AliYun")) return ali.playerContent(flag, id);
|
||||||
return Result.get().parse().jx().url(id).string();
|
if (flag.equals("官源")) return Result.get().parse().jx().url(id).string();
|
||||||
} else if (flag.equals("直連")) {
|
if (flag.equals("直連")) return Result.get().url(id).string();
|
||||||
return Result.get().url(id).string();
|
|
||||||
} else {
|
|
||||||
return Result.get().parse().url(id).string();
|
return Result.get().parse().url(id).string();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private Vod vod(String url, String type) {
|
private Vod vod(String url, String type) {
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Result;
|
||||||
|
import com.github.catvod.bean.yiso.Item;
|
||||||
|
import com.github.catvod.crawler.Spider;
|
||||||
|
import com.github.catvod.utils.Misc;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class YiSo extends Spider {
|
||||||
|
|
||||||
|
private Ali ali;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context, String extend) {
|
||||||
|
ali = new Ali(extend);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
|
return ali.detailContent(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||||
|
return ali.playerContent(flag, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String searchContent(String key, boolean quick) {
|
||||||
|
String url = "https://yiso.fun/api/search?name=" + URLEncoder.encode(key) + "&from=ali";
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
|
Misc.loadWebView(url, getWebViewClient(result));
|
||||||
|
while (!result.containsKey("json")) SystemClock.sleep(250);
|
||||||
|
String json = JsonParser.parseString(Objects.requireNonNull(result.get("json"))).getAsJsonPrimitive().getAsString();
|
||||||
|
return Result.string(Item.objectFrom(json).getData().getList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private WebViewClient getWebViewClient(Map<String, String> result) {
|
||||||
|
return new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
view.evaluateJavascript("document.getElementsByTagName('pre')[0].textContent", value -> {
|
||||||
|
if (!value.equals("null")) result.put("json", value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
package com.github.catvod.utils;
|
package com.github.catvod.utils;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import com.github.catvod.crawler.SpiderDebug;
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
|
import com.github.catvod.spider.Init;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
@ -17,7 +21,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Misc {
|
public class Misc {
|
||||||
|
|
||||||
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.62 Safari/537.36";
|
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36";
|
||||||
private static final Pattern SNIFFER = Pattern.compile("http((?!http).){20,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)\\?.*|http((?!http).){20,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)|http((?!http).){20,}?\\/m3u8\\?pt=m3u8.*|http((?!http).)*?default\\.ixigua\\.com\\/.*|http((?!http).)*?cdn-tos[^\\?]*|http((?!http).)*?\\/obj\\/tos[^\\?]*|http.*?\\/player\\/m3u8play\\.php\\?url=.*|http.*?\\/player\\/.*?[pP]lay\\.php\\?url=.*|http.*?\\/playlist\\/m3u8\\/\\?vid=.*|http.*?\\.php\\?type=m3u8&.*|http.*?\\/download.aspx\\?.*|http.*?\\/api\\/up_api.php\\?.*|https.*?\\.66yk\\.cn.*|http((?!http).)*?netease\\.com\\/file\\/.*");
|
private static final Pattern SNIFFER = Pattern.compile("http((?!http).){20,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)\\?.*|http((?!http).){20,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)|http((?!http).){20,}?\\/m3u8\\?pt=m3u8.*|http((?!http).)*?default\\.ixigua\\.com\\/.*|http((?!http).)*?cdn-tos[^\\?]*|http((?!http).)*?\\/obj\\/tos[^\\?]*|http.*?\\/player\\/m3u8play\\.php\\?url=.*|http.*?\\/player\\/.*?[pP]lay\\.php\\?url=.*|http.*?\\/playlist\\/m3u8\\/\\?vid=.*|http.*?\\.php\\?type=m3u8&.*|http.*?\\/download.aspx\\?.*|http.*?\\/api\\/up_api.php\\?.*|https.*?\\.66yk\\.cn.*|http((?!http).)*?netease\\.com\\/file\\/.*");
|
||||||
|
|
||||||
public static boolean isVip(String url) {
|
public static boolean isVip(String url) {
|
||||||
|
|
@ -45,8 +49,7 @@ public class Misc {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVideoFormat(String url) {
|
public static boolean isVideoFormat(String url) {
|
||||||
if (url.contains("=http") || url.contains("=https") || url.contains("=https%3a%2f") || url.contains("=http%3a%2f")) return false;
|
if (url.contains("=http") || url.contains("=https") || url.contains("=https%3a%2f") || url.contains("=http%3a%2f") || url.contains(".js") || url.contains(".css")) return false;
|
||||||
if (url.contains("cdn-tos") || url.contains(".js") || url.contains(".css") || url.contains(".ico")) return false;
|
|
||||||
return SNIFFER.matcher(url).find();
|
return SNIFFER.matcher(url).find();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,17 +69,16 @@ public class Misc {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JSONObject fixJsonVodHeader(JSONObject headers, String input, String url) throws JSONException {
|
public static JSONObject fixJsonVodHeader(JSONObject headers, String input, String url) throws JSONException {
|
||||||
if (headers == null)
|
if (headers == null) headers = new JSONObject();
|
||||||
headers = new JSONObject();
|
|
||||||
if (input.contains("www.mgtv.com")) {
|
if (input.contains("www.mgtv.com")) {
|
||||||
headers.put("Referer", " ");
|
headers.put("Referer", "");
|
||||||
headers.put("User-Agent", " Mozilla/5.0");
|
headers.put("User-Agent", "Mozilla/5.0");
|
||||||
} else if (url.contains("titan.mgtv")) {
|
} else if (url.contains("titan.mgtv")) {
|
||||||
headers.put("Referer", " ");
|
headers.put("Referer", "");
|
||||||
headers.put("User-Agent", " Mozilla/5.0");
|
headers.put("User-Agent", "Mozilla/5.0");
|
||||||
} else if (input.contains("bilibili")) {
|
} else if (input.contains("bilibili")) {
|
||||||
headers.put("Referer", " https://www.bilibili.com/");
|
headers.put("Referer", "https://www.bilibili.com/");
|
||||||
headers.put("User-Agent", " " + Misc.CHROME);
|
headers.put("User-Agent", Misc.CHROME);
|
||||||
}
|
}
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
@ -84,24 +86,14 @@ public class Misc {
|
||||||
public static JSONObject jsonParse(String input, String json) throws JSONException {
|
public static JSONObject jsonParse(String input, String json) throws JSONException {
|
||||||
JSONObject jsonPlayData = new JSONObject(json);
|
JSONObject jsonPlayData = new JSONObject(json);
|
||||||
String url = jsonPlayData.getString("url");
|
String url = jsonPlayData.getString("url");
|
||||||
if (url.startsWith("//")) {
|
if (url.startsWith("//")) url = "https:" + url;
|
||||||
url = "https:" + url;
|
if (!url.startsWith("http")) return null;
|
||||||
}
|
if (url.equals(input)) if (isVip(url) || !isVideoFormat(url)) return null;
|
||||||
if (!url.startsWith("http")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (url.equals(input)) {
|
|
||||||
if (isVip(url) || !isVideoFormat(url)) return null;
|
|
||||||
}
|
|
||||||
JSONObject headers = new JSONObject();
|
JSONObject headers = new JSONObject();
|
||||||
String ua = jsonPlayData.optString("user-agent", "");
|
String ua = jsonPlayData.optString("user-agent", "");
|
||||||
if (ua.trim().length() > 0) {
|
if (ua.trim().length() > 0) headers.put("User-Agent", ua);
|
||||||
headers.put("User-Agent", " " + ua);
|
|
||||||
}
|
|
||||||
String referer = jsonPlayData.optString("referer", "");
|
String referer = jsonPlayData.optString("referer", "");
|
||||||
if (referer.trim().length() > 0) {
|
if (referer.trim().length() > 0) headers.put("Referer", referer);
|
||||||
headers.put("Referer", " " + referer);
|
|
||||||
}
|
|
||||||
headers = Misc.fixJsonVodHeader(headers, input, url);
|
headers = Misc.fixJsonVodHeader(headers, input, url);
|
||||||
JSONObject taskResult = new JSONObject();
|
JSONObject taskResult = new JSONObject();
|
||||||
taskResult.put("header", headers);
|
taskResult.put("header", headers);
|
||||||
|
|
@ -145,4 +137,22 @@ public class Misc {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadWebView(String url) {
|
||||||
|
loadWebView(url, new WebViewClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadWebView(String url, WebViewClient client) {
|
||||||
|
Init.run(() -> {
|
||||||
|
WebView webView = new WebView(Init.context());
|
||||||
|
webView.getSettings().setDatabaseEnabled(true);
|
||||||
|
webView.getSettings().setDomStorageEnabled(true);
|
||||||
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
webView.setWebViewClient(client);
|
||||||
|
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(0, 0);
|
||||||
|
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||||
|
Init.getActivity().addContentView(webView, params);
|
||||||
|
webView.loadUrl(url);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
19211bffdfc96677d1eee804ff300a47
|
f913d30766882408e79b7316771dd011
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue