Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
99b2dbb073
|
|
@ -145,6 +145,12 @@ public class API {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean checkManyRequest(String result) {
|
||||
if (!result.contains("Too Many Requests")) return false;
|
||||
Init.show("洗洗睡吧,Too Many Requests。");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkAccessToken() {
|
||||
if (auth.getAccessToken().isEmpty()) refreshAccessToken();
|
||||
}
|
||||
|
|
@ -154,7 +160,7 @@ public class API {
|
|||
SpiderDebug.log("refreshAccessToken...");
|
||||
JSONObject body = new JSONObject();
|
||||
String token = auth.getRefreshToken();
|
||||
if (token.startsWith("http")) token = OkHttp.string(token).replaceAll("[^A-Za-z0-9]", "");
|
||||
if (token.startsWith("http")) token = OkHttp.string(token);
|
||||
body.put("refresh_token", token);
|
||||
body.put("grant_type", "refresh_token");
|
||||
JSONObject object = new JSONObject(post("https://auth.aliyundrive.com/v2/account/token", body));
|
||||
|
|
@ -186,14 +192,22 @@ public class API {
|
|||
oauthRedirect(object.getString("redirectUri").split("code=")[1]);
|
||||
}
|
||||
|
||||
private void oauthRedirect(String code) throws Exception {
|
||||
SpiderDebug.log("OAuth Redirect...");
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("code", code);
|
||||
body.put("grant_type", "authorization_code");
|
||||
JSONObject object = new JSONObject(post("https://api.nn.ci/alist/ali_open/code", body));
|
||||
Log.e("DDD", object.toString());
|
||||
auth.setRefreshTokenOpen(object.getString("refresh_token"));
|
||||
private void oauthRedirect(String code) {
|
||||
try {
|
||||
SpiderDebug.log("OAuth Redirect...");
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("code", code);
|
||||
body.put("grant_type", "authorization_code");
|
||||
String result = post("https://api.nn.ci/alist/ali_open/code", body);
|
||||
Log.e("DDD", result);
|
||||
if (checkManyRequest(result)) return;
|
||||
JSONObject object = new JSONObject(result);
|
||||
auth.setRefreshTokenOpen(object.getString("refresh_token"));
|
||||
auth.setAccessTokenOpen(object.optString("token_type") + " " + object.optString("access_token"));
|
||||
auth.save();
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean refreshOpenToken() {
|
||||
|
|
@ -202,8 +216,10 @@ public class API {
|
|||
JSONObject body = new JSONObject();
|
||||
body.put("grant_type", "refresh_token");
|
||||
body.put("refresh_token", auth.getRefreshTokenOpen());
|
||||
JSONObject object = new JSONObject(post("https://api.nn.ci/alist/ali_open/token", body));
|
||||
Log.e("DDD", object.toString());
|
||||
String result = post("https://api.nn.ci/alist/ali_open/token", body);
|
||||
Log.e("DDD", result);
|
||||
if (checkManyRequest(result)) return false;
|
||||
JSONObject object = new JSONObject(result);
|
||||
auth.setRefreshTokenOpen(object.optString("refresh_token"));
|
||||
auth.setAccessTokenOpen(object.optString("token_type") + " " + object.optString("access_token"));
|
||||
auth.save();
|
||||
|
|
|
|||
|
|
@ -85,9 +85,6 @@ public class Auth {
|
|||
}
|
||||
|
||||
public void clean() {
|
||||
setRefreshTokenOpen("");
|
||||
setAccessTokenOpen("");
|
||||
setRefreshToken("");
|
||||
setAccessToken("");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.catvod.bean.alist;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.bean.Class;
|
||||
|
|
@ -24,6 +25,8 @@ public class Drive {
|
|||
private String password;
|
||||
@SerializedName("version")
|
||||
private int version;
|
||||
@SerializedName("path")
|
||||
private String path;
|
||||
|
||||
public static Drive objectFrom(String str) {
|
||||
return new Gson().fromJson(str, Drive.class);
|
||||
|
|
@ -57,6 +60,14 @@ public class Drive {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return TextUtils.isEmpty(path) ? "" : path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = TextUtils.isEmpty(path) ? "" : path;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return getVersion() == 3;
|
||||
}
|
||||
|
|
@ -65,24 +76,29 @@ public class Drive {
|
|||
return new Class(getName(), getName(), "1");
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return getServer().replace(getPath(), "");
|
||||
}
|
||||
|
||||
public String settingsApi() {
|
||||
return getServer() + "/api/public/settings";
|
||||
return getHost() + "/api/public/settings";
|
||||
}
|
||||
|
||||
public String listApi() {
|
||||
return getServer() + (isNew() ? "/api/fs/list" : "/api/public/path");
|
||||
return getHost() + (isNew() ? "/api/fs/list" : "/api/public/path");
|
||||
}
|
||||
|
||||
public String getApi() {
|
||||
return getServer() + (isNew() ? "/api/fs/get" : "/api/public/path");
|
||||
return getHost() + (isNew() ? "/api/fs/get" : "/api/public/path");
|
||||
}
|
||||
|
||||
public String searchApi() {
|
||||
return getServer() + (isNew() ? "/api/fs/search" : "/api/public/search");
|
||||
return getHost() + (isNew() ? "/api/fs/search" : "/api/public/search");
|
||||
}
|
||||
|
||||
public Drive check() {
|
||||
if (getVersion() == 0) setVersion(OkHttp.string(settingsApi()).contains("v2.") ? 2 : 3);
|
||||
if (path == null) setPath(Uri.parse(getServer()).getPath());
|
||||
if (version == 0) setVersion(OkHttp.string(settingsApi()).contains("v2.") ? 2 : 3);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import com.github.catvod.bean.alist.Item;
|
|||
import com.github.catvod.bean.alist.Sorter;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Trans;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ public class AList extends Spider {
|
|||
String path = id.contains("/") ? id.substring(id.indexOf("/")) : "";
|
||||
Drive drive = getDrive(key);
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("path", path);
|
||||
params.put("path", drive.getPath() + path);
|
||||
params.put("password", drive.getPassword());
|
||||
String response = OkHttp.postJson(drive.getApi(), params.toString());
|
||||
return Item.objectFrom(getDetailJson(drive.isNew(), response));
|
||||
|
|
@ -151,7 +151,7 @@ public class AList extends Spider {
|
|||
String path = id.contains("/") ? id.substring(id.indexOf("/")) : "";
|
||||
Drive drive = getDrive(key);
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("path", path);
|
||||
params.put("path", drive.getPath() + path);
|
||||
params.put("password", drive.getPassword());
|
||||
String response = OkHttp.postJson(drive.listApi(), params.toString());
|
||||
List<Item> items = Item.arrayFrom(getListJson(drive.isNew(), response));
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
255c5dca97c64efb39b5fbe7d748cc0b
|
||||
3473c6feb44308efdb18ef8ea90ed6eb
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;255c5dca97c64efb39b5fbe7d748cc0b",
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;3473c6feb44308efdb18ef8ea90ed6eb",
|
||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;255c5dca97c64efb39b5fbe7d748cc0b",
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;3473c6feb44308efdb18ef8ea90ed6eb",
|
||||
"wallpaper": "http://饭太硬.ga/深色壁纸/api.php",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue