Update API.java

This commit is contained in:
FongMi 2023-03-10 14:35:49 +08:00
parent 63acd722fe
commit 6ea0e91308
1 changed files with 4 additions and 15 deletions

View File

@ -170,8 +170,9 @@ public class API {
body.put("code", code); body.put("code", code);
body.put("grant_type", "authorization_code"); body.put("grant_type", "authorization_code");
object = new JSONObject(post("https://api.nn.ci/alist/ali_open/code", body)); object = new JSONObject(post("https://api.nn.ci/alist/ali_open/code", body));
auth.setAccessTokenOpen(object.optString("token_type") + " " + object.optString("access_token"));
auth.setRefreshTokenOpen(object.getString("refresh_token")); auth.setRefreshTokenOpen(object.getString("refresh_token"));
refreshOpenToken(); auth.save();
return true; return true;
} catch (Exception e) { } catch (Exception e) {
SpiderDebug.log(e); SpiderDebug.log(e);
@ -184,18 +185,6 @@ public class API {
} }
} }
private void refreshOpenToken() throws Exception {
SpiderDebug.log("refreshAccessTokenOpen...");
JSONObject body = new JSONObject();
String token = auth.getRefreshTokenOpen();
body.put("refresh_token", token);
body.put("grant_type", "refresh_token");
JSONObject object = new JSONObject(OkHttp.postJson("https://api.nn.ci/alist/ali_open/token", body.toString(), getHeader()));
auth.setAccessTokenOpen(object.optString("token_type") + " " + object.optString("access_token"));
auth.setRefreshTokenOpen(object.optString("refresh_token"));
auth.save();
}
public boolean refreshShareToken() { public boolean refreshShareToken() {
try { try {
SpiderDebug.log("refreshShareToken..."); SpiderDebug.log("refreshShareToken...");
@ -246,7 +235,7 @@ public class API {
List<Item> files = new ArrayList<>(); List<Item> files = new ArrayList<>();
LinkedHashMap<String, List<String>> subMap = new LinkedHashMap<>(); LinkedHashMap<String, List<String>> subMap = new LinkedHashMap<>();
listFiles(new Item(getParentFileId(fileId, object)), files, subMap); listFiles(new Item(getParentFileId(fileId, object)), files, subMap);
List<String> playFrom = Arrays.asList("原畫", "FHD", "HD", "SD", "LD"); List<String> playFrom = Arrays.asList("原畫", "高清", "標清");
List<String> episode = new ArrayList<>(); List<String> episode = new ArrayList<>();
List<String> playUrl = new ArrayList<>(); List<String> playUrl = new ArrayList<>();
for (Item file : files) episode.add(Trans.get(file.getDisplayName()) + "$" + file.getFileId() + findSubs(file.getName(), subMap)); for (Item file : files) episode.add(Trans.get(file.getDisplayName()) + "$" + file.getFileId() + findSubs(file.getName(), subMap));
@ -334,7 +323,7 @@ public class API {
} }
public String getPreviewUrl(String fileId, String flag) { public String getPreviewUrl(String fileId, String flag) {
return Proxy.getUrl() + "?do=ali&type=m3u8&file_id=" + fileId + "&flag=" + flag; return Proxy.getUrl() + "?do=ali&type=m3u8&file_id=" + fileId + "&flag=" + (flag.equals("高清") ? "FHD" : "HD");
} }
public String getDownloadUrl(String fileId) { public String getDownloadUrl(String fileId) {