123盘expire
This commit is contained in:
parent
35ab144e27
commit
586b4919c7
|
|
@ -9,6 +9,7 @@ import com.github.catvod.net.OkHttp
|
|||
import com.github.catvod.utils.Json
|
||||
import com.github.catvod.utils.ProxyServer.buildProxyUrl
|
||||
import com.github.catvod.utils.Util
|
||||
import com.google.gson.JsonObject
|
||||
import okhttp3.HttpUrl
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
|
@ -50,7 +51,7 @@ object Pan123Api {
|
|||
/**
|
||||
* 登录方法
|
||||
*/
|
||||
fun login(passport: String, password: String): String? {
|
||||
fun login(passport: String, password: String): JsonObject? {
|
||||
|
||||
val data = mapOf(
|
||||
"passport" to passport, "password" to password, "remember" to true
|
||||
|
|
@ -82,7 +83,8 @@ object Pan123Api {
|
|||
// setAuth(token)
|
||||
SpiderDebug.log("登录成功")
|
||||
|
||||
return token
|
||||
|
||||
return authData.get("data").asJsonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ object Pan123Handler {
|
|||
private var auth = ""
|
||||
private var userName = ""
|
||||
private var passwd = ""
|
||||
private var expire = 0L;
|
||||
|
||||
fun getCache(): File {
|
||||
return Path.tv("pan123")
|
||||
|
|
@ -47,12 +48,15 @@ object Pan123Handler {
|
|||
userName = cache!!.user.userName
|
||||
passwd = cache!!.user.password
|
||||
auth = cache!!.user.cookie
|
||||
if (StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(passwd)) {
|
||||
expire = cache!!.user.expire
|
||||
if (expire == 0L || System.currentTimeMillis() > expire) {
|
||||
SpiderDebug.log("token已过期")
|
||||
startFlow()
|
||||
} else if (StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(passwd)) {
|
||||
if (StringUtils.isBlank(auth)) {
|
||||
SpiderDebug.log("userName passwd 不为空,auth 为空")
|
||||
this.loginWithPassword(userName, passwd)
|
||||
}
|
||||
|
||||
} else {
|
||||
SpiderDebug.log("userName passwd 为空")
|
||||
startFlow()
|
||||
|
|
@ -67,13 +71,14 @@ object Pan123Handler {
|
|||
|
||||
try {
|
||||
//保存的账号密码
|
||||
val auth = login(uname!!, passwd!!)
|
||||
if (StringUtils.isNotBlank(auth)) {
|
||||
val json = login(uname!!, passwd!!)
|
||||
if (json != null) {
|
||||
val user = User()
|
||||
user.cookie = auth
|
||||
user.cookie = json.get("token").asString
|
||||
user.password = passwd
|
||||
user.userName = uname
|
||||
this.auth = auth ?: ""
|
||||
user.expire = json.get("refresh_token_expire_time").asLong * 1000
|
||||
this.auth = json.get("token").asString
|
||||
cache?.setUserInfo(user)
|
||||
Notify.show("123登录成功")
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import com.google.gson.annotations.SerializedName;
|
|||
|
||||
public class User {
|
||||
|
||||
|
||||
@SerializedName("expire")
|
||||
private long expire;
|
||||
@SerializedName("cookie")
|
||||
private String cookie;
|
||||
|
||||
|
|
@ -38,6 +39,14 @@ public class User {
|
|||
this.cookie = cookie;
|
||||
}
|
||||
|
||||
public long getExpire() {
|
||||
return expire;
|
||||
}
|
||||
|
||||
public void setExpire(long expire) {
|
||||
this.expire = expire;
|
||||
}
|
||||
|
||||
public static User objectFrom(String str) {
|
||||
User item = new Gson().fromJson(str, User.class);
|
||||
return item == null ? new User() : item;
|
||||
|
|
@ -48,6 +57,7 @@ public class User {
|
|||
this.cookie = "";
|
||||
this.userName = "";
|
||||
this.password = "";
|
||||
this.expire = 0L;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
f18a9014de20e672f634bb9120e333cb
|
||||
8d1566cb9f39f6dc19f1ae7754323b28
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://andoridspidermt.netlify.app/jar/custom_spider.jar;md5;f18a9014de20e672f634bb9120e333cb",
|
||||
"spider": "https://andoridspidermt.netlify.app/jar/custom_spider.jar;md5;8d1566cb9f39f6dc19f1ae7754323b28",
|
||||
"lives": [
|
||||
{
|
||||
"name": "电视直播",
|
||||
|
|
|
|||
Loading…
Reference in New Issue