天意accessToken
This commit is contained in:
parent
5b75f47b69
commit
9f603ce26d
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.github.catvod.api;
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.catvod.bean.tianyi.Cache;
|
||||||
|
import com.github.catvod.bean.tianyi.User;
|
||||||
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
|
import com.github.catvod.utils.Json;
|
||||||
|
import com.github.catvod.utils.Path;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import okhttp3.Cookie;
|
||||||
|
import okhttp3.CookieJar;
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SimpleCookieJar implements CookieJar {
|
||||||
|
private Map<String, List<Cookie>> cookieStore = new HashMap<>();
|
||||||
|
private final Cache cache;
|
||||||
|
|
||||||
|
public Map<String, List<Cookie>> getCookieStore() {
|
||||||
|
return cookieStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCookieStore(Map<String, List<Cookie>> cookieStore) {
|
||||||
|
this.cookieStore = cookieStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCookieJar() {
|
||||||
|
this.cache = Cache.objectFrom(Path.read(getCache()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public File getCache() {
|
||||||
|
return Path.tv("tianyi");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveFromResponse(HttpUrl url, @NotNull List<Cookie> cookies) {
|
||||||
|
SpiderDebug.log("SimpleCookieJar saveFromResponse: " + url.host() + ": " + Json.toJson(cookies));
|
||||||
|
// 创建可修改的 Cookie 列表副本
|
||||||
|
List<Cookie> oldCookies = cookieStore.get(url.host())!=null?cookieStore.get(url.host()):new ArrayList<>();
|
||||||
|
List<Cookie> newCookies = new ArrayList<>(oldCookies);
|
||||||
|
|
||||||
|
// 更新 Cookie
|
||||||
|
for (Cookie newCookie : cookies) {
|
||||||
|
// 移除同名的旧 Cookie
|
||||||
|
for (Cookie oldCookie : newCookies) {
|
||||||
|
if(oldCookie.name().equals(newCookie.name())){
|
||||||
|
oldCookies.remove(oldCookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oldCookies.addAll(cookies);
|
||||||
|
|
||||||
|
cookieStore.put(url.host(), oldCookies);
|
||||||
|
cache.setTianyiUser(User.objectFrom(Json.toJson(cookieStore)));
|
||||||
|
SpiderDebug.log("SimpleCookieJar cookieStore: " + Json.toJson(cookieStore));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<Cookie> loadForRequest(HttpUrl url) {
|
||||||
|
|
||||||
|
|
||||||
|
var cookies = cookieStore.get(url.host());
|
||||||
|
SpiderDebug.log(" SimpleCookieJar loadForRequest: " + url.host() + ": " + Json.toJson(cookies));
|
||||||
|
return cookies != null ? cookies : new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlobalCookie(JsonObject jsonObject) {
|
||||||
|
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
JsonArray value = entry.getValue().getAsJsonArray();
|
||||||
|
for (JsonElement element : value) {
|
||||||
|
JsonObject cookieobj = element.getAsJsonObject();
|
||||||
|
Cookie.Builder cookieBuilder = new Cookie.Builder().name(cookieobj.get("name").getAsString()).value(cookieobj.get("value").getAsString())
|
||||||
|
|
||||||
|
.expiresAt(cookieobj.get("expiresAt").getAsLong()).path(cookieobj.get("path").getAsString());
|
||||||
|
|
||||||
|
boolean secure = cookieobj.get("secure").getAsBoolean();
|
||||||
|
if (secure) {
|
||||||
|
cookieBuilder.secure();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean httpOnly = cookieobj.get("httpOnly").getAsBoolean();
|
||||||
|
if (httpOnly) {
|
||||||
|
cookieBuilder.httpOnly();
|
||||||
|
}
|
||||||
|
boolean persistent = cookieobj.get("persistent").getAsBoolean();
|
||||||
|
/* if (persistent) {
|
||||||
|
cookieBuilder.persistent();
|
||||||
|
}*/
|
||||||
|
boolean hostOnly = cookieobj.get("hostOnly").getAsBoolean();
|
||||||
|
if (hostOnly) {
|
||||||
|
cookieBuilder.hostOnlyDomain(cookieobj.get("domain").getAsString());
|
||||||
|
}else {
|
||||||
|
cookieBuilder.domain(cookieobj.get("domain").getAsString());
|
||||||
|
|
||||||
|
}
|
||||||
|
Cookie cookies = cookieBuilder.build();
|
||||||
|
|
||||||
|
|
||||||
|
// 设置全局Cookie
|
||||||
|
List<Cookie> cookiesForHost = cookieStore.get(key) == null ? new ArrayList<>() : cookieStore.get(key);
|
||||||
|
cookiesForHost.add(cookies);
|
||||||
|
cookieStore.put(key, cookiesForHost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<Cookie>> getCookie() {
|
||||||
|
return cookieStore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,9 +8,8 @@ import android.view.Gravity;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import com.github.catvod.bean.tianyi.Cache;
|
import com.github.catvod.bean.tianyi.Cache;
|
||||||
import com.github.catvod.bean.tianyi.User;
|
|
||||||
import com.github.catvod.crawler.SpiderDebug;
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttpWithCookie;
|
||||||
import com.github.catvod.net.OkResult;
|
import com.github.catvod.net.OkResult;
|
||||||
import com.github.catvod.spider.Init;
|
import com.github.catvod.spider.Init;
|
||||||
import com.github.catvod.utils.*;
|
import com.github.catvod.utils.*;
|
||||||
|
|
@ -19,7 +18,6 @@ import okhttp3.Headers;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
@ -51,69 +49,69 @@ public class TianYiHandler {
|
||||||
|
|
||||||
private String reqId;
|
private String reqId;
|
||||||
private String lt;
|
private String lt;
|
||||||
private Map<String, String> cookieMap;
|
|
||||||
private Map<String, String> ecookieMap;
|
private SimpleCookieJar cookieJar;
|
||||||
private String cookie;
|
|
||||||
private String ecookie;
|
|
||||||
|
|
||||||
public TianYiHandler() {
|
public TianYiHandler() {
|
||||||
|
|
||||||
cookieMap = new HashMap<>();
|
|
||||||
ecookieMap = new HashMap<>();
|
|
||||||
cache = Cache.objectFrom(Path.read(getCache()));
|
cache = Cache.objectFrom(Path.read(getCache()));
|
||||||
ecache = Cache.objectFrom(Path.read(geteCache()));
|
ecache = Cache.objectFrom(Path.read(geteCache()));
|
||||||
cookie = cache.getUser().getCookie();
|
|
||||||
ecookie = ecache.getUser().getCookie();
|
cookieJar = new SimpleCookieJar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCookieJar getCookieJar() {
|
||||||
|
return cookieJar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCookie(JsonObject cookie) {
|
||||||
|
cookieJar.setGlobalCookie(cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshCookie() throws IOException {
|
public void refreshCookie() throws IOException {
|
||||||
|
|
||||||
|
|
||||||
String url = "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fweb%2Fredirect.html";
|
String url = "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fweb%2Fredirect.html&defaultSaveName=3&defaultSaveNameCheck=uncheck&browserId=16322f24d9405fb83331c3f6ce971b53";
|
||||||
String index = OkHttp.getLocation(url, Map.of("Cookie", this.cookie));
|
String index = OkHttpWithCookie.getLocation(url, Map.of("Cookie", ""), cookieJar);
|
||||||
SpiderDebug.log("index:" + index);
|
SpiderDebug.log("index:" + index);
|
||||||
SpiderDebug.log("index red: " + index);
|
SpiderDebug.log("index red: " + index);
|
||||||
Map<String, List<String>> resHeaderMap = OkHttp.getLocationHeader(index, Map.of("Cookie", this.ecookie));
|
Map<String, List<String>> resHeaderMap = OkHttpWithCookie.getLocationHeader(index, Map.of("Cookie", ""), cookieJar);
|
||||||
|
|
||||||
|
|
||||||
getCookieMap(resHeaderMap.get("Set-Cookie"));
|
|
||||||
this.cookie = mapToCookie(cookieMap);
|
|
||||||
indexUrl = resHeaderMap.get("Location").get(0);
|
indexUrl = resHeaderMap.get("Location").get(0);
|
||||||
SpiderDebug.log("indexUrl red: " + indexUrl);
|
SpiderDebug.log("indexUrl red: " + indexUrl);
|
||||||
OkResult okResult = OkHttp.get(indexUrl, new HashMap<>(), Map.of("Cookie", this.cookie));
|
OkResult okResult = OkHttpWithCookie.get(indexUrl, new HashMap<>(), Map.of("Cookie", ""), cookieJar);
|
||||||
|
|
||||||
SpiderDebug.log("refreshCookie header:" + Json.toJson(okResult.getResp()));
|
SpiderDebug.log("refreshCookie header:" + Json.toJson(okResult.getResp()));
|
||||||
if (okResult.getResp().containsKey("set-cookie")) {
|
|
||||||
getCookieMap(okResult.getResp().get("set-cookie"));
|
|
||||||
this.cookie = mapToCookie(cookieMap);
|
|
||||||
cache.setTianyiUser(User.objectFrom(cookie));
|
|
||||||
SpiderDebug.log("获取cookie成功:" + cookie);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] startScan() throws Exception {
|
public byte[] startScan() throws Exception {
|
||||||
|
|
||||||
|
|
||||||
/* OkResult okResult1 = OkHttp.get("https://ux.21cn.com/api/htmlReportRest/getJs.js?pid=25577E0DEEDF48ADBD4459911F5825E4", new HashMap<>(), new HashMap<>());
|
/* OkResult okResult1 = OkHttp.get("https://ux.21cn.com/api/htmlReportRest/getJs.js?pid=25577E0DEEDF48ADBD4459911F5825E4", new HashMap<>(), new HashMap<>());
|
||||||
|
|
||||||
getCookieMap(okResult1.getResp().get("Set-Cookie"));
|
getCookieMap(okResult1.getResp().get("Set-Cookie"));
|
||||||
this.cookie = mapToCookie(cookieMap);*/
|
this.cookie = mapToCookie(cookieMap);*/
|
||||||
SpiderDebug.log("index ori: " + "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fweb%2Fredirect.html&defaultSaveName=3&defaultSaveNameCheck=uncheck&browserId=dff95dced0b03d9d972d920f03ddd05e");
|
SpiderDebug.log("index ori: " + "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fweb%2Fredirect.html&defaultSaveName=3&defaultSaveNameCheck=uncheck&browserId=dff95dced0b03d9d972d920f03ddd05e");
|
||||||
String index = OkHttp.getLocation("https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https://cloud.189.cn/web/redirect.html&defaultSaveName=3&defaultSaveNameCheck=uncheck&browserId=8d38da4344fba4699d13d6e6854319d7", Map.of("Cookie", ""));
|
String index = OkHttpWithCookie.getLocation("https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https://cloud.189.cn/web/redirect.html&defaultSaveName=3&defaultSaveNameCheck=uncheck&browserId=8d38da4344fba4699d13d6e6854319d7", Map.of("Cookie", ""), cookieJar);
|
||||||
SpiderDebug.log("index red: " + index);
|
SpiderDebug.log("index red: " + index);
|
||||||
Map<String, List<String>> resHeaderMap = OkHttp.getLocationHeader(index, new HashMap<>());
|
Map<String, List<String>> resHeaderMap = OkHttpWithCookie.getLocationHeader(index, new HashMap<>(), cookieJar);
|
||||||
|
|
||||||
indexUrl = resHeaderMap.get("Location").get(0);
|
indexUrl = resHeaderMap.get("Location").get(0);
|
||||||
SpiderDebug.log("indexUrl red: " + indexUrl);
|
SpiderDebug.log("indexUrl red: " + indexUrl);
|
||||||
|
|
||||||
|
|
||||||
getCookieMap(resHeaderMap.get("Set-Cookie"));
|
/* getCookieMap(resHeaderMap.get("Set-Cookie"));
|
||||||
this.cookie = mapToCookie(cookieMap);
|
this.cookie = mapToCookie(cookieMap);
|
||||||
SpiderDebug.log("secondCookie: " + cookie);
|
SpiderDebug.log("secondCookie: " + cookie);*/
|
||||||
|
|
||||||
HttpUrl httpParams = HttpUrl.parse(indexUrl);
|
HttpUrl httpParams = HttpUrl.parse(indexUrl);
|
||||||
reqId = httpParams.queryParameter("reqId");
|
reqId = httpParams.queryParameter("reqId");
|
||||||
lt = httpParams.queryParameter("lt");
|
lt = httpParams.queryParameter("lt");
|
||||||
|
|
||||||
Result result = appConf(this.cookie);
|
Result result = appConf();
|
||||||
|
|
||||||
// Step 1: Get UUID
|
// Step 1: Get UUID
|
||||||
JsonObject uuidInfo = getUUID();
|
JsonObject uuidInfo = getUUID();
|
||||||
|
|
@ -122,12 +120,12 @@ public class TianYiHandler {
|
||||||
String encodeuuid = uuidInfo.get("encodeuuid").getAsString();
|
String encodeuuid = uuidInfo.get("encodeuuid").getAsString();
|
||||||
|
|
||||||
// Step 2: Get QR Code
|
// Step 2: Get QR Code
|
||||||
byte[] byteStr = downloadQRCode(encodeuuid, reqId, cookie);
|
byte[] byteStr = downloadQRCode(encodeuuid, reqId);
|
||||||
|
|
||||||
Init.run(() -> showQRCode(byteStr));
|
Init.run(() -> showQRCode(byteStr));
|
||||||
// Step 3: Check login status
|
// Step 3: Check login status
|
||||||
// return
|
// return
|
||||||
Init.execute(() -> startService(uuid, encryuuid, reqId, lt, result.paramId, result.returnUrl, cookie));
|
Init.execute(() -> startService(uuid, encryuuid, reqId, lt, result.paramId, result.returnUrl));
|
||||||
/*Map<String, Object> result = new HashMap<>();
|
/*Map<String, Object> result = new HashMap<>();
|
||||||
result.put("qrcode", "data:image/png;base64," + qrCode);
|
result.put("qrcode", "data:image/png;base64," + qrCode);
|
||||||
result.put("status", "NEW");*/
|
result.put("status", "NEW");*/
|
||||||
|
|
@ -143,15 +141,15 @@ public class TianYiHandler {
|
||||||
|
|
||||||
OkResult okResult;
|
OkResult okResult;
|
||||||
if ("GET".equals(method)) {
|
if ("GET".equals(method)) {
|
||||||
okResult = OkHttp.get(this.API_URL + url, params, headers);
|
okResult = OkHttpWithCookie.get(this.API_URL + url, params, headers, cookieJar);
|
||||||
} else {
|
} else {
|
||||||
okResult = OkHttp.post(this.API_URL + url, params, headers);
|
okResult = OkHttpWithCookie.post(this.API_URL + url, params, headers, cookieJar);
|
||||||
}
|
}
|
||||||
if (okResult.getResp().get("Set-Cookie") != null) {
|
/* if (okResult.getResp().get("Set-Cookie") != null) {
|
||||||
geteCookieMap(okResult.getResp().get("Set-Cookie"));
|
geteCookieMap(okResult.getResp().get("Set-Cookie"));
|
||||||
this.ecookie = mapToCookie(ecookieMap);
|
this.ecookie = mapToCookie(ecookieMap);
|
||||||
SpiderDebug.log("cookie: " + this.ecookie);
|
SpiderDebug.log("cookie: " + this.ecookie);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (okResult.getCode() != 200 && leftRetry > 0) {
|
if (okResult.getCode() != 200 && leftRetry > 0) {
|
||||||
SpiderDebug.log("请求" + url + " failed;");
|
SpiderDebug.log("请求" + url + " failed;");
|
||||||
|
|
@ -165,11 +163,11 @@ public class TianYiHandler {
|
||||||
/**
|
/**
|
||||||
* 获取appConf
|
* 获取appConf
|
||||||
*
|
*
|
||||||
* @param secondCookie
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private @NotNull Result appConf(String secondCookie) throws Exception {
|
private @NotNull Result appConf() throws Exception {
|
||||||
Map<String, String> tHeaders = new HashMap<>();
|
Map<String, String> tHeaders = new HashMap<>();
|
||||||
tHeaders.put("Content-Type", "application/x-www-form-urlencoded");
|
tHeaders.put("Content-Type", "application/x-www-form-urlencoded");
|
||||||
tHeaders.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0");
|
tHeaders.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0");
|
||||||
|
|
@ -177,7 +175,7 @@ public class TianYiHandler {
|
||||||
tHeaders.put("origin", API_URL);
|
tHeaders.put("origin", API_URL);
|
||||||
tHeaders.put("Lt", lt);
|
tHeaders.put("Lt", lt);
|
||||||
tHeaders.put("Reqid", reqId);
|
tHeaders.put("Reqid", reqId);
|
||||||
tHeaders.put("Cookie", secondCookie);
|
//tHeaders.put("Cookie", secondCookie);
|
||||||
Map<String, String> param = new HashMap<>();
|
Map<String, String> param = new HashMap<>();
|
||||||
|
|
||||||
param.put("version", "2.0");
|
param.put("version", "2.0");
|
||||||
|
|
@ -215,46 +213,6 @@ public class TianYiHandler {
|
||||||
return cookieList;
|
return cookieList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 现有方法:List转Map(已优化)
|
|
||||||
private void getCookieMap(List<String> cookie) {
|
|
||||||
|
|
||||||
for (String s : cookie) {
|
|
||||||
String[] split = s.split(";");
|
|
||||||
String cookieItem = split[0].trim();
|
|
||||||
int equalsIndex = cookieItem.indexOf('=');
|
|
||||||
if (equalsIndex > 0) {
|
|
||||||
String key = cookieItem.substring(0, equalsIndex);
|
|
||||||
String value = equalsIndex < cookieItem.length() - 1 ? cookieItem.substring(equalsIndex + 1) : "";
|
|
||||||
cookieMap.put(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void geteCookieMap(List<String> cookie) {
|
|
||||||
|
|
||||||
for (String s : cookie) {
|
|
||||||
String[] split = s.split(";");
|
|
||||||
String cookieItem = split[0].trim();
|
|
||||||
int equalsIndex = cookieItem.indexOf('=');
|
|
||||||
if (equalsIndex > 0) {
|
|
||||||
String key = cookieItem.substring(0, equalsIndex);
|
|
||||||
String value = equalsIndex < cookieItem.length() - 1 ? cookieItem.substring(equalsIndex + 1) : "";
|
|
||||||
ecookieMap.put(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增方法:Map转Cookie字符串
|
|
||||||
private String mapToCookie(Map<String, String> map) {
|
|
||||||
if (map == null || map.isEmpty()) return "";
|
|
||||||
List<String> joiner = new ArrayList<>();
|
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
||||||
joiner.add(entry.getKey() + "=" + entry.getValue());
|
|
||||||
}
|
|
||||||
return StringUtils.join(joiner, ";");
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonObject getUUID() throws InterruptedException {
|
public JsonObject getUUID() throws InterruptedException {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
|
|
@ -271,20 +229,20 @@ public class TianYiHandler {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadQRCode(String uuid, String reqId, String cookie) throws IOException {
|
public byte[] downloadQRCode(String uuid, String reqId) throws IOException {
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> headers = new HashMap<>();
|
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) Chrome/99.0.4844.51 Safari/537.36");
|
headers.put("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36");
|
||||||
|
|
||||||
headers.put("referer", indexUrl);
|
headers.put("referer", indexUrl);
|
||||||
headers.put("cookie", cookie);
|
|
||||||
// OkResult okResult = OkHttp.get("https://open.e.189.cn/api/logbox/oauth2/image.do", params, headers);
|
// OkResult okResult = OkHttp.get("https://open.e.189.cn/api/logbox/oauth2/image.do", params, headers);
|
||||||
//.addQueryParameter("uuid", uuid).addQueryParameter("REQID", reqId)
|
//.addQueryParameter("uuid", uuid).addQueryParameter("REQID", reqId)
|
||||||
HttpUrl url = HttpUrl.parse(API_URL + "/api/logbox/oauth2/image.do?uuid=" + uuid + "&REQID=" + reqId).newBuilder().build();
|
HttpUrl url = HttpUrl.parse(API_URL + "/api/logbox/oauth2/image.do?uuid=" + uuid + "&REQID=" + reqId).newBuilder().build();
|
||||||
|
|
||||||
Request request = new Request.Builder().url(url).headers(Headers.of(headers)).build();
|
Request request = new Request.Builder().url(url).headers(Headers.of(headers)).build();
|
||||||
Response response = OkHttp.newCall(request);
|
Response response = OkHttpWithCookie.newCall(request, cookieJar);
|
||||||
if (response.code() == 200) {
|
if (response.code() == 200) {
|
||||||
return response.body().bytes();
|
return response.body().bytes();
|
||||||
}
|
}
|
||||||
|
|
@ -292,7 +250,7 @@ public class TianYiHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, Object> checkLoginStatus(String uuid, String encryuuid, String reqId, String lt, String paramId, String returnUrl, String secondCookie) throws Exception {
|
private Map<String, Object> checkLoginStatus(String uuid, String encryuuid, String reqId, String lt, String paramId, String returnUrl) throws Exception {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("appId", "cloud");
|
params.put("appId", "cloud");
|
||||||
params.put("encryuuid", encryuuid);
|
params.put("encryuuid", encryuuid);
|
||||||
|
|
@ -309,7 +267,7 @@ public class TianYiHandler {
|
||||||
headers.put("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36");
|
headers.put("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36");
|
||||||
headers.put("referer", indexUrl);
|
headers.put("referer", indexUrl);
|
||||||
headers.put("Reqid", reqId);
|
headers.put("Reqid", reqId);
|
||||||
headers.put("cookie", secondCookie);
|
|
||||||
String body = api("/api/logbox/oauth2/qrcodeLoginState.do", params, headers, 3, "POST");
|
String body = api("/api/logbox/oauth2/qrcodeLoginState.do", params, headers, 3, "POST");
|
||||||
// OkResult okResult = OkHttp.post(API_URL + "/api/logbox/oauth2/qrcodeLoginState.do", params, headers);
|
// OkResult okResult = OkHttp.post(API_URL + "/api/logbox/oauth2/qrcodeLoginState.do", params, headers);
|
||||||
SpiderDebug.log("qrcodeLoginState result------" + body);
|
SpiderDebug.log("qrcodeLoginState result------" + body);
|
||||||
|
|
@ -321,7 +279,7 @@ public class TianYiHandler {
|
||||||
String redirectUrl = obj.get("redirectUrl").getAsString();
|
String redirectUrl = obj.get("redirectUrl").getAsString();
|
||||||
|
|
||||||
|
|
||||||
fetchUserInfo(redirectUrl, secondCookie);
|
fetchUserInfo(redirectUrl);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -332,22 +290,15 @@ public class TianYiHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchUserInfo(String redirectUrl, String secondCookie) throws IOException {
|
private void fetchUserInfo(String redirectUrl) throws IOException {
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put("Cookie", secondCookie);
|
|
||||||
Map<String, List<String>> okResult = OkHttp.getLocationHeader(redirectUrl, headers);
|
Map<String, List<String>> okResult = OkHttpWithCookie.getLocationHeader(redirectUrl, headers, cookieJar);
|
||||||
SpiderDebug.log("扫码返回数据:" + Json.toJson(okResult));
|
SpiderDebug.log("扫码返回数据:" + Json.toJson(okResult));
|
||||||
if (okResult.containsKey("set-cookie")) {
|
if (okResult.containsKey("set-cookie")) {
|
||||||
getCookieMap(okResult.get("Set-Cookie"));
|
|
||||||
this.cookie = mapToCookie(cookieMap);
|
|
||||||
|
|
||||||
|
|
||||||
cache.setTianyiUser(User.objectFrom(cookie));
|
|
||||||
ecache.setTianyieUser(User.objectFrom(ecookie));
|
|
||||||
SpiderDebug.log("获取cookie成功:" + cookie);
|
|
||||||
SpiderDebug.log("获取ecookie成功:" + ecookie);
|
|
||||||
//停止检验线程,关闭弹窗
|
//停止检验线程,关闭弹窗
|
||||||
stopService();
|
stopService();
|
||||||
}
|
}
|
||||||
|
|
@ -399,7 +350,7 @@ public class TianYiHandler {
|
||||||
Init.run(this::dismiss);
|
Init.run(this::dismiss);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startService(String uuid, String encryuuid, String reqId, String lt, String paramId, String returnUrl, String secondCookie) {
|
public void startService(String uuid, String encryuuid, String reqId, String lt, String paramId, String returnUrl) {
|
||||||
SpiderDebug.log("----start checkLoginStatus service");
|
SpiderDebug.log("----start checkLoginStatus service");
|
||||||
|
|
||||||
service = Executors.newScheduledThreadPool(1);
|
service = Executors.newScheduledThreadPool(1);
|
||||||
|
|
@ -407,7 +358,7 @@ public class TianYiHandler {
|
||||||
service.scheduleWithFixedDelay(() -> {
|
service.scheduleWithFixedDelay(() -> {
|
||||||
SpiderDebug.log("----checkLoginStatus ing....");
|
SpiderDebug.log("----checkLoginStatus ing....");
|
||||||
try {
|
try {
|
||||||
checkLoginStatus(uuid, encryuuid, reqId, lt, paramId, returnUrl, secondCookie);
|
checkLoginStatus(uuid, encryuuid, reqId, lt, paramId, returnUrl);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SpiderDebug.log("----checkLoginStatus error" + e.getMessage());
|
SpiderDebug.log("----checkLoginStatus error" + e.getMessage());
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,10 @@ package com.github.catvod.api;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
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.bean.quark.Cache;
|
|
||||||
import com.github.catvod.bean.tianyi.Item;
|
import com.github.catvod.bean.tianyi.Item;
|
||||||
import com.github.catvod.bean.tianyi.ShareData;
|
import com.github.catvod.bean.tianyi.ShareData;
|
||||||
import com.github.catvod.crawler.SpiderDebug;
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttpWithCookie;
|
||||||
import com.github.catvod.net.OkResult;
|
import com.github.catvod.net.OkResult;
|
||||||
import com.github.catvod.spider.Init;
|
import com.github.catvod.spider.Init;
|
||||||
import com.github.catvod.spider.Proxy;
|
import com.github.catvod.spider.Proxy;
|
||||||
|
|
@ -27,15 +26,15 @@ import java.util.regex.Pattern;
|
||||||
public class TianyiApi {
|
public class TianyiApi {
|
||||||
private String apiUrl = "https://cloud.189.cn/api/open/share/";
|
private String apiUrl = "https://cloud.189.cn/api/open/share/";
|
||||||
public static final String URL_START = "https://cloud.189.cn/";
|
public static final String URL_START = "https://cloud.189.cn/";
|
||||||
private String cookie = "";
|
|
||||||
|
|
||||||
private Map<String, JsonObject> shareTokenCache = new HashMap<>();
|
private Map<String, JsonObject> shareTokenCache = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
private final Cache cache;
|
|
||||||
private ScheduledExecutorService service;
|
private ScheduledExecutorService service;
|
||||||
private String sessionKey = "";
|
private String sessionKey = "";
|
||||||
private TianYiHandler tianYiHandler;
|
private TianYiHandler tianYiHandler;
|
||||||
|
private SimpleCookieJar cookieJar;
|
||||||
|
|
||||||
|
|
||||||
public String[] getPlayFormatList() {
|
public String[] getPlayFormatList() {
|
||||||
|
|
@ -52,9 +51,12 @@ public class TianyiApi {
|
||||||
|
|
||||||
public void setCookie(String token) throws Exception {
|
public void setCookie(String token) throws Exception {
|
||||||
if (StringUtils.isNoneBlank(token)) {
|
if (StringUtils.isNoneBlank(token)) {
|
||||||
this.cookie = token;
|
JsonObject obj = Json.safeObject(token);
|
||||||
initUserInfo();
|
//初始化CookieJar
|
||||||
|
tianYiHandler.setCookie(obj);
|
||||||
}
|
}
|
||||||
|
getUserSizeInfo();
|
||||||
|
this.sessionKey = getUserBriefInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> getHeaders() {
|
private Map<String, String> getHeaders() {
|
||||||
|
|
@ -63,7 +65,7 @@ public class TianyiApi {
|
||||||
|
|
||||||
headers.put("Content-Type", "application/x-www-form-urlencoded");
|
headers.put("Content-Type", "application/x-www-form-urlencoded");
|
||||||
headers.put("accept", "application/json;charset=UTF-8");
|
headers.put("accept", "application/json;charset=UTF-8");
|
||||||
headers.put("Cookie", cookie);
|
|
||||||
if (StringUtils.isNotBlank(sessionKey)) {
|
if (StringUtils.isNotBlank(sessionKey)) {
|
||||||
headers.put("sessionKey", sessionKey);
|
headers.put("sessionKey", sessionKey);
|
||||||
}
|
}
|
||||||
|
|
@ -72,18 +74,11 @@ public class TianyiApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void init(String cookie) throws Exception {
|
|
||||||
|
|
||||||
this.cookie = cookie;
|
|
||||||
|
|
||||||
getUserSizeInfo();
|
|
||||||
this.sessionKey = getUserBriefInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private TianyiApi() {
|
private TianyiApi() {
|
||||||
Init.checkPermission();
|
Init.checkPermission();
|
||||||
cache = Cache.objectFrom(Path.read(getCache()));
|
|
||||||
tianYiHandler = new TianYiHandler();
|
tianYiHandler = new TianYiHandler();
|
||||||
|
cookieJar = tianYiHandler.getCookieJar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getCache() {
|
public File getCache() {
|
||||||
|
|
@ -164,15 +159,12 @@ public class TianyiApi {
|
||||||
|
|
||||||
|
|
||||||
int leftRetry = retry != null ? retry : 3;
|
int leftRetry = retry != null ? retry : 3;
|
||||||
if (StringUtils.isAllBlank(cookie)) {
|
|
||||||
this.initUserInfo();
|
|
||||||
return api(url, params, data, leftRetry - 1, method);
|
|
||||||
}
|
|
||||||
OkResult okResult;
|
OkResult okResult;
|
||||||
if ("GET".equals(method)) {
|
if ("GET".equals(method)) {
|
||||||
okResult = OkHttp.get(this.apiUrl + url, params, getHeaders());
|
okResult = OkHttpWithCookie.get(this.apiUrl + url, params, getHeaders(), cookieJar);
|
||||||
} else {
|
} else {
|
||||||
okResult = OkHttp.post(this.apiUrl + url, Json.toJson(data), getHeaders());
|
okResult = OkHttpWithCookie.post(this.apiUrl + url, Json.toJson(data), getHeaders(), cookieJar);
|
||||||
}
|
}
|
||||||
/* if (okResult.getResp().get("Set-Cookie") != null) {
|
/* if (okResult.getResp().get("Set-Cookie") != null) {
|
||||||
Matcher matcher = Pattern.compile("__puus=([^;]+)").matcher(StringUtils.join(okResult.getResp().get("Set-Cookie"), ";;;"));
|
Matcher matcher = Pattern.compile("__puus=([^;]+)").matcher(StringUtils.join(okResult.getResp().get("Set-Cookie"), ";;;"));
|
||||||
|
|
@ -194,55 +186,6 @@ public class TianyiApi {
|
||||||
return okResult.getBody();
|
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) {
|
public ShareData getShareData(String url, String accessCode) {
|
||||||
String shareCode = "";
|
String shareCode = "";
|
||||||
|
|
@ -284,18 +227,18 @@ public class TianyiApi {
|
||||||
|
|
||||||
|
|
||||||
private String getUserBriefInfo() throws Exception {
|
private String getUserBriefInfo() throws Exception {
|
||||||
OkResult result = OkHttp.get("https://cloud.189.cn/api/portal/v2/getUserBriefInfo.action", new HashMap<>(), getHeaders());
|
OkResult result = OkHttpWithCookie.get("https://cloud.189.cn/api/portal/v2/getUserBriefInfo.action", new HashMap<>(), getHeaders(), cookieJar);
|
||||||
JsonObject obj = Json.safeObject(result.getBody());
|
JsonObject obj = Json.safeObject(result.getBody());
|
||||||
return obj.get("sessionKey").getAsString();
|
return obj.get("sessionKey").getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUserSizeInfo() throws Exception {
|
private String getUserSizeInfo() throws Exception {
|
||||||
OkResult result = OkHttp.get("https://cloud.189.cn/api/portal/getUserSizeInfo.action", new HashMap<>(), getHeaders());
|
OkResult result = OkHttpWithCookie.get("https://cloud.189.cn/api/portal/getUserSizeInfo.action", new HashMap<>(), getHeaders(), cookieJar);
|
||||||
JsonObject res = Json.safeObject(result.getBody());
|
JsonObject res = Json.safeObject(result.getBody());
|
||||||
if (res.isEmpty() || (Objects.nonNull(res.get("errorCode")) && res.get("errorCode").getAsString().equals("InvalidSessionKey"))) {
|
if (res.isEmpty() || (Objects.nonNull(res.get("errorCode")) && res.get("errorCode").getAsString().equals("InvalidSessionKey"))) {
|
||||||
// tianYiHandler.startScan();
|
// tianYiHandler.startScan();
|
||||||
//tianYiHandler.refreshCookie(cookie);
|
tianYiHandler.refreshCookie();
|
||||||
tianYiHandler.startScan();
|
//tianYiHandler.startScan();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
|
@ -335,11 +278,11 @@ public class TianyiApi {
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
if (Objects.nonNull(shareToken.get("res_code")) && shareToken.get("res_code").getAsInt() == 0) {
|
if (Objects.nonNull(shareToken.get("res_code")) && shareToken.get("res_code").getAsInt() == 0) {
|
||||||
shareData.setShareId((String) shareToken.get("shareId").getAsString());
|
shareData.setShareId(shareToken.get("shareId").getAsString());
|
||||||
shareData.setShareMode((Integer) shareToken.get("shareMode").getAsInt());
|
shareData.setShareMode(shareToken.get("shareMode").getAsInt());
|
||||||
shareData.setFolder(shareToken.get("isFolder").getAsBoolean());
|
shareData.setFolder(shareToken.get("isFolder").getAsBoolean());
|
||||||
shareData.setFileId((String) shareToken.get("fileId").getAsString());
|
shareData.setFileId(shareToken.get("fileId").getAsString());
|
||||||
shareData.setFolderId((String) shareToken.get("fileId").getAsString());
|
shareData.setFolderId(shareToken.get("fileId").getAsString());
|
||||||
|
|
||||||
this.shareTokenCache.put(shareData.getShareId(), shareToken);
|
this.shareTokenCache.put(shareData.getShareId(), shareToken);
|
||||||
}
|
}
|
||||||
|
|
@ -422,7 +365,7 @@ public class TianyiApi {
|
||||||
private String getDownload(String shareId, String fileId) throws Exception {
|
private String getDownload(String shareId, String fileId) throws Exception {
|
||||||
Map<String, String> headers = getHeaders();
|
Map<String, String> headers = getHeaders();
|
||||||
//headers.remove("sessionKey");
|
//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);
|
OkResult result = OkHttpWithCookie.get("https://cloud.189.cn/api/portal/getNewVlcVideoPlayUrl.action?shareId=" + shareId + "&dt=1&fileId=" + fileId + "&type=4&key=noCache", new HashMap<>(), headers, cookieJar);
|
||||||
JsonObject res = Json.safeObject(result.getBody());
|
JsonObject res = Json.safeObject(result.getBody());
|
||||||
if (Objects.nonNull(res.get("res_code")) && res.get("res_code").getAsInt() == 0) {
|
if (Objects.nonNull(res.get("res_code")) && res.get("res_code").getAsInt() == 0) {
|
||||||
|
|
||||||
|
|
@ -432,30 +375,17 @@ public class TianyiApi {
|
||||||
SpiderDebug.log("获取天翼下载地址成功:" + normal);
|
SpiderDebug.log("获取天翼下载地址成功:" + normal);
|
||||||
return normal;
|
return normal;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (res.get("errorCode") != null && res.get("errorCode").getAsString().equals("InvalidSessionKey")) {
|
||||||
SpiderDebug.log("获取下载地址失败:" + result.getBody());
|
//刷新cookie
|
||||||
|
SpiderDebug.log("cookie 过期,刷新cookie。。。。");
|
||||||
|
tianYiHandler.refreshCookie();
|
||||||
|
//重试下载
|
||||||
|
SpiderDebug.log("重试下载。。。。");
|
||||||
|
getDownload(shareId, fileId);
|
||||||
}
|
}
|
||||||
return "";
|
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,111 @@
|
||||||
|
package com.github.catvod.net;
|
||||||
|
|
||||||
|
import com.github.catvod.crawler.Spider;
|
||||||
|
import okhttp3.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class OkHttpWithCookie {
|
||||||
|
|
||||||
|
public static final String POST = "POST";
|
||||||
|
public static final String GET = "GET";
|
||||||
|
|
||||||
|
private OkHttpClient client;
|
||||||
|
|
||||||
|
|
||||||
|
private static class Loader {
|
||||||
|
static volatile OkHttpWithCookie INSTANCE = new OkHttpWithCookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OkHttpWithCookie get() {
|
||||||
|
return Loader.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Response newCall(Request request, CookieJar cookieJar) throws IOException {
|
||||||
|
return client(cookieJar).newCall(request).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Response newCall(String url, CookieJar cookieJar) throws IOException {
|
||||||
|
return client(cookieJar).newCall(new Request.Builder().url(url).build()).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Response newCall(String url, Map<String, String> header, CookieJar cookieJar) throws IOException {
|
||||||
|
return client(cookieJar).newCall(new Request.Builder().url(url).headers(Headers.of(header)).build()).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String string(String url, CookieJar cookieJar) {
|
||||||
|
return string(url, null, cookieJar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String string(String url, Map<String, String> header, CookieJar cookieJar) {
|
||||||
|
return string(url, null, header, cookieJar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String string(String url, Map<String, String> params, Map<String, String> header, CookieJar cookieJar) {
|
||||||
|
return url.startsWith("http") ? new OkRequest(GET, url, params, header).execute(client(cookieJar)).getBody() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OkResult get(String url, Map<String, String> params, Map<String, String> header, CookieJar cookieJar) {
|
||||||
|
return new OkRequest(GET, url, params, header).execute(client(cookieJar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String post(String url, Map<String, String> params, CookieJar cookieJar) {
|
||||||
|
return post(url, params, null, cookieJar).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OkResult post(String url, Map<String, String> params, Map<String, String> header, CookieJar cookieJar) {
|
||||||
|
return new OkRequest(POST, url, params, header).execute(client(cookieJar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String post(String url, String json, CookieJar cookieJar) {
|
||||||
|
return post(url, json, null, cookieJar).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OkResult post(String url, String json, Map<String, String> header, CookieJar cookieJar) {
|
||||||
|
return new OkRequest(POST, url, json, header).execute(client(cookieJar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLocation(String url, Map<String, String> header, CookieJar cookieJar) throws IOException {
|
||||||
|
return getLocation(client(cookieJar).newBuilder().followRedirects(false).followSslRedirects(false).build().newCall(new Request.Builder().url(url).headers(Headers.of(header)).build()).execute().headers().toMultimap());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, List<String>> getLocationHeader(String url, Map<String, String> header, CookieJar cookieJar) throws IOException {
|
||||||
|
return client(cookieJar).newBuilder().followRedirects(false).followSslRedirects(false).build().newCall(new Request.Builder().url(url).headers(Headers.of(header)).build()).execute().headers().toMultimap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLocation(Map<String, List<String>> headers) {
|
||||||
|
if (headers == null) return null;
|
||||||
|
if (headers.containsKey("location")) return headers.get("location").get(0);
|
||||||
|
if (headers.containsKey("Location")) return headers.get("Location").get(0);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OkHttpClient build(CookieJar cookieJar) {
|
||||||
|
if (get().client != null) return get().client;
|
||||||
|
return get().client = getBuilder(cookieJar).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OkHttpClient.Builder getBuilder(CookieJar cookieJar) {
|
||||||
|
return new OkHttpClient.Builder().cookieJar(cookieJar).dns(safeDns()).connectTimeout(30, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).hostnameVerifier((hostname, session) -> true).sslSocketFactory(new SSLCompat(), SSLCompat.TM);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OkHttpClient client(CookieJar cookieJar) {
|
||||||
|
try {
|
||||||
|
return Objects.requireNonNull(Spider.client());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return build(cookieJar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dns safeDns() {
|
||||||
|
try {
|
||||||
|
return Objects.requireNonNull(Spider.safeDns());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return Dns.SYSTEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -28,20 +28,20 @@ public class TianYiTest {
|
||||||
Init.init(mockContext);
|
Init.init(mockContext);
|
||||||
spider = new TianYi();
|
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, "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");
|
spider.init(mockContext, "{\"open.e.189.cn\":[{\"name\":\"SSON\",\"value\":\"dc466c8192e3109eaea837c1d136c1fd065253ce1c7d3a66ca1520d7d6d6307b10a1fe65c7becac73b95f24a6e681e654ec4f47c39533ebcc48bb78d6d6e63d1bbf3334e6e97eaa7092d34f87bf1209ee35f344871bc5a329eac34ae948d399d4a6b3b28a929c4f353ade0981657e9e0f09ce27cc1c15d8322c6e45a8ebb21eb431509f1dd7dc3a7856b32b0991d654d5ced73dd20b764ca8737600cbe699c37ccf59b3c610893fc42bdc08b477c5d394e290c14d175d1ca0ee9fa61a1a8dcac7007e9219fd0ae6ccd5dc760524213f85b6b8c6166af01a31336dab797d9118010b81a5a3c26e08e\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":true,\"httpOnly\":true,\"persistent\":true,\"hostOnly\":false},{\"name\":\"GUID\",\"value\":\"525d8874e53e46a7ba3ed8907e9fef1f\",\"expiresAt\":1775176321000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false},{\"name\":\"pageOp\",\"value\":\"336b9ddc820212fa6c9b5a0cfd7bf5b3\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":false,\"hostOnly\":false},{\"name\":\"OPENINFO\",\"value\":\"33c28688ef52ce9e3a9ef87388047efbde5e3e2e4c7ef6ef267632468c7dfaf294ff59fa59d34801\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false},{\"name\":\"GRAYNUMBER\",\"value\":\"319DE3F68C8730862F3BEF66F3D635B7\",\"expiresAt\":1775177653000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false}],\"cloud.189.cn\":[{\"name\":\"JSESSIONID\",\"value\":\"431787526C43DF21B6373E914FE597EC\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":true},{\"name\":\"COOKIE_LOGIN_USER\",\"value\":\"0C7407F59A6E5896EB6B777056E160DB020BAE67B121B5930CCD4777073744055308F7E8CD03F2FC2399E4823F60ECDD74120CEE4C529017\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false}]}");
|
||||||
// Server.get().start();
|
// Server.get().start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@org.junit.Test
|
@org.junit.Test
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
spider.init(mockContext, "JSESSIONID=B35242EB04B3FBE672BED4B42F04D7E3;COOKIE_LOGIN_USER=B0A47E7C883DA2F0AFA9713E5D80E60955214A1445778CC40810306B68D7038FC568A6F20EAE2963519B17746FC9EB976F2317DE786E92E8CFCA5D36");
|
spider.init(mockContext, "{\"open.e.189.cn\":[{\"name\":\"SSON\",\"value\":\"dc466c8192e3109eaea837c1d136c1fd065253ce1c7d3a66ca1520d7d6d6307b10a1fe65c7becac73b95f24a6e681e654ec4f47c39533ebcc48bb78d6d6e63d1bbf3334e6e97eaa7092d34f87bf1209ee35f344871bc5a329eac34ae948d399d4a6b3b28a929c4f353ade0981657e9e0f09ce27cc1c15d8322c6e45a8ebb21eb431509f1dd7dc3a7856b32b0991d654d5ced73dd20b764ca8737600cbe699c37ccf59b3c610893fc42bdc08b477c5d394e290c14d175d1ca0ee9fa61a1a8dcac7007e9219fd0ae6ccd5dc760524213f85b6b8c6166af01a31336dab797d9118010b81a5a3c26e08e\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":true,\"httpOnly\":true,\"persistent\":true,\"hostOnly\":false},{\"name\":\"GUID\",\"value\":\"525d8874e53e46a7ba3ed8907e9fef1f\",\"expiresAt\":1775176321000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false},{\"name\":\"pageOp\",\"value\":\"336b9ddc820212fa6c9b5a0cfd7bf5b3\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":false,\"hostOnly\":false},{\"name\":\"OPENINFO\",\"value\":\"33c28688ef52ce9e3a9ef87388047efbde5e3e2e4c7ef6ef267632468c7dfaf294ff59fa59d34801\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false},{\"name\":\"GRAYNUMBER\",\"value\":\"319DE3F68C8730862F3BEF66F3D635B7\",\"expiresAt\":1775177653000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false}],\"cloud.189.cn\":[{\"name\":\"JSESSIONID\",\"value\":\"431787526C43DF21B6373E914FE597EC\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":true},{\"name\":\"COOKIE_LOGIN_USER\",\"value\":\"0C7407F59A6E5896EB6B777056E160DB020BAE67B121B5930CCD4777073744055308F7E8CD03F2FC2399E4823F60ECDD74120CEE4C529017\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false}]}");
|
||||||
//Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
//Assert.assertFalse(map.getAsJsonArray("list").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@org.junit.Test
|
@org.junit.Test
|
||||||
public void detailContent() throws Exception {
|
public void detailContent() throws Exception {
|
||||||
|
|
||||||
String content = spider.detailContent(Arrays.asList("https://cloud.189.cn/web/share?code=2eyARfBzURZj(访问码:kz6y)"));
|
String content = spider.detailContent(Arrays.asList("https://cloud.189.cn/web/share?code=ZvEjUvq6FNr2"));
|
||||||
System.out.println("detailContent--" + content);
|
System.out.println("detailContent--" + content);
|
||||||
JsonObject map = Json.safeObject(content);
|
JsonObject map = Json.safeObject(content);
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
|
@ -52,7 +52,7 @@ public class TianYiTest {
|
||||||
@org.junit.Test
|
@org.junit.Test
|
||||||
public void playerContent() throws Exception {
|
public void playerContent() throws Exception {
|
||||||
|
|
||||||
String content = spider.playerContent("普画","21309114537538085++12347115348228",new ArrayList<>());
|
String content = spider.playerContent("天意","523693138438437163++12314111132976",new ArrayList<>());
|
||||||
System.out.println("playerContent--" + content);
|
System.out.println("playerContent--" + content);
|
||||||
JsonObject map = Json.safeObject(content);
|
JsonObject map = Json.safeObject(content);
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.catvod.api;
|
package com.github.catvod.api;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import com.github.catvod.utils.Json;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -33,6 +34,19 @@ public class TianYiHandlerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refreshCookie() throws Exception {
|
||||||
|
|
||||||
|
JsonObject obj = Json.safeObject("{\"open.e.189.cn\":[{\"name\":\"SSON\",\"value\":\"dc466c8192e3109eaea837c1d136c1fd065253ce1c7d3a66ca1520d7d6d6307b10a1fe65c7becac73b95f24a6e681e654ec4f47c39533ebcc48bb78d6d6e63d1bbf3334e6e97eaa7092d34f87bf1209ee35f344871bc5a329eac34ae948d399d4a6b3b28a929c4f353ade0981657e9e0f09ce27cc1c15d8322c6e45a8ebb21eb431509f1dd7dc3a7856b32b0991d654d5ced73dd20b764ca8737600cbe699c37ccf59b3c610893fc42bdc08b477c5d394e290c14d175d1ca0ee9fa61a1a8dcac7007e9219fd0ae6ccd5dc760524213f85b6b8c6166af01a31336dab797d9118010b81a5a3c26e08e\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":true,\"httpOnly\":true,\"persistent\":true,\"hostOnly\":false},{\"name\":\"GUID\",\"value\":\"525d8874e53e46a7ba3ed8907e9fef1f\",\"expiresAt\":1775176321000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false},{\"name\":\"pageOp\",\"value\":\"336b9ddc820212fa6c9b5a0cfd7bf5b3\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":false,\"hostOnly\":false},{\"name\":\"OPENINFO\",\"value\":\"33c28688ef52ce9e3a9ef87388047efbde5e3e2e4c7ef6ef267632468c7dfaf294ff59fa59d34801\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false},{\"name\":\"GRAYNUMBER\",\"value\":\"319DE3F68C8730862F3BEF66F3D635B7\",\"expiresAt\":1775177653000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false}],\"cloud.189.cn\":[{\"name\":\"JSESSIONID\",\"value\":\"431787526C43DF21B6373E914FE597EC\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":true},{\"name\":\"COOKIE_LOGIN_USER\",\"value\":\"0C7407F59A6E5896EB6B777056E160DB020BAE67B121B5930CCD4777073744055308F7E8CD03F2FC2399E4823F60ECDD74120CEE4C529017\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false}]}");
|
||||||
|
tianYiHandler.setCookie(obj);
|
||||||
|
tianYiHandler.refreshCookie();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void download() throws Exception {
|
public void download() throws Exception {
|
||||||
// Mock the OkHttp.get method to return a predefined OkResult
|
// Mock the OkHttp.get method to return a predefined OkResult
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class TianyiApiTest {
|
||||||
|
|
||||||
com.github.catvod.bean.tianyi.ShareData shareData1 = TianyiApi.get().getShareData("https://cloud.189.cn/web/share?code=qEVVjyqM7bY3(访问码:6iel)", "");
|
com.github.catvod.bean.tianyi.ShareData shareData1 = TianyiApi.get().getShareData("https://cloud.189.cn/web/share?code=qEVVjyqM7bY3(访问码:6iel)", "");
|
||||||
TianyiApi api = TianyiApi.get();
|
TianyiApi api = TianyiApi.get();
|
||||||
api.setCookie("apm_ct=20250326080123000;OPENINFO=33c28688ef52ce9e3a9ef87388047efbde5e3e2e4c7ef6ef267632468c7dfaf294ff59fa59d34801;apm_sid=02F59AEE89AF29D6420BBD8408003B99;apm_key=317D96407B91CFC7EDA9010FA963CB06;pageOp=8b7ecdae02246019e5b5c07d5775e568;apm_uid=CD70AFED168CA30CF75CDBF983D237C2;LT=358459209f24f17e;GUID=a72822a1f8574d2c97b8392c067e835c;SSON=dc466c8192e3109eaea837c1d136c1fd065253ce1c7d3a66ca1520d7d6d6307b10a1fe65c7becac73b95f24a6e681e654ec4f47c39533ebcc48bb78d6d6e63d1bbf3334e6e97eaa7092d34f87bf1209e791a623d703df58b667c93cf9745938a396cfcc4e795bb687b7e16255f08379edd4f03e64b2002aa915c3157b008d54ed80b1ad57bf6b7405d23e0763077999425d511e0ccc0e07a952221985bf9903d10b9f21c4d6c175b5e9fb20721ef5b2926290dda57af27ff65ad5df045c8a824bebb4dcec0cd08a68edfc462d5bcd7a180b80b072ca61aa87dd0ebe3946397f94f0bc28d24a56958;JSESSIONID=58737554E5FEB36C9AF67050CE292E38;COOKIE_LOGIN_USER=92F4CEE641F1363A0EA09AC7FA6B61FDB6DD036333EFCD7F28818C64A94CFACC7C6186180FCEE7A6BD5E2A597347DBE58BA1C72D1493EE0847FD4F5A;apm_ua=45747CD36C19E71509E38183EB8AAB8D");
|
api.setCookie("{\"open.e.189.cn\":[{\"name\":\"SSON\",\"value\":\"dc466c8192e3109eaea837c1d136c1fd065253ce1c7d3a66ca1520d7d6d6307b10a1fe65c7becac73b95f24a6e681e654ec4f47c39533ebcc48bb78d6d6e63d1bbf3334e6e97eaa7092d34f87bf1209ee35f344871bc5a329eac34ae948d399d4a6b3b28a929c4f353ade0981657e9e0f09ce27cc1c15d8322c6e45a8ebb21eb431509f1dd7dc3a7856b32b0991d654d5ced73dd20b764ca8737600cbe699c37ccf59b3c610893fc42bdc08b477c5d394e290c14d175d1ca0ee9fa61a1a8dcac7007e9219fd0ae6ccd5dc760524213f85b6b8c6166af01a31336dab797d9118010b81a5a3c26e08e\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":true,\"httpOnly\":true,\"persistent\":true,\"hostOnly\":false},{\"name\":\"GUID\",\"value\":\"525d8874e53e46a7ba3ed8907e9fef1f\",\"expiresAt\":1775176321000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false},{\"name\":\"pageOp\",\"value\":\"336b9ddc820212fa6c9b5a0cfd7bf5b3\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":false,\"hostOnly\":false},{\"name\":\"OPENINFO\",\"value\":\"33c28688ef52ce9e3a9ef87388047efbde5e3e2e4c7ef6ef267632468c7dfaf294ff59fa59d34801\",\"expiresAt\":253402300799999,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false},{\"name\":\"GRAYNUMBER\",\"value\":\"319DE3F68C8730862F3BEF66F3D635B7\",\"expiresAt\":1775177653000,\"domain\":\"e.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":false,\"persistent\":true,\"hostOnly\":false}],\"cloud.189.cn\":[{\"name\":\"JSESSIONID\",\"value\":\"431787526C43DF21B6373E914FE597EC\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":true},{\"name\":\"COOKIE_LOGIN_USER\",\"value\":\"0C7407F59A6E5896EB6B777056E160DB020BAE67B121B5930CCD4777073744055308F7E8CD03F2FC2399E4823F60ECDD74120CEE4C529017\",\"expiresAt\":253402300799999,\"domain\":\"cloud.189.cn\",\"path\":\"/\",\"secure\":false,\"httpOnly\":true,\"persistent\":false,\"hostOnly\":false}]}");
|
||||||
api.getVod(shareData1);
|
api.getVod(shareData1);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
2564bdb95b6b930b55efb4bdfff9f588
|
bdc3251d091440120df0d7797bf148db
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://androidcatvodspider.netlify.app/jar/custom_spider.jar;md5;2564bdb95b6b930b55efb4bdfff9f588",
|
"spider": "https://raw.kkgithub.com/lushunming/AndroidCatVodSpider/tyCookieJar/jar/custom_spider.jar;md5;2564bdb95b6b930b55efb4bdfff9f588",
|
||||||
"lives": [
|
"lives": [
|
||||||
{
|
{
|
||||||
"name": "电视直播",
|
"name": "电视直播",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue