天意accessToken
This commit is contained in:
parent
0b895730e8
commit
e5447fc5a1
|
|
@ -12,6 +12,7 @@ import com.google.gson.JsonObject;
|
|||
import okhttp3.Cookie;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.HttpUrl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -34,6 +35,11 @@ public class SimpleCookieJar implements CookieJar {
|
|||
|
||||
public SimpleCookieJar() {
|
||||
this.cache = Cache.objectFrom(Path.read(getCache()));
|
||||
String cookieStr = cache.getUser().getCookie();
|
||||
if (StringUtils.isNoneBlank(cookieStr)) {
|
||||
JsonObject cookieJson = Json.safeObject(cookieStr);
|
||||
setGlobalCookie(cookieJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -45,14 +51,14 @@ public class SimpleCookieJar implements CookieJar {
|
|||
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> 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())){
|
||||
if (oldCookie.name().equals(newCookie.name())) {
|
||||
oldCookies.remove(oldCookie);
|
||||
}
|
||||
}
|
||||
|
|
@ -100,7 +106,7 @@ public class SimpleCookieJar implements CookieJar {
|
|||
boolean hostOnly = cookieobj.get("hostOnly").getAsBoolean();
|
||||
if (hostOnly) {
|
||||
cookieBuilder.hostOnlyDomain(cookieobj.get("domain").getAsString());
|
||||
}else {
|
||||
} else {
|
||||
cookieBuilder.domain(cookieobj.get("domain").getAsString());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public class TianYiHandler {
|
|||
private ScheduledExecutorService service;
|
||||
private AlertDialog dialog;
|
||||
private final Cache cache;
|
||||
private final Cache ecache;
|
||||
|
||||
public File getCache() {
|
||||
return Path.tv("tianyi");
|
||||
|
|
@ -56,8 +55,6 @@ public class TianYiHandler {
|
|||
|
||||
|
||||
cache = Cache.objectFrom(Path.read(getCache()));
|
||||
ecache = Cache.objectFrom(Path.read(geteCache()));
|
||||
|
||||
cookieJar = new SimpleCookieJar();
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
fabff6d0293436b616892579a9d1e3e3
|
||||
1d71c8fceb2eb53953b31019774eeb86
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.kkgithub.com/lushunming/AndroidCatVodSpider/tyCookieJar/jar/custom_spider.jar;md5;fabff6d0293436b616892579a9d1e3e3",
|
||||
"spider": "https://raw.kkgithub.com/lushunming/AndroidCatVodSpider/tyCookieJar/jar/custom_spider.jar;md5;1d71c8fceb2eb53953b31019774eeb86",
|
||||
"lives": [
|
||||
{
|
||||
"name": "电视直播",
|
||||
|
|
|
|||
Loading…
Reference in New Issue