天翼扫码bug
This commit is contained in:
parent
792feb5acd
commit
3809a09f44
|
|
@ -8,7 +8,7 @@ import com.github.catvod.utils.Json;
|
|||
import com.github.catvod.utils.Path;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -17,6 +17,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class SimpleCookieJar {
|
||||
private Map<String, Map<String, String>> cookieStore = new HashMap<>();
|
||||
private final Cache cache;
|
||||
|
|
@ -46,7 +48,8 @@ public class SimpleCookieJar {
|
|||
|
||||
public void saveFromResponse(String url, List<String> cookies) {
|
||||
HttpUrl httpUrl = HttpUrl.parse(url);
|
||||
SpiderDebug.log("SimpleCookieJar saveFromResponse: " + httpUrl.host() + ": " + Json.toJson(cookies));
|
||||
SpiderDebug.log(" saveFromResponse url: " + url);
|
||||
SpiderDebug.log(" saveFromResponse cookie : " + Json.toJson(cookies));
|
||||
// 创建可修改的 Cookie 列表副本
|
||||
Map<String, String> oldCookies = cookieStore.get(httpUrl.host()) != null ? cookieStore.get(httpUrl.host()) : new HashMap<>();
|
||||
|
||||
|
|
@ -65,7 +68,7 @@ public class SimpleCookieJar {
|
|||
|
||||
cookieStore.put(httpUrl.host(), oldCookies);
|
||||
cache.setTianyiUser(User.objectFrom(Json.toJson(cookieStore)));
|
||||
SpiderDebug.log("SimpleCookieJar cookieStore: " + Json.toJson(cookieStore));
|
||||
SpiderDebug.log(" cookieStore now: " + Json.toJson(cookieStore));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +105,8 @@ public class SimpleCookieJar {
|
|||
}
|
||||
}
|
||||
String cookie = StringUtils.join(cookieList, ";");
|
||||
SpiderDebug.log("SimpleCookieJar getCookie: url:" + httpUrl.host() + "cookie:" + cookie);
|
||||
SpiderDebug.log(" loadForRequest url:" + url);
|
||||
SpiderDebug.log(" loadForRequest cookie:" + cookie);
|
||||
return cookie;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,29 +7,41 @@ import android.graphics.drawable.ColorDrawable;
|
|||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.github.catvod.bean.tianyi.Cache;
|
||||
import com.github.catvod.bean.tianyi.User;
|
||||
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.utils.*;
|
||||
import com.github.catvod.utils.Json;
|
||||
import com.github.catvod.utils.Notify;
|
||||
import com.github.catvod.utils.Path;
|
||||
import com.github.catvod.utils.QRCode;
|
||||
import com.github.catvod.utils.ResUtil;
|
||||
import com.google.gson.JsonObject;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class TianYiHandler {
|
||||
|
||||
public static final String API_URL = "https://open.e.189.cn";
|
||||
|
|
@ -77,18 +89,18 @@ public class TianYiHandler {
|
|||
|
||||
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&defaultSaveName=3&defaultSaveNameCheck=uncheck&browserId=16322f24d9405fb83331c3f6ce971b53";
|
||||
String index = OkHttp.getLocation(url, getHeader(url));
|
||||
SpiderDebug.log("index:" + index);
|
||||
SpiderDebug.log("index red: " + index);
|
||||
SpiderDebug.log("unifyAccountLogin:" + index);
|
||||
|
||||
Map<String, List<String>> resHeaderMap = OkHttp.getLocationHeader(index, getHeader(index));
|
||||
saveCookie(resHeaderMap.get("Set-Cookie"), index);
|
||||
indexUrl = resHeaderMap.get("Location").get(0);
|
||||
SpiderDebug.log("indexUrl red: " + indexUrl);
|
||||
OkResult okResult = OkHttp.get(indexUrl, new HashMap<>(), getHeader(indexUrl));
|
||||
saveCookie(okResult.getResp().get("Set-Cookie"), indexUrl);
|
||||
SpiderDebug.log("refreshCookie header:" + Json.toJson(okResult.getResp()));
|
||||
SpiderDebug.log("callbackUnify: " + indexUrl);
|
||||
|
||||
Map<String, List<String>> callbackUnify = OkHttp.getLocationHeader(indexUrl, getHeader(indexUrl));
|
||||
saveCookie(callbackUnify.get("Set-Cookie"), indexUrl);
|
||||
SpiderDebug.log("refreshCookie header:" + Json.toJson(callbackUnify));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ public class TianyiApi {
|
|||
}
|
||||
} else if (res.get("errorCode") != null && res.get("errorCode").getAsString().equals("InvalidSessionKey")) {
|
||||
//刷新cookie
|
||||
SpiderDebug.log("cookie 过期,刷新cookie。。。。");
|
||||
SpiderDebug.log("天意cookie 过期,刷新cookie。。。。");
|
||||
tianYiHandler.refreshCookie();
|
||||
//重试下载
|
||||
SpiderDebug.log("重试下载。。。。");
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class TianYiHandlerTest {
|
|||
@Test
|
||||
public void refreshCookie() throws Exception {
|
||||
|
||||
JsonObject obj = Json.safeObject("{\"open.e.189.cn\":{\"OPENINFO\":\"33c28688ef52ce9e3a9ef87388047efbde5e3e2e4c7ef6ef267632468c7dfaf294ff59fa59d34801\",\"pageOp\":\"f69c75fdedccb502a36c77a24e680020\",\"LT\":\"855366f756091e07\",\"GUID\":\"3956b8eff8b746ecb6529247e942ede9\",\"SSON\":\"dc466c8192e3109eaea837c1d136c1fd065253ce1c7d3a66ca1520d7d6d6307b10a1fe65c7becac73b95f24a6e681e654ec4f47c39533ebcc48bb78d6d6e63d1bbf3334e6e97eaa7092d34f87bf1209ebf5e9fb0cc4acaa19d9244741def867ce3c66f9d8bebba20bbd3850b11abcbf331d1f434623686850171e7f6e60c3af4726febb62ca26b017bf79babc487db070293d8276d861fcaadc58148255113ad473bd52c732bb1c22a095f1a6e76c6ec643eb5cc5fde4629f50d5cd9fd69397c3548cfd8377e57b4793588d4b4707cd037d43c42927c74878296e13016a6974dba12aee0c9d53fa7\"},\"cloud.189.cn\":{\"JSESSIONID\":\"2378013FE97769100CA550798FE9C7A0\",\"COOKIE_LOGIN_USER\":\"CEFA57A70B075914732B7BAB853E481AFC04F65870A4D9D68AD677D97C78BE91C0613178466B68B1E91E2DC5DAF6FAED798CCA1676AAF3D1\"}}");
|
||||
JsonObject obj = Json.safeObject("{\"open.e.189.cn\":{\"OPENINFO\":\"33c28688ef52ce9e3a9ef87388047efbde5e3e2e4c7ef6ef267632468c7dfaf294ff59fa59d34801\",\"pageOp\":\"f73420158c5c010491f1faa4fc91870e\",\"LT\":\"a8900fc0ecae0c59\",\"GUID\":\"b959026ffdf84080ae8567afd9ea4c32\",\"SSON\":\"dc466c8192e3109eaea837c1d136c1fd065253ce1c7d3a66ca1520d7d6d6307b10a1fe65c7becac73b95f24a6e681e654ec4f47c39533ebcc48bb78d6d6e63d1bbf3334e6e97eaa7092d34f87bf1209e256cd4822db68da051a0aeb532d94408c8e50486347fc713813dafc5776a7cfa665ddf96837151232745aa2957fb441d8a79ca7d86f46452060794e6f4b5873ab99ed476629aed2c7b36a44613c92f925dcfd221fce142cd1ecaab667236df697ece293e3ca24030918e5b357bc193118772278748606ade7262bf25ae7527d3c8a059bd48fc08b53b182e61e543a7e9bd1562b50bf80438\"},\"cloud.189.cn\":{\"JSESSIONID\":\"12088774C4B78E632EB944ECA2E6705F\",\"COOKIE_LOGIN_USER\":\"24DA4CBA27A8388982710C2F3D55EFAA84AEE67E9B3EF1B7AC1C565BEEF24C562052CB9B5EAC85E733C10C2704225133CD625407C352ED5D\"}}");
|
||||
tianYiHandler.setCookie(obj);
|
||||
tianYiHandler.refreshCookie();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue