Fix ali cache
This commit is contained in:
parent
4c48839c67
commit
aa126312e4
|
|
@ -68,7 +68,7 @@ public class API {
|
|||
}
|
||||
|
||||
public void setRefreshToken(String token) {
|
||||
auth.setRefreshToken(token);
|
||||
if (auth.getRefreshToken().isEmpty()) auth.setRefreshToken(token);
|
||||
}
|
||||
|
||||
public void setShareId(String shareId) {
|
||||
|
|
@ -148,10 +148,6 @@ public class API {
|
|||
if (auth.getAccessToken().isEmpty()) refreshAccessToken();
|
||||
}
|
||||
|
||||
public void checkAccessTokenOpen() {
|
||||
if (auth.getAccessTokenOpen().isEmpty()) refreshAccessTokenOpen();
|
||||
}
|
||||
|
||||
private void checkSignature() {
|
||||
if (auth.getSignature().isEmpty()) refreshSignature();
|
||||
}
|
||||
|
|
@ -256,7 +252,7 @@ public class API {
|
|||
public Vod getVod(String url, String fileId) throws Exception {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("share_id", shareId);
|
||||
String json = API.get().post("adrive/v3/share_link/get_share_by_anonymous", body);
|
||||
String json = post("adrive/v3/share_link/get_share_by_anonymous", body);
|
||||
JSONObject object = new JSONObject(json);
|
||||
List<Item> files = new ArrayList<>();
|
||||
LinkedHashMap<String, List<String>> subMap = new LinkedHashMap<>();
|
||||
|
|
@ -290,7 +286,7 @@ public class API {
|
|||
body.put("order_by", "name");
|
||||
body.put("order_direction", "ASC");
|
||||
if (marker.length() > 0) body.put("marker", marker);
|
||||
Item item = Item.objectFrom(API.get().auth("adrive/v3/file/list", body, true));
|
||||
Item item = Item.objectFrom(auth("adrive/v3/file/list", body, true));
|
||||
for (Item file : item.getItems()) {
|
||||
if (file.getType().equals("folder")) {
|
||||
folders.add(file);
|
||||
|
|
@ -354,16 +350,15 @@ public class API {
|
|||
|
||||
public String getDownloadUrl(String fileId) {
|
||||
try {
|
||||
checkAccessTokenOpen();
|
||||
return openFile(copy(fileId));
|
||||
fileId = copy(fileId);
|
||||
return TextUtils.isEmpty(fileId) ? "" : open(fileId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String openFile(String fileId) throws Exception {
|
||||
if (TextUtils.isEmpty(fileId)) return "";
|
||||
private String open(String fileId) throws Exception {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("file_id", fileId);
|
||||
body.put("drive_id", auth.getDriveId());
|
||||
|
|
@ -387,7 +382,7 @@ public class API {
|
|||
|
||||
public Object[] proxySub(Map<String, String> params) {
|
||||
String fileId = params.get("file_id");
|
||||
String text = OkHttp.string(getDownloadUrl(fileId), API.get().getHeaderAuth());
|
||||
String text = OkHttp.string(getDownloadUrl(fileId), getHeaderAuth());
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "application/octet-stream";
|
||||
|
|
@ -504,8 +499,8 @@ public class API {
|
|||
private void setToken(String value) {
|
||||
Init.show("請重新進入播放頁");
|
||||
auth.setRefreshToken(value);
|
||||
refreshAccessToken();
|
||||
stopService();
|
||||
auth.save();
|
||||
}
|
||||
|
||||
private void stopService() {
|
||||
|
|
|
|||
|
|
@ -4,21 +4,30 @@ import android.text.TextUtils;
|
|||
|
||||
import com.github.catvod.utils.Prefers;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Auth {
|
||||
|
||||
@SerializedName("refreshToken")
|
||||
private String refreshToken;
|
||||
@SerializedName("refreshTokenOpen")
|
||||
private String refreshTokenOpen;
|
||||
@SerializedName("accessToken")
|
||||
private String accessToken;
|
||||
@SerializedName("accessTokenOpen")
|
||||
private String accessTokenOpen;
|
||||
@SerializedName("signature")
|
||||
private String signature;
|
||||
@SerializedName("deviceId")
|
||||
private String deviceId;
|
||||
@SerializedName("userId")
|
||||
private String userId;
|
||||
@SerializedName("driveId")
|
||||
private String driveId;
|
||||
|
||||
public static Auth objectFrom(String str) {
|
||||
if (TextUtils.isEmpty(str)) return new Auth();
|
||||
return new Gson().fromJson(str, Auth.class);
|
||||
Auth item = new Gson().fromJson(str, Auth.class);
|
||||
return item == null ? new Auth() : item;
|
||||
}
|
||||
|
||||
public String getRefreshToken() {
|
||||
|
|
@ -94,6 +103,7 @@ public class Auth {
|
|||
setAccessTokenOpen("");
|
||||
setRefreshToken("");
|
||||
setAccessToken("");
|
||||
setSignature("");
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
8c2d8ce4096829e9fe00e9ac53f75dc9
|
||||
a25f65d9985736693258d27a77386ac5
|
||||
|
|
|
|||
Loading…
Reference in New Issue