Clean code
This commit is contained in:
parent
22ca7a8a63
commit
2673b087d3
|
|
@ -1,4 +1,4 @@
|
|||
package com.github.catvod.ali;
|
||||
package com.github.catvod.api;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -50,7 +50,7 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
import okhttp3.Response;
|
||||
|
||||
public class API {
|
||||
public class AliYun {
|
||||
|
||||
private ScheduledExecutorService service;
|
||||
private final List<String> tempIds;
|
||||
|
|
@ -64,10 +64,10 @@ public class API {
|
|||
private Drive drive;
|
||||
|
||||
private static class Loader {
|
||||
static volatile API INSTANCE = new API();
|
||||
static volatile AliYun INSTANCE = new AliYun();
|
||||
}
|
||||
|
||||
public static API get() {
|
||||
public static AliYun get() {
|
||||
return Loader.INSTANCE;
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ public class API {
|
|||
return FileUtil.getCacheFile("aliyundrive_drive");
|
||||
}
|
||||
|
||||
private API() {
|
||||
private AliYun() {
|
||||
tempIds = new ArrayList<>();
|
||||
oauth = OAuth.objectFrom(FileUtil.read(getOAuthCache()));
|
||||
user = User.objectFrom(FileUtil.read(getUserCache()));
|
||||
|
|
@ -2,7 +2,7 @@ package com.github.catvod.bean.ali;
|
|||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.ali.API;
|
||||
import com.github.catvod.api.AliYun;
|
||||
import com.github.catvod.utils.FileUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -52,7 +52,7 @@ public class Drive {
|
|||
}
|
||||
|
||||
public Drive save() {
|
||||
FileUtil.write(API.get().getDriveCache(), toString());
|
||||
FileUtil.write(AliYun.get().getDriveCache(), toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.github.catvod.bean.ali;
|
|||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.ali.API;
|
||||
import com.github.catvod.api.AliYun;
|
||||
import com.github.catvod.utils.FileUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -44,7 +44,7 @@ public class OAuth {
|
|||
}
|
||||
|
||||
public OAuth save() {
|
||||
FileUtil.write(API.get().getOAuthCache(), toString());
|
||||
FileUtil.write(AliYun.get().getOAuthCache(), toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.github.catvod.bean.ali;
|
|||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.ali.API;
|
||||
import com.github.catvod.api.AliYun;
|
||||
import com.github.catvod.utils.FileUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -64,7 +64,7 @@ public class User {
|
|||
}
|
||||
|
||||
public User save() {
|
||||
FileUtil.write(API.get().getUserCache(), toString());
|
||||
FileUtil.write(AliYun.get().getUserCache(), toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.github.catvod.spider;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import com.github.catvod.ali.API;
|
||||
import com.github.catvod.api.AliYun;
|
||||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ public class Ali extends Spider {
|
|||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
API.get().setRefreshToken(extend);
|
||||
AliYun.get().setRefreshToken(extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -30,19 +30,19 @@ public class Ali extends Spider {
|
|||
if (!matcher.find()) return "";
|
||||
String shareId = matcher.group(1);
|
||||
String fileId = matcher.groupCount() == 3 ? matcher.group(3) : "";
|
||||
API.get().setShareId(shareId);
|
||||
return Result.string(API.get().getVod(url, fileId));
|
||||
AliYun.get().setShareId(shareId);
|
||||
return Result.string(AliYun.get().getVod(url, fileId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||
return API.get().playerContent(id.split("\\+"), flag.equals("原畫"));
|
||||
return AliYun.get().playerContent(id.split("\\+"), flag.equals("原畫"));
|
||||
}
|
||||
|
||||
public static Object[] proxy(Map<String, String> params) throws Exception {
|
||||
String type = params.get("type");
|
||||
if (type.equals("sub")) return API.get().proxySub(params);
|
||||
if (type.equals("token")) return API.get().getToken();
|
||||
if (type.equals("sub")) return AliYun.get().proxySub(params);
|
||||
if (type.equals("token")) return AliYun.get().getToken();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import android.text.TextUtils;
|
|||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Sub;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
|
|
@ -15,16 +16,22 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Push extends Ali {
|
||||
public class Push extends Spider {
|
||||
|
||||
private final Ali ali;
|
||||
|
||||
public Push() {
|
||||
ali = new Ali();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
super.init(context, extend);
|
||||
ali.init(context, extend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
if (pattern.matcher(ids.get(0)).find()) return super.detailContent(ids);
|
||||
if (Ali.pattern.matcher(ids.get(0)).find()) return ali.detailContent(ids);
|
||||
return Result.string(vod(ids.get(0)));
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +40,7 @@ public class Push extends Ali {
|
|||
if (flag.equals("直連")) return Result.get().url(id).subs(getSubs(id)).string();
|
||||
if (flag.equals("嗅探")) return Result.get().parse().url(id).string();
|
||||
if (flag.equals("解析")) return Result.get().parse().jx().url(id).string();
|
||||
return super.playerContent(flag, id, vipFlags);
|
||||
return ali.playerContent(flag, id, vipFlags);
|
||||
}
|
||||
|
||||
private Vod vod(String url) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue