天意cookie
This commit is contained in:
parent
8fd0f3aff7
commit
a66f81807a
|
|
@ -50,6 +50,7 @@ public class TianYiHandler {
|
|||
cache = Cache.objectFrom(Path.read(getCache()));
|
||||
}
|
||||
|
||||
|
||||
public byte[] startScan() throws Exception {
|
||||
|
||||
OkResult okResult1 = OkHttp.get("https://ux.21cn.com/api/htmlReportRest/getJs.js?pid=25577E0DEEDF48ADBD4459911F5825E4", new HashMap<>(), new HashMap<>());
|
||||
|
|
@ -219,10 +220,11 @@ public class TianYiHandler {
|
|||
}
|
||||
cache.setTianyiUser(User.objectFrom(StringUtils.join(cookieList, ";")));
|
||||
SpiderDebug.log("获取cookie成功:" + StringUtils.join(cookieList, ";"));
|
||||
//停止检验线程,关闭弹窗
|
||||
stopService();
|
||||
}
|
||||
|
||||
//停止检验线程,关闭弹窗
|
||||
stopService();
|
||||
|
||||
/* if (okResult.getCode() == 200) {
|
||||
okResult.getBody();
|
||||
}*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,517 @@
|
|||
package com.github.catvod.api;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.bean.quark.Cache;
|
||||
import com.github.catvod.bean.tianyi.Item;
|
||||
import com.github.catvod.bean.tianyi.ShareData;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.net.OkResult;
|
||||
import com.github.catvod.spider.Init;
|
||||
import com.github.catvod.spider.Proxy;
|
||||
import com.github.catvod.utils.*;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TianyiApi {
|
||||
private String apiUrl = "https://cloud.189.cn/api/open/share/";
|
||||
public static final String URL_START = "https://cloud.189.cn/";
|
||||
private String cookie = "";
|
||||
private String ckey = "";
|
||||
private Map<String, JsonObject> shareTokenCache = new HashMap<>();
|
||||
private String pr = "pr=ucpro&fr=pc";
|
||||
private List<String> subtitleExts = Arrays.asList(".srt", ".ass", ".scc", ".stl", ".ttml");
|
||||
private Map<String, String> saveFileIdCaches = new HashMap<>();
|
||||
private String saveDirId = null;
|
||||
private String saveDirName = "TV";
|
||||
private boolean isVip = false;
|
||||
private final Cache cache;
|
||||
private ScheduledExecutorService service;
|
||||
private String sessionKey = "";
|
||||
private TianYiHandler tianYiHandler;
|
||||
|
||||
private AlertDialog dialog;
|
||||
private String serviceTicket;
|
||||
|
||||
public Object[] proxyVideo(Map<String, String> params) throws Exception {
|
||||
String url = Util.base64Decode(params.get("url"));
|
||||
Map header = new Gson().fromJson(Util.base64Decode(params.get("header")), Map.class);
|
||||
if (header == null) header = new HashMap<>();
|
||||
List<String> arr = List.of("Range", "Accept", "Accept-Encoding", "Accept-Language", "Cookie", "Origin", "Referer", "Sec-Ch-Ua", "Sec-Ch-Ua-Mobile", "Sec-Ch-Ua-Platform", "Sec-Fetch-Dest", "Sec-Fetch-Mode", "Sec-Fetch-Site", "User-Agent");
|
||||
for (String key : params.keySet()) {
|
||||
for (String s : arr) {
|
||||
if (s.toLowerCase().equals(key.toLowerCase())) {
|
||||
header.put(key, params.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (Util.getExt(url).contains("m3u8")) {
|
||||
return getM3u8(url, header);
|
||||
}
|
||||
return ProxyVideo.proxy(url, header);
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理m3u8
|
||||
*
|
||||
* @param url
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
private Object[] getM3u8(String url, Map header) {
|
||||
|
||||
OkResult result = OkHttp.get(url, new HashMap<>(), header);
|
||||
String[] m3u8Arr = result.getBody().split("\n");
|
||||
List<String> listM3u8 = new ArrayList<>();
|
||||
|
||||
String site = url.substring(0, url.lastIndexOf("/")) + "/";
|
||||
int mediaId = 0;
|
||||
for (String oneLine : m3u8Arr) {
|
||||
String thisOne = oneLine;
|
||||
if (oneLine.contains(".ts")) {
|
||||
thisOne = proxyVideoUrl(site + thisOne, header);
|
||||
mediaId++;
|
||||
}
|
||||
listM3u8.add(thisOne);
|
||||
}
|
||||
String m3u8Str = TextUtils.join("\n", listM3u8);
|
||||
String contentType = result.getResp().get("Content-Type").get(0);
|
||||
|
||||
Map<String, String> respHeaders = new HashMap<>();
|
||||
for (String key : result.getResp().keySet()) {
|
||||
respHeaders.put(key, result.getResp().get(key).get(0));
|
||||
}
|
||||
return new Object[]{result.getCode(), contentType, new ByteArrayInputStream(m3u8Str.getBytes(Charset.forName("UTF-8"))), respHeaders};
|
||||
}
|
||||
|
||||
public String[] getPlayFormatList() {
|
||||
return new String[]{"原画"};
|
||||
}
|
||||
|
||||
private static class Loader {
|
||||
static volatile TianyiApi INSTANCE = new TianyiApi();
|
||||
}
|
||||
|
||||
public static TianyiApi get() {
|
||||
return TianyiApi.Loader.INSTANCE;
|
||||
}
|
||||
|
||||
public void setCookie(String token) throws Exception {
|
||||
if (StringUtils.isNoneBlank(token)) {
|
||||
this.cookie = token;
|
||||
initUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> getHeaders() {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch");
|
||||
|
||||
headers.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
headers.put("accept", "application/json;charset=UTF-8");
|
||||
headers.put("Cookie", cookie);
|
||||
if (StringUtils.isNotBlank(sessionKey)) {
|
||||
headers.put("sessionKey", sessionKey);
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
||||
public void init(String cookie) throws Exception {
|
||||
this.ckey = Util.MD5(cookie);
|
||||
this.cookie = cookie;
|
||||
// this.isVip = getVip();
|
||||
getUserSizeInfo();
|
||||
this.sessionKey = getUserBriefInfo();
|
||||
}
|
||||
|
||||
private TianyiApi() {
|
||||
Init.checkPermission();
|
||||
cache = Cache.objectFrom(Path.read(getCache()));
|
||||
tianYiHandler = new TianYiHandler();
|
||||
}
|
||||
|
||||
public File getCache() {
|
||||
return Path.tv("tianyi");
|
||||
}
|
||||
|
||||
public Vod getVod(ShareData shareData) throws Exception {
|
||||
getShareToken(shareData);
|
||||
List<Item> files = new ArrayList<>();
|
||||
List<Item> subs = new ArrayList<>();
|
||||
try {
|
||||
JsonArray listData = listFile(1, shareData, files, subs, shareData.getShareId(), shareData.getFolderId(), 1);
|
||||
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log("资源已取消:" + e.getMessage());
|
||||
Notify.show("资源已取消");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
List<String> playFromtmp = new ArrayList<>();
|
||||
playFromtmp.add("天意");
|
||||
|
||||
|
||||
List<String> playUrl = new ArrayList<>();
|
||||
|
||||
if (files.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int index = 0; index < playFromtmp.size(); index++) {
|
||||
List<String> vodItems = new ArrayList<>();
|
||||
for (Item video_item : files) {
|
||||
vodItems.add(video_item.getEpisodeUrl("电影"));// + findSubs(video_item.getName(), subs));
|
||||
}
|
||||
playUrl.add(TextUtils.join("#", vodItems));
|
||||
}
|
||||
|
||||
|
||||
Vod vod = new Vod();
|
||||
vod.setVodId("");
|
||||
vod.setVodContent("");
|
||||
vod.setVodPic("");
|
||||
vod.setVodName("");
|
||||
vod.setVodPlayUrl(TextUtils.join("$$$", playUrl));
|
||||
vod.setVodPlayFrom(TextUtils.join("$$$", playFromtmp));
|
||||
vod.setTypeName("天意云盘");
|
||||
return vod;
|
||||
}
|
||||
|
||||
public String playerContent(String[] split, String flag) throws Exception {
|
||||
|
||||
String fileId = split[0], shareId = split[1];
|
||||
String playUrl = "";
|
||||
|
||||
playUrl = this.getDownload(shareId, fileId);
|
||||
Map<String, String> header = getHeaders();
|
||||
header.remove("Host");
|
||||
header.remove("Content-Type");
|
||||
return Result.get().url(playUrl).header(header).string();
|
||||
}
|
||||
|
||||
|
||||
private String proxyVideoUrl(String url, Map<String, String> header) {
|
||||
return String.format(Proxy.getUrl() + "?do=quark&type=video&url=%s&header=%s", Util.base64Encode(url.getBytes(Charset.defaultCharset())), Util.base64Encode(Json.toJson(header).getBytes(Charset.defaultCharset())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url
|
||||
* @param params get 参数
|
||||
* @param data post json
|
||||
* @param retry
|
||||
* @param method
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String api(String url, Map<String, String> params, Map<String, Object> data, Integer retry, String method) throws Exception {
|
||||
|
||||
|
||||
int leftRetry = retry != null ? retry : 3;
|
||||
if (StringUtils.isAllBlank(cookie)) {
|
||||
this.initUserInfo();
|
||||
return api(url, params, data, leftRetry - 1, method);
|
||||
}
|
||||
OkResult okResult;
|
||||
if ("GET".equals(method)) {
|
||||
okResult = OkHttp.get(this.apiUrl + url, params, getHeaders());
|
||||
} else {
|
||||
okResult = OkHttp.post(this.apiUrl + url, Json.toJson(data), getHeaders());
|
||||
}
|
||||
/* if (okResult.getResp().get("Set-Cookie") != null) {
|
||||
Matcher matcher = Pattern.compile("__puus=([^;]+)").matcher(StringUtils.join(okResult.getResp().get("Set-Cookie"), ";;;"));
|
||||
if (matcher.find()) {
|
||||
Matcher cookieMatcher = Pattern.compile("__puus=([^;]+)").matcher(this.cookie);
|
||||
if (cookieMatcher.find() && !cookieMatcher.group(1).equals(matcher.group(1))) {
|
||||
this.cookie = this.cookie.replaceAll("__puus=[^;]+", "__puus=" + matcher.group(1));
|
||||
} else {
|
||||
this.cookie = this.cookie + ";__puus=" + matcher.group(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (okResult.getCode() != 200 && leftRetry > 0) {
|
||||
SpiderDebug.log("api error code:" + okResult.getCode());
|
||||
Thread.sleep(1000);
|
||||
return api(url, params, data, leftRetry - 1, method);
|
||||
}
|
||||
return okResult.getBody();
|
||||
}
|
||||
|
||||
private void initUserInfo() {
|
||||
try {
|
||||
SpiderDebug.log("initUserInfo...");
|
||||
|
||||
//extend没有cookie,从缓存中获取
|
||||
if (StringUtils.isAllBlank(cookie)) {
|
||||
SpiderDebug.log(" cookie from ext is empty...");
|
||||
cookie = cache.getUser().getCookie();
|
||||
}
|
||||
init(cookie);
|
||||
/*//获取到cookie,初始化quark,并且把cookie缓存一次
|
||||
if (StringUtils.isNoneBlank(cookie) && cookie.contains("__pus")) {
|
||||
SpiderDebug.log(" initQuark ...");
|
||||
// initQuark(this.cookie);
|
||||
cache.setUser(User.objectFrom(this.cookie));
|
||||
return;
|
||||
}
|
||||
|
||||
//没有cookie,也没有serviceTicket,抛出异常,提示用户重新登录
|
||||
if (StringUtils.isAllBlank(cookie) && StringUtils.isAllBlank(serviceTicket)) {
|
||||
SpiderDebug.log("cookie为空");
|
||||
throw new RuntimeException("cookie为空");
|
||||
}
|
||||
|
||||
String token = serviceTicket;
|
||||
OkResult result = OkHttp.get("https://pan.quark.cn/account/info?st=" + token + "&lw=scan", new HashMap<>(), getHeaders());
|
||||
Map json = Json.parseSafe(result.getBody(), Map.class);
|
||||
if (json.get("success").equals(Boolean.TRUE)) {
|
||||
List<String> cookies = result.getResp().get("set-Cookie");
|
||||
List<String> cookieList = new ArrayList<>();
|
||||
for (String cookie : cookies) {
|
||||
cookieList.add(cookie.split(";")[0]);
|
||||
}
|
||||
this.cookie += TextUtils.join(";", cookieList);
|
||||
|
||||
cache.setUser(User.objectFrom(this.cookie));
|
||||
if (cache.getUser().getCookie().isEmpty()) throw new Exception(this.cookie);
|
||||
// initQuark(this.cookie);
|
||||
}
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
cache.getUser().clean();
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
// while (cache.getUser().getCookie().isEmpty()) SystemClock.sleep(250);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ShareData getShareData(String url, String accessCode) {
|
||||
String shareCode = "";
|
||||
// 第一种匹配规则:使用预编译的 regex
|
||||
Matcher matcher = Pattern.compile("https:\\/\\/cloud\\.189\\.cn\\/web\\/share\\?code=([^&]+)").matcher(url);
|
||||
if (matcher.find() && matcher.group(1) != null) {
|
||||
shareCode = matcher.group(1);
|
||||
// 从shareCode中提取访问码
|
||||
Matcher accessMatcher = Pattern.compile("访问码:([a-zA-Z0-9]+)").matcher(shareCode);
|
||||
if (accessMatcher.find()) {
|
||||
accessCode = accessMatcher.group(1);
|
||||
|
||||
} else {
|
||||
accessCode = "";
|
||||
}
|
||||
} else {
|
||||
// 第二种匹配规则:直接匹配 cloud.189.cn/t/ 格式
|
||||
Matcher fallbackMatcher = Pattern.compile("https://cloud\\.189\\.cn/t/([^&]+)").matcher(url);
|
||||
if (fallbackMatcher.find()) {
|
||||
shareCode = fallbackMatcher.group(1);
|
||||
} else {
|
||||
shareCode = null;
|
||||
}
|
||||
// 再次尝试从shareCode提取访问码
|
||||
if (shareCode != null) {
|
||||
Matcher accessMatcher = Pattern.compile("访问码:([a-zA-Z0-9]+)").matcher(shareCode);
|
||||
accessCode = accessMatcher.find() ? accessMatcher.group(1) : "";
|
||||
} else {
|
||||
accessCode = "";
|
||||
}
|
||||
}
|
||||
|
||||
shareCode = shareCode.split("(访问码")[0].trim();
|
||||
ShareData shareData = new ShareData(shareCode, "0");
|
||||
shareData.setSharePwd(accessCode);
|
||||
return shareData;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String getUserBriefInfo() throws Exception {
|
||||
OkResult result = OkHttp.get("https://cloud.189.cn/api/portal/v2/getUserBriefInfo.action", new HashMap<>(), getHeaders());
|
||||
JsonObject obj = Json.safeObject(result.getBody());
|
||||
return obj.get("sessionKey").getAsString();
|
||||
}
|
||||
|
||||
private String getUserSizeInfo() throws Exception {
|
||||
OkResult result = OkHttp.get("https://cloud.189.cn/api/portal/getUserSizeInfo.action", new HashMap<>(), getHeaders());
|
||||
JsonObject res = Json.safeObject(result.getBody());
|
||||
if (Objects.nonNull(res.get("errorCode")) && res.get("errorCode").getAsString().equals("InvalidSessionKey")) {
|
||||
tianYiHandler.startScan();
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void getShareToken(ShareData shareData) throws Exception {
|
||||
if (!this.shareTokenCache.containsKey(shareData.getShareId())) {
|
||||
this.shareTokenCache.remove(shareData.getShareId());
|
||||
JsonObject shareToken = Json.safeObject(api("getShareInfoByCodeV2.action?noCache=0.8886566349412803&shareCode=" + shareData.getShareId(), new HashMap<>(), new HashMap<>(), 0, "GET"));
|
||||
/**
|
||||
* {
|
||||
* "res_code" : 0.0,
|
||||
* "res_message" : "成功",
|
||||
* "accessCode" : "",
|
||||
* "creator" : {
|
||||
* "iconURL" : "",
|
||||
* "oper" : false,
|
||||
* "ownerAccount" : "185****1601@189.cn",
|
||||
* "superVip" : 33.0,
|
||||
* "vip" : 0.0
|
||||
* },
|
||||
* "expireTime" : 6.0,
|
||||
* "expireType" : 1.0,
|
||||
* "fileCreateDate" : "2025-03-20 13:49:18",
|
||||
* "fileId" : "12350115314094",
|
||||
* "fileLastOpTime" : "2025-03-20 13:49:19",
|
||||
* "fileName" : "05_如何制作动感影集.mp4等",
|
||||
* "fileSize" : 0.0,
|
||||
* "fileType" : "batchShare",
|
||||
* "isFolder" : true,
|
||||
* "needAccessCode" : 1.0,
|
||||
* "reviewStatus" : 1.0,
|
||||
* "shareDate" : 1.742449758E12,
|
||||
* "shareMode" : 1.0,
|
||||
* "shareType" : 1.0
|
||||
* }
|
||||
*/
|
||||
if (Objects.nonNull(shareToken.get("res_code")) && shareToken.get("res_code").getAsInt() == 0) {
|
||||
shareData.setShareId((String) shareToken.get("shareId").getAsString());
|
||||
shareData.setShareMode((Integer) shareToken.get("shareMode").getAsInt());
|
||||
shareData.setFolder(shareToken.get("isFolder").getAsBoolean());
|
||||
shareData.setFileId((String) shareToken.get("fileId").getAsString());
|
||||
shareData.setFolderId((String) shareToken.get("fileId").getAsString());
|
||||
|
||||
this.shareTokenCache.put(shareData.getShareId(), shareToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JsonArray listFile(int shareIndex, ShareData shareData, List<Item> videos, List<Item> subtitles, String shareId, String folderId, Integer page) throws Exception {
|
||||
int prePage = 200;
|
||||
page = page != null ? page : 1;
|
||||
String url = "listShareDir.action?" + "pageNum=" + page + "&pageSize=" + prePage + "&fileId=" + folderId + "&shareDirFileId=" + folderId + "&isFolder=" + shareData.getFolder() + "&shareId=" + shareId + "&shareMode=" + shareData.getShareMode() + "&iconOption=5" + "&orderBy=filename" + "&descending=false" + "&accessCode=" + shareData.getSharePwd();
|
||||
|
||||
JsonObject listData = Json.safeObject(api(url, Collections.emptyMap(), Collections.emptyMap(), 0, "GET"));
|
||||
if (listData.get("res_code").getAsInt() != 0) return new JsonArray();
|
||||
if (listData.get("fileListAO").getAsJsonObject().get("count").getAsInt() == 0 && listData.get("fileListAO").getAsJsonObject().get("fileListSize").getAsInt() == 0)
|
||||
return new JsonArray();
|
||||
|
||||
JsonArray items = listData.get("fileListAO").getAsJsonObject().get("fileList").getAsJsonArray();
|
||||
JsonArray subDir = listData.get("fileListAO").getAsJsonObject().get("folderList").getAsJsonArray();
|
||||
|
||||
for (JsonElement item : items) {
|
||||
if (item.getAsJsonObject().get("mediaType").getAsInt() == 3) {
|
||||
if (item.getAsJsonObject().get("size").getAsInt() < 1024 * 1024 * 5) continue;
|
||||
|
||||
videos.add(Item.objectFrom(item.getAsJsonObject(), shareData.getShareId(), shareIndex));
|
||||
} /*else if ("file".equals(item.get("type")) && this.subtitleExts.contains("." + Util.getExt((String) item.get("file_name")))) {
|
||||
subtitles.add(Item.objectFrom(item, shareData.getShareId(), shareIndex));
|
||||
}*/
|
||||
}
|
||||
if (listData.get("fileListAO").getAsJsonObject().get("count").getAsInt() > (items.size() + subDir.size())) {
|
||||
JsonArray nextItems = listFile(shareIndex, shareData, videos, subtitles, shareId, folderId, page + 1);
|
||||
items.addAll(nextItems);
|
||||
}
|
||||
for (JsonElement dir : subDir) {
|
||||
String subfolderId = dir.getAsJsonObject().get("id").getAsString();
|
||||
JsonArray subItems = listFile(shareIndex, shareData, videos, subtitles, shareId, subfolderId, null);
|
||||
items.addAll(subItems);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private Map<String, Object> findBestLCS(Item mainItem, List<Item> targetItems) {
|
||||
List<Map<String, Object>> results = new ArrayList<>();
|
||||
int bestMatchIndex = 0;
|
||||
for (int i = 0; i < targetItems.size(); i++) {
|
||||
Util.LCSResult currentLCS = Util.lcs(mainItem.getName(), targetItems.get(i).getName());
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("target", targetItems.get(i));
|
||||
result.put("lcs", currentLCS);
|
||||
results.add(result);
|
||||
if (currentLCS.length > results.get(bestMatchIndex).get("lcs").toString().length()) {
|
||||
bestMatchIndex = i;
|
||||
}
|
||||
}
|
||||
Map<String, Object> bestMatch = results.get(bestMatchIndex);
|
||||
Map<String, Object> finalResult = new HashMap<>();
|
||||
finalResult.put("allLCS", results);
|
||||
finalResult.put("bestMatch", bestMatch);
|
||||
finalResult.put("bestMatchIndex", bestMatchIndex);
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
public void getFilesByShareUrl(int shareIndex, String shareInfo, List<Item> videos, List<Item> subtitles) throws Exception {
|
||||
ShareData shareData = getShareData((String) shareInfo, "");
|
||||
if (shareData == null) return;
|
||||
getShareToken(shareData);
|
||||
if (!this.shareTokenCache.containsKey(shareData.getShareId())) return;
|
||||
listFile(shareIndex, shareData, videos, subtitles, shareData.getShareId(), shareData.getFolderId(), 1);
|
||||
if (!subtitles.isEmpty()) {
|
||||
for (Item video : videos) {
|
||||
Map<String, Object> matchSubtitle = findBestLCS(video, subtitles);
|
||||
if (matchSubtitle.get("bestMatch") != null) {
|
||||
video.setSubtitle((String) ((Map<String, Object>) matchSubtitle.get("bestMatch")).get("target"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getDownload(String shareId, String fileId) throws Exception {
|
||||
Map<String, String> headers = getHeaders();
|
||||
//headers.remove("sessionKey");
|
||||
OkResult result = OkHttp.get("https://cloud.189.cn/api/portal/getNewVlcVideoPlayUrl.action?shareId=" + shareId + "&dt=1&fileId=" + fileId + "&type=4&key=noCache", new HashMap<>(), headers);
|
||||
JsonObject res = Json.safeObject(result.getBody());
|
||||
if (Objects.nonNull(res.get("res_code")) && res.get("res_code").getAsInt() == 0) {
|
||||
|
||||
if (res.get("normal") != null) {
|
||||
return res.get("normal").getAsJsonObject().get("url").getAsString();
|
||||
}
|
||||
} else {
|
||||
SpiderDebug.log("获取下载地址失败:" + result.getBody());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Helper method to convert bytes to hex string
|
||||
private String bytesToHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// Encoding helper method
|
||||
private String encodeURIComponent(String value) {
|
||||
try {
|
||||
return java.net.URLEncoder.encode(value, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.github.catvod.bean.tianyi;
|
||||
|
||||
import com.github.catvod.api.TianYiHandler;
|
||||
import com.github.catvod.api.UCApi;
|
||||
import com.github.catvod.api.UCTokenHandler;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.spider.Init;
|
||||
import com.github.catvod.utils.Path;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Cache {
|
||||
|
||||
@SerializedName("user")
|
||||
private User user;
|
||||
|
||||
|
||||
public static Cache objectFrom(String str) {
|
||||
SpiderDebug.log("Cache.objectFrom: " + str);
|
||||
Cache item = new Gson().fromJson(str, Cache.class);
|
||||
return item == null ? new Cache() : item;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user == null ? new User("") : user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void setTokenUser(User user) {
|
||||
this.user = user;
|
||||
this.saveToken();
|
||||
}
|
||||
|
||||
public void setTianyiUser(User user) {
|
||||
this.user = user;
|
||||
this.saveTianyiUser();
|
||||
}
|
||||
|
||||
public void saveTianyiUser() {
|
||||
Init.execute(() -> Path.write(new TianYiHandler().getCache(), toString()));
|
||||
}
|
||||
|
||||
public void saveToken() {
|
||||
Init.execute(() -> Path.write(new UCTokenHandler().getCache(), toString()));
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
Init.execute(() -> Path.write(UCApi.get().getCache(), toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
package com.github.catvod.bean.tianyi;
|
||||
|
||||
import com.github.catvod.utils.Util;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Item {
|
||||
private String fileId;
|
||||
private String shareId;
|
||||
private String shareToken;
|
||||
private String shareFileToken;
|
||||
private String seriesId;
|
||||
private String name;
|
||||
private String type;
|
||||
private String formatType;
|
||||
private Double size;
|
||||
private String parent;
|
||||
private String shareData;
|
||||
private int shareIndex;
|
||||
private Double lastUpdateAt;
|
||||
private String subtitle;
|
||||
|
||||
public Item() {
|
||||
this.fileId = "";
|
||||
this.shareId = "";
|
||||
this.shareToken = "";
|
||||
this.shareFileToken = "";
|
||||
this.seriesId = "";
|
||||
this.name = "";
|
||||
this.type = "";
|
||||
this.formatType = "";
|
||||
this.size = 0d;
|
||||
this.parent = "";
|
||||
this.shareData = null;
|
||||
this.shareIndex = 0;
|
||||
this.lastUpdateAt = 0d;
|
||||
}
|
||||
|
||||
public static Item objectFrom(JsonObject item_json, String shareId, int shareIndex) {
|
||||
Item item = new Item();
|
||||
item.fileId = item_json.get("id") != null ? item_json.get("id").getAsString() : "";
|
||||
item.shareId = shareId;
|
||||
item.name = item_json.get("name") != null ? item_json.get("name").getAsString() : "";
|
||||
item.size = item_json.get("size") != null ? item_json.get("size").getAsDouble() : 0d;
|
||||
/* item.shareToken = item_json.get("stoken") != null ? (String) item_json.get("stoken") : "";
|
||||
item.shareFileToken = item_json.get("share_fid_token") != null ? (String) item_json.get("share_fid_token") : "";
|
||||
item.seriesId = item_json.get("series_id") != null ? (String) item_json.get("series_id") : "";
|
||||
|
||||
item.type = item_json.get("obj_category") != null ? (String) item_json.get("obj_category") : "";
|
||||
item.formatType = item_json.get("format_type") != null ? (String) item_json.get("format_type") : "";
|
||||
item.size = item_json.get("size") != null ? (Double) item_json.get("size") : 0d;
|
||||
item.parent = item_json.get("pdir_fid") != null ? (String) item_json.get("pdir_fid") : "";
|
||||
item.lastUpdateAt = item_json.get("last_update_at") != null ? (Double) item_json.get("last_update_at") : Double.valueOf(0d);
|
||||
item.shareIndex = shareIndex;*/
|
||||
return item;
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
String[] arr = name.split("\\.");
|
||||
return arr[arr.length - 1];
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return fileId.isEmpty() ? "" : fileId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name.isEmpty() ? "" : name;
|
||||
}
|
||||
|
||||
public String getParent() {
|
||||
return parent.isEmpty() ? "" : "[" + parent + "]";
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size.equals("0") ? "" : "[" + size + "]";
|
||||
}
|
||||
|
||||
|
||||
public int getShareIndex() {
|
||||
return shareIndex;
|
||||
}
|
||||
|
||||
public String getDisplayName(String type_name) {
|
||||
String name = getName();
|
||||
if (type_name.equals("电视剧")) {
|
||||
String[] replaceNameList = {"4k", "4K"};
|
||||
name = name.replaceAll("\\." + getFileExtension(), "");
|
||||
for (String replaceName : replaceNameList) {
|
||||
name = name.replaceAll(replaceName, "");
|
||||
}
|
||||
name = Pattern.compile("/\\.S01E(.*?)\\./").matcher(name).find() ? name.split("/\\.S01E(.*?)\\./")[1] : name;
|
||||
String[] numbers = name.split("\\d+");
|
||||
if (numbers.length > 0) {
|
||||
name = numbers[0];
|
||||
}
|
||||
}
|
||||
return name + " " + Util.getSize(size);
|
||||
}
|
||||
|
||||
public String getEpisodeUrl(String type_name) {
|
||||
return getDisplayName(type_name) + "$" + getFileId() + "++" + shareId ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.github.catvod.bean.tianyi;
|
||||
|
||||
public class ShareData {
|
||||
|
||||
private String shareId;
|
||||
private String folderId;
|
||||
private String sharePwd;
|
||||
private String fileId;
|
||||
private Integer shareMode;
|
||||
private Boolean isFolder;
|
||||
|
||||
|
||||
public String getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public void setFileId(String fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public Integer getShareMode() {
|
||||
return shareMode;
|
||||
}
|
||||
|
||||
public void setShareMode(Integer shareMode) {
|
||||
this.shareMode = shareMode;
|
||||
}
|
||||
|
||||
public Boolean getFolder() {
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
public void setFolder(Boolean folder) {
|
||||
isFolder = folder;
|
||||
}
|
||||
|
||||
public ShareData(String shareId, String folderId) {
|
||||
this.shareId = shareId;
|
||||
this.folderId = folderId;
|
||||
}
|
||||
|
||||
public String getSharePwd() {
|
||||
return sharePwd;
|
||||
}
|
||||
|
||||
public void setSharePwd(String sharePwd) {
|
||||
this.sharePwd = sharePwd;
|
||||
}
|
||||
|
||||
public String getShareId() {
|
||||
return shareId;
|
||||
}
|
||||
|
||||
public void setShareId(String shareId) {
|
||||
this.shareId = shareId;
|
||||
}
|
||||
|
||||
public String getFolderId() {
|
||||
return folderId;
|
||||
}
|
||||
|
||||
public void setFolderId(String folderId) {
|
||||
this.folderId = folderId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.github.catvod.bean.tianyi;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class User {
|
||||
public User(String cookie) {
|
||||
this.cookie = cookie;
|
||||
}
|
||||
|
||||
@SerializedName("cookie")
|
||||
private String cookie;
|
||||
|
||||
|
||||
|
||||
|
||||
public String getCookie() {
|
||||
return cookie;
|
||||
}
|
||||
|
||||
public void setCookie(String cookie) {
|
||||
this.cookie = cookie;
|
||||
}
|
||||
|
||||
public static User objectFrom(String cookie) {
|
||||
return new User(cookie);
|
||||
}
|
||||
|
||||
|
||||
public void clean() {
|
||||
this.cookie = "";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.github.catvod.spider;
|
|||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.github.catvod.api.TianyiApi;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.utils.Json;
|
||||
import com.github.catvod.utils.Util;
|
||||
|
|
@ -10,6 +11,8 @@ import com.google.gson.JsonObject;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.github.catvod.api.TianyiApi.URL_START;
|
||||
|
||||
/**
|
||||
* @author ColaMint & Adam & FongMi
|
||||
*/
|
||||
|
|
@ -17,6 +20,7 @@ public class Cloud extends Spider {
|
|||
private Quark quark = null;
|
||||
private Ali ali = null;
|
||||
private UC uc = null;
|
||||
private TianYi tianYi = null;
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
|
|
@ -24,9 +28,11 @@ public class Cloud extends Spider {
|
|||
quark = new Quark();
|
||||
uc = new UC();
|
||||
ali = new Ali();
|
||||
tianYi = new TianYi();
|
||||
quark.init(context, ext.has("cookie") ? ext.get("cookie").getAsString() : "");
|
||||
uc.init(context, ext.has("uccookie") ? ext.get("uccookie").getAsString() : "");
|
||||
ali.init(context, ext.has("token") ? ext.get("token").getAsString() : "");
|
||||
tianYi.init(context, ext.has("tianyicookie") ? ext.get("tianyicookie").getAsString() : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -37,6 +43,8 @@ public class Cloud extends Spider {
|
|||
return quark.detailContent(shareUrl);
|
||||
} else if (shareUrl.get(0).matches(Util.patternUC)) {
|
||||
return uc.detailContent(shareUrl);
|
||||
} else if (shareUrl.get(0).startsWith(TianyiApi.URL_START)) {
|
||||
return tianYi.detailContent(shareUrl);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -47,6 +55,8 @@ public class Cloud extends Spider {
|
|||
return quark.playerContent(flag, id, vipFlags);
|
||||
} else if (flag.contains("uc")) {
|
||||
return uc.playerContent(flag, id, vipFlags);
|
||||
} else if (flag.contains("天意")) {
|
||||
return tianYi.playerContent(flag, id, vipFlags);
|
||||
} else {
|
||||
return ali.playerContent(flag, id, vipFlags);
|
||||
}
|
||||
|
|
@ -54,15 +64,17 @@ public class Cloud extends Spider {
|
|||
|
||||
protected String detailContentVodPlayFrom(List<String> shareLinks) {
|
||||
List<String> from = new ArrayList<>();
|
||||
int i =0;
|
||||
int i = 0;
|
||||
for (String shareLink : shareLinks) {
|
||||
i++;
|
||||
if (shareLink.matches(Util.patternUC)) {
|
||||
from.add(uc.detailContentVodPlayFrom(List.of(shareLink),i));
|
||||
from.add(uc.detailContentVodPlayFrom(List.of(shareLink), i));
|
||||
} else if (shareLink.matches(Util.patternQuark)) {
|
||||
from.add(quark.detailContentVodPlayFrom(List.of(shareLink),i));
|
||||
from.add(quark.detailContentVodPlayFrom(List.of(shareLink), i));
|
||||
} else if (shareLink.matches(Util.patternAli)) {
|
||||
from.add(ali.detailContentVodPlayFrom(List.of(shareLink),i));
|
||||
from.add(ali.detailContentVodPlayFrom(List.of(shareLink), i));
|
||||
} else if (shareLink.startsWith(URL_START)) {
|
||||
from.add(tianYi.detailContentVodPlayFrom(List.of(shareLink), i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +90,8 @@ int i =0;
|
|||
urls.add(quark.detailContentVodPlayUrl(List.of(shareLink)));
|
||||
} else if (shareLink.matches(Util.patternAli)) {
|
||||
urls.add(ali.detailContentVodPlayUrl(List.of(shareLink)));
|
||||
} else if (shareLink.startsWith(URL_START)) {
|
||||
urls.add(tianYi.detailContentVodPlayUrl(List.of(shareLink)));
|
||||
}
|
||||
}
|
||||
return TextUtils.join("$$$", urls);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
package com.github.catvod.spider;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.github.catvod.api.TianyiApi;
|
||||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.tianyi.ShareData;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lushunming
|
||||
*/
|
||||
public class TianYi extends Spider {
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) throws Exception {
|
||||
|
||||
TianyiApi.get().setCookie(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
|
||||
ShareData shareData = TianyiApi.get().getShareData(ids.get(0), "");
|
||||
return Result.string(TianyiApi.get().getVod(shareData));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
return TianyiApi.get().playerContent(id.split("\\+\\+"), flag);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 獲取詳情內容視頻播放來源(多 shared_link)
|
||||
*
|
||||
* @param ids share_link 集合
|
||||
* @param
|
||||
* @return 詳情內容視頻播放來源
|
||||
*/
|
||||
public String detailContentVodPlayFrom(List<String> ids, int index) {
|
||||
List<String> playFrom = new ArrayList<>();
|
||||
/* if (ids.size() < 2){
|
||||
return TextUtils.join("$$$", TianyiApi.get().getPlayFormatList());
|
||||
}*/
|
||||
|
||||
for (int i = 1; i <= ids.size(); i++) {
|
||||
|
||||
for (String s : TianyiApi.get().getPlayFormatList()) {
|
||||
playFrom.add(String.format(Locale.getDefault(), "天意" + s + "#%02d%02d", i, index));
|
||||
|
||||
}
|
||||
playFrom.add("天意" + i + index);
|
||||
}
|
||||
return TextUtils.join("$$$", playFrom);
|
||||
}
|
||||
|
||||
/**
|
||||
* 獲取詳情內容視頻播放地址(多 share_link)
|
||||
*
|
||||
* @param ids share_link 集合
|
||||
* @return 詳情內容視頻播放地址
|
||||
*/
|
||||
public String detailContentVodPlayUrl(List<String> ids) throws Exception {
|
||||
List<String> playUrl = new ArrayList<>();
|
||||
for (String id : ids) {
|
||||
ShareData shareData = TianyiApi.get().getShareData(id, "");
|
||||
try {
|
||||
playUrl.add(TianyiApi.get().getVod(shareData).getVodPlayUrl());
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log("获取播放地址出错:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
return TextUtils.join("$$$", playUrl);
|
||||
}
|
||||
|
||||
public static Object[] proxy(Map<String, String> params) throws Exception {
|
||||
String type = params.get("type");
|
||||
if ("video".equals(type)) return TianyiApi.get().proxyVideo(params);
|
||||
//if ("sub".equals(type)) return AliYun.get().proxySub(params);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.github.catvod.spider;
|
||||
|
||||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Util;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhixc
|
||||
*/
|
||||
public class TianYiSo extends Cloud {
|
||||
|
||||
private final String URL = "https://www.tianyiso.com/";
|
||||
|
||||
private Map<String, String> getHeader() {
|
||||
Map<String, String> header = new HashMap<>();
|
||||
header.put("User-Agent", Util.CHROME);
|
||||
return header;
|
||||
}
|
||||
|
||||
private Map<String, String> getSearchHeader() {
|
||||
Map<String, String> header = getHeader();
|
||||
header.put("referer", URL);
|
||||
header.put("Origin", URL);
|
||||
return header;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchContent(String key, boolean quick) throws Exception {
|
||||
|
||||
List<Vod> list = new ArrayList<>();
|
||||
String url = URL + "search?k=" + URLEncoder.encode(key, Charset.defaultCharset().name());
|
||||
String result = OkHttp.string(url, getSearchHeader());
|
||||
Elements links = Jsoup.parse(result).select("a");
|
||||
for (Element link : links) {
|
||||
String path = link.attr("href");
|
||||
if (path.startsWith("/s/")) {
|
||||
String name = link.select("template").first().text().trim();
|
||||
list.add(new Vod(
|
||||
path,
|
||||
name,
|
||||
"", // vod_pic 留空
|
||||
"" // vod_remarks 留空
|
||||
));
|
||||
}
|
||||
}
|
||||
return Result.string(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> shareUrl) throws Exception {
|
||||
|
||||
String html = OkHttp.string(URL + shareUrl.get(0), getHeader());
|
||||
String url = Util.findByRegex("\"(https://cloud\\.189\\.cn/t/.*)\",", html, 1);
|
||||
String result = super.detailContent(List.of(url));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import android.app.Application;
|
||||
import com.github.catvod.server.Server;
|
||||
import com.github.catvod.spider.Init;
|
||||
import com.github.catvod.spider.PanSearch;
|
||||
import com.github.catvod.spider.TianYiSo;
|
||||
import com.github.catvod.utils.Json;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TianYiSoTest {
|
||||
|
||||
private Application mockContext;
|
||||
|
||||
private TianYiSo spider;
|
||||
|
||||
@org.junit.Before
|
||||
public void setUp() throws Exception {
|
||||
mockContext = RuntimeEnvironment.application;
|
||||
Init.init(mockContext);
|
||||
spider = new TianYiSo();
|
||||
Server.get().start();
|
||||
// spider.init(mockContext, "{\"cookie\":\"b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; _UP_A4A_11_=wb9661c6dfb642f88f73d8e0c7edd398; b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; ctoken=wla6p3EUOLyn1FSB8IKp1SEW; grey-id=5583e32b-39df-4bf0-f39f-1adf83f604a2; grey-id.sig=p8ReBIMG2BeZu1sYvsuOAZxYbx-MVrsfKEiCv87MsTM; isQuark=true; isQuark.sig=hUgqObykqFom5Y09bll94T1sS9abT1X-4Df_lzgl8nM; _UP_F7E_8D_=ZkyvVHnrBLp1A1NFJIjWi0PwKLOVbxJPcg0RzQPI6KmBtV6ZMgPh38l93pgubgHDQqhaZ2Sfc0qv%2BRantbfg1mWGAUpRMP4RqXP78Wvu%2FCfvkWWGc5NhCTV71tGOIGgDBR3%2Bu6%2Fjj44KlE5biSNDOWW7Bigcz27lvOTidzNw8s%2FWtKAIxWbnCzZn4%2FJMBUub1SIMcW89g57k4mfPmDlCgpZKzxwl6beSfdtZ4RUWXmZOn5v5NkxVKhU4wR0Pq7NklczEGdRq2nIAcu7v22Uw2o%2FxMY0xBdeC9Korm5%2FNHnxl6K%2Bd6FXSoT9a3XIMQO359auZPiZWzrNlZe%2BqnOahXcx7KAhQIRqSOapSmL4ygJor4r5isJhRuDoXy7vJAVuH%2FRDtEJJ8rZTq0BdC23Bz%2B0MrsdgbK%2BiW; _UP_D_=pc; __wpkreporterwid_=3d3f74a7-99b7-4916-3f78-911fc2eb9d87; tfstk=fIoZNxjnbhKwPOu0TWZ4LsaRqirTcudSSmNbnxD0C5VgClMm8xMyB-GsnSu4tjpOflAOmSD-9PNiGl120XrgkVNb1SrqHbJBN3tSBAEYoQOWVUUg9qZ8n1bGGkD3CqGYINKSBABhjnXgp3_Vywz6gSc0Syj3BWf0mr2DLW24eZfiiovEKWefj1q0swq3E82iNEMinMy7SLrcpA4Fh3z_ZAViCfih3PbtdW5N_DuU77AaTijmYRkL2Wq54ENoy5a7ZXxCbok33XzS7QSZgxD-oyoVsdGotql0p2dVu7umC4nLStbiLmParc4FELHrI-c0u2dPVRrs8zoZWKCnIbNZrlHfUCMUz2z8KyXVSlgSFmUojh58OzeqTzgwaGll4YCYKwctDV5coP2LL79eKHxpNTXHmre1kZU32JPWCR_AkP2LL79eLZQY-WeUNdw1.; __pus=2051c82285199d8be553be41dd5a2100AAQ+mmv35G4FDDZ5x+3Mhe2OMbNgweQ1ODbW8zDt9YuP1LQVqHUuAAz9KWLsPjpNtim0AVGHusN4MCosTmbq/khM; __kp=e6604120-6051-11ef-bfe4-c31b6cdd0766; __kps=AATcZArVgS76EPn0FMaV4HEj; __ktd=sii/iz4ePzEaoVirXul7QQ==; __uid=AATcZArVgS76EPn0FMaV4HEj; __itrace_wid=5829b95d-dac1-48d3-bfd5-f60cd9462786; __puus=7da0b96cb710fa1b376934485f977e05AATp/q8/QupT7IiBR1GWqZhxlIRT677smMvoHlLxQA0Lk6CkP0YJBOTl+p9DZgzlMz6w4hPXPgWsokukk8PW7ZfhFfPmv8tKMgLpCGLW+tk57luhNghmSdTeVPkAF59STtyCPBEtiNzNAd/zZJ6qILJDi5ywEBAAAg+gOyWHoLHNUR+QxeHRuQa8g5WWA95J8jebIlrr8rCvI1vjTbtiYktT\",\"token\":\"26fc6787afff43e78b78992e782502f1\"}");
|
||||
spider.init(mockContext, "{\"tianyicookie\":\"JSESSIONID=B35242EB04B3FBE672BED4B42F04D7E3;COOKIE_LOGIN_USER=B0A47E7C883DA2F0AFA9713E5D80E60955214A1445778CC40810306B68D7038FC568A6F20EAE2963519B17746FC9EB976F2317DE786E92E8CFCA5D36\"}");
|
||||
// spider.init(mockContext, "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void searchContent() throws Exception {
|
||||
String content = spider.searchContent("红海", false);
|
||||
JsonObject map = Json.safeObject(content);
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
System.out.println("searchContent--" + gson.toJson(map));
|
||||
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void detailContent() throws Exception {
|
||||
|
||||
String content = spider.detailContent(Arrays.asList("/s/LEvn4lUGB6ufdQ"));
|
||||
JsonObject map = Json.safeObject(content);
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
System.out.println("detailContent--" + gson.toJson(map));
|
||||
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
import android.app.Application;
|
||||
import com.github.catvod.server.Server;
|
||||
import com.github.catvod.spider.Init;
|
||||
import com.github.catvod.spider.Quark;
|
||||
import com.github.catvod.spider.TianYi;
|
||||
import com.github.catvod.utils.Json;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TianYiTest {
|
||||
|
||||
private Application mockContext;
|
||||
|
||||
private TianYi spider;
|
||||
|
||||
@org.junit.Before
|
||||
public void setUp() throws Exception {
|
||||
mockContext = RuntimeEnvironment.application;
|
||||
Init.init(mockContext);
|
||||
spider = new TianYi();
|
||||
// spider.init(mockContext, "b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; _UP_A4A_11_=wb9661c6dfb642f88f73d8e0c7edd398; b-user-id=89ede34e-0efc-e1dd-c997-f16aaa792d0c; ctoken=wla6p3EUOLyn1FSB8IKp1SEW; grey-id=5583e32b-39df-4bf0-f39f-1adf83f604a2; grey-id.sig=p8ReBIMG2BeZu1sYvsuOAZxYbx-MVrsfKEiCv87MsTM; isQuark=true; isQuark.sig=hUgqObykqFom5Y09bll94T1sS9abT1X-4Df_lzgl8nM; _UP_F7E_8D_=ZkyvVHnrBLp1A1NFJIjWi0PwKLOVbxJPcg0RzQPI6KmBtV6ZMgPh38l93pgubgHDQqhaZ2Sfc0qv%2BRantbfg1mWGAUpRMP4RqXP78Wvu%2FCfvkWWGc5NhCTV71tGOIGgDBR3%2Bu6%2Fjj44KlE5biSNDOWW7Bigcz27lvOTidzNw8s%2FWtKAIxWbnCzZn4%2FJMBUub1SIMcW89g57k4mfPmDlCgpZKzxwl6beSfdtZ4RUWXmZOn5v5NkxVKhU4wR0Pq7NklczEGdRq2nIAcu7v22Uw2o%2FxMY0xBdeC9Korm5%2FNHnxl6K%2Bd6FXSoT9a3XIMQO359auZPiZWzrNlZe%2BqnOahXcx7KAhQIRqSOapSmL4ygJor4r5isJhRuDoXy7vJAVuH%2FRDtEJJ8rZTq0BdC23Bz%2B0MrsdgbK%2BiW; _UP_D_=pc; __wpkreporterwid_=3d3f74a7-99b7-4916-3f78-911fc2eb9d87; tfstk=fIoZNxjnbhKwPOu0TWZ4LsaRqirTcudSSmNbnxD0C5VgClMm8xMyB-GsnSu4tjpOflAOmSD-9PNiGl120XrgkVNb1SrqHbJBN3tSBAEYoQOWVUUg9qZ8n1bGGkD3CqGYINKSBABhjnXgp3_Vywz6gSc0Syj3BWf0mr2DLW24eZfiiovEKWefj1q0swq3E82iNEMinMy7SLrcpA4Fh3z_ZAViCfih3PbtdW5N_DuU77AaTijmYRkL2Wq54ENoy5a7ZXxCbok33XzS7QSZgxD-oyoVsdGotql0p2dVu7umC4nLStbiLmParc4FELHrI-c0u2dPVRrs8zoZWKCnIbNZrlHfUCMUz2z8KyXVSlgSFmUojh58OzeqTzgwaGll4YCYKwctDV5coP2LL79eKHxpNTXHmre1kZU32JPWCR_AkP2LL79eLZQY-WeUNdw1.; __pus=2051c82285199d8be553be41dd5a2100AAQ+mmv35G4FDDZ5x+3Mhe2OMbNgweQ1ODbW8zDt9YuP1LQVqHUuAAz9KWLsPjpNtim0AVGHusN4MCosTmbq/khM; __kp=e6604120-6051-11ef-bfe4-c31b6cdd0766; __kps=AATcZArVgS76EPn0FMaV4HEj; __ktd=sii/iz4ePzEaoVirXul7QQ==; __uid=AATcZArVgS76EPn0FMaV4HEj; __itrace_wid=5829b95d-dac1-48d3-bfd5-f60cd9462786; __puus=7da0b96cb710fa1b376934485f977e05AATp/q8/QupT7IiBR1GWqZhxlIRT677smMvoHlLxQA0Lk6CkP0YJBOTl+p9DZgzlMz6w4hPXPgWsokukk8PW7ZfhFfPmv8tKMgLpCGLW+tk57luhNghmSdTeVPkAF59STtyCPBEtiNzNAd/zZJ6qILJDi5ywEBAAAg+gOyWHoLHNUR+QxeHRuQa8g5WWA95J8jebIlrr8rCvI1vjTbtiYktT");
|
||||
spider.init(mockContext, "JSESSIONID=B35242EB04B3FBE672BED4B42F04D7E3;COOKIE_LOGIN_USER=B0A47E7C883DA2F0AFA9713E5D80E60955214A1445778CC40810306B68D7038FC568A6F20EAE2963519B17746FC9EB976F2317DE786E92E8CFCA5D36");
|
||||
// Server.get().start();
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void init() throws Exception {
|
||||
spider.init(mockContext, "JSESSIONID=B35242EB04B3FBE672BED4B42F04D7E3;COOKIE_LOGIN_USER=B0A47E7C883DA2F0AFA9713E5D80E60955214A1445778CC40810306B68D7038FC568A6F20EAE2963519B17746FC9EB976F2317DE786E92E8CFCA5D36");
|
||||
//Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void detailContent() throws Exception {
|
||||
|
||||
String content = spider.detailContent(Arrays.asList("https://cloud.189.cn/web/share?code=2eyARfBzURZj(访问码:kz6y)"));
|
||||
System.out.println("detailContent--" + content);
|
||||
JsonObject map = Json.safeObject(content);
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
System.out.println("detailContent--" + gson.toJson(map));
|
||||
Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void playerContent() throws Exception {
|
||||
|
||||
String content = spider.playerContent("普画","21309114537538085++12347115348228",new ArrayList<>());
|
||||
System.out.println("playerContent--" + content);
|
||||
JsonObject map = Json.safeObject(content);
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
System.out.println("playerContent--" + gson.toJson(map));
|
||||
Assert.assertFalse(map.getAsJsonPrimitive("url").getAsString().isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.github.catvod.api;
|
||||
|
||||
import com.github.catvod.bean.tianyi.ShareData;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TianyiApiTest {
|
||||
|
||||
// @Test
|
||||
// public void getShareData() {
|
||||
//
|
||||
//
|
||||
// ShareData shareData = QuarkApi.get().getShareData("https://pan.quark.cn/s/1e386295b8ca");
|
||||
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
//
|
||||
// System.out.println("getShareData--" + gson.toJson(shareData));
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void getShareData() throws Exception {
|
||||
|
||||
com.github.catvod.bean.tianyi.ShareData shareData = TianyiApi.get().getShareData("https://cloud.189.cn/web/share?code=ZvEjUvq6FNr2", "");
|
||||
// TianyiApi.get().getVod(shareData);
|
||||
com.github.catvod.bean.tianyi.ShareData shareData1 = TianyiApi.get().getShareData("https://cloud.189.cn/web/share?code=2eyARfBzURZj(访问码:kz6y)", "");
|
||||
|
||||
// TianyiApi.get().getVod(shareData1);
|
||||
ShareData shareData2 = TianyiApi.get().getShareData("https://cloud.189.cn/t/ZvEjUvq6FNr2", "");
|
||||
// TianyiApi.get().getVod(shareData2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getVod() throws Exception {
|
||||
|
||||
com.github.catvod.bean.tianyi.ShareData shareData1 = TianyiApi.get().getShareData("https://cloud.189.cn/web/share?code=qEVVjyqM7bY3(访问码:6iel)", "");
|
||||
TianyiApi api = TianyiApi.get();
|
||||
api.setCookie("JSESSIONID=B35242EB04B3FBE672BED4B42F04D7E3;COOKIE_LOGIN_USER=B0A47E7C883DA2F0AFA9713E5D80E60955214A1445778CC40810306B68D7038FC568A6F20EAE2963519B17746FC9EB976F2317DE786E92E8CFCA5D36");
|
||||
api.getVod(shareData1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
47a90e0f69913b779d628d308a0e99d3
|
||||
f18e18cac02689c0b0bb3ba3311d2660
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/tianyidev/jar/custom_spider.jar;md5;47a90e0f69913b779d628d308a0e99d3",
|
||||
"spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/tianyidev/jar/custom_spider.jar;md5;f18e18cac02689c0b0bb3ba3311d2660",
|
||||
"lives": [
|
||||
{
|
||||
"name": "电视直播",
|
||||
|
|
@ -338,6 +338,14 @@
|
|||
"searchable": 1,
|
||||
"timeout": 30
|
||||
},
|
||||
{
|
||||
"key": "TianYiSo",
|
||||
"name": "天翼┃搜索",
|
||||
"type": 3,
|
||||
"api": "csp_TianYiSo",
|
||||
"searchable": 1,
|
||||
"timeout": 30
|
||||
},
|
||||
{
|
||||
"key": "newvision",
|
||||
"name": "(js)新视觉影院(不稳定)",
|
||||
|
|
|
|||
Loading…
Reference in New Issue