夸克盘扫码

This commit is contained in:
lushunming 2024-08-31 10:50:30 +08:00
parent f381ead422
commit ad3c25f254
1 changed files with 9 additions and 8 deletions

View File

@ -154,18 +154,19 @@ public class QuarkApi {
int leftRetry = retry != null ? retry : 3; int leftRetry = retry != null ? retry : 3;
if (StringUtils.isAllBlank(cookie)) {
this.refreshAccessToken();
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 = OkHttp.get(this.apiUrl + url, params, getHeaders());
} else { } else {
okResult = OkHttp.post(this.apiUrl + url, Json.toJson(data), getHeaders()); okResult = OkHttp.post(this.apiUrl + url, Json.toJson(data), getHeaders());
} }
if (leftRetry > 0 && okResult.getCode() == 401 && refreshAccessToken())
return api(url, params, data, leftRetry - 1, method);
if (leftRetry > 0 && okResult.getCode() == 429) return api(url, params, data, leftRetry - 1, method);
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"), ";;;"));
if (matcher.find()) { if (matcher.find()) {
Matcher cookieMatcher = Pattern.compile("__puus=([^;]+)").matcher(this.cookie); Matcher cookieMatcher = Pattern.compile("__puus=([^;]+)").matcher(this.cookie);
@ -173,7 +174,7 @@ public class QuarkApi {
this.cookie = this.cookie.replaceAll("__puus=[^;]+", "__puus=" + matcher.group(1)); this.cookie = this.cookie.replaceAll("__puus=[^;]+", "__puus=" + matcher.group(1));
} }
} }
} }*/
if (okResult.getCode() != 200 && leftRetry > 0) { if (okResult.getCode() != 200 && leftRetry > 0) {
Thread.sleep(1000); Thread.sleep(1000);
@ -191,9 +192,9 @@ public class QuarkApi {
OkResult result = OkHttp.get("https://pan.quark.cn/account/info?st=" + token, new HashMap<>(), Map.of("set-cookie", "my-set-cookie")); OkResult result = OkHttp.get("https://pan.quark.cn/account/info?st=" + token, new HashMap<>(), Map.of("set-cookie", "my-set-cookie"));
Map<String, Map<String, Map<String, String>>> json = new HashMap<>();
json = Json.parseSafe(result.getBody(), json.getClass()); Map<String, Object> json = Json.parseSafe(result.getBody(), Map.class);
if (json.get("message").equals("ok")) { if (json.get("code").equals("ok")) {
String cook = result.getResp().get("my-set-cookie").get(0); String cook = result.getResp().get("my-set-cookie").get(0);
cache.setUser(User.objectFrom(cook)); cache.setUser(User.objectFrom(cook));
if (cache.getUser().getCookie().isEmpty()) throw new Exception(cook); if (cache.getUser().getCookie().isEmpty()) throw new Exception(cook);