diff --git a/json/config.json b/json/config.json index d80fa7f..892dba0 100644 --- a/json/config.json +++ b/json/config.json @@ -52,7 +52,8 @@ "changeable": 0, "ext": { } - }, { + }, + { "key": "ChangZhang", "name": "厂长影视", "type": 3, @@ -62,7 +63,8 @@ "changeable": 0, "ext": { } - }, { + }, + { "key": "Zxzj", "name": "在线之家", "type": 3, diff --git a/src/main/java/com/github/catvod/spider/BD.kt b/src/main/java/com/github/catvod/spider/BD.kt index a7ecba0..3e00590 100644 --- a/src/main/java/com/github/catvod/spider/BD.kt +++ b/src/main/java/com/github/catvod/spider/BD.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.loadImageBitmap import androidx.compose.ui.unit.dp import cn.hutool.core.codec.Base64 +import cn.hutool.core.exceptions.ExceptionUtil import cn.hutool.core.net.URLEncodeUtil import cn.hutool.crypto.Mode import cn.hutool.crypto.Padding @@ -300,7 +301,7 @@ class BD : Spider() { } private fun buildUrl(url: String, id: String, session: String, ref: String): String { - return "${Proxy.getProxyUrl()}?do=bd&url=${Utils.base64Encode(url)}&id=$id&session=${Utils.base64Encode(session)}&ref=${ + return "${Proxy.getProxyUrl()}?do=bd&url=${Utils.base64Encode(url)}&id=${Utils.base64Encode(id)}&session=${Utils.base64Encode(session)}&ref=${ Utils.base64Encode( ref ) @@ -319,18 +320,27 @@ class BD : Spider() { private var reference = host fun proxyLocal(params: MutableMap): Array { - var url = Utils.base64Decode(params["url"] ?: "") - val id = Utils.base64Decode(params["id"] ?: "") - val cookie = Utils.base64Decode(params["session"] ?: "") - val ref = Utils.base64Decode(params["ref"] ?: "") - if (url.contains("god")) { - val t = Date().time - val p = mutableMapOf("t" to t, "sg" to getSg(id, t.toString()), "verifyCode" to "888") - val body = OkHttp.post("${host}god", Json.toJson(p), Utils.webHeaders(host, cookie)).body - SpiderDebug.log("DB god req:$body") - url = Json.get().toJsonTree(body).asJsonObject.get("url").asString + try { + var url = Utils.base64Decode(params["url"] ?: "") + val id = if(StringUtils.isNotBlank(params["id"])){ + Utils.base64Decode(params["id"] ?: "") + }else "" + val cookie = if(StringUtils.isNotBlank(params["session"])){ + Utils.base64Decode(params["session"] ?: "") + }else "" +// val ref = Utils.base64Decode(params["ref"] ?: "") + if (url.contains("god")) { + val t = Date().time + val p = mutableMapOf("t" to t, "sg" to getSg(id, t.toString()), "verifyCode" to "888") + val body = OkHttp.post("${host}god", Json.toJson(p), Utils.webHeaders(host, cookie)).body + SpiderDebug.log("DB god req:$body") + url = Json.get().toJsonTree(body).asJsonObject.get("url").asString + } + return ProxyVideo.ProxyRespBuilder.redirect(url) + } catch (e: Exception) { + SpiderDebug.log("bd proxy error: " + ExceptionUtil.stacktraceToString(e)) } - return ProxyVideo.ProxyRespBuilder.redirect(url) + return arrayOf() } fun getSg(id: String, time: String): String { diff --git a/src/main/java/com/github/catvod/utils/Utils.java b/src/main/java/com/github/catvod/utils/Utils.java index 378cb32..1338450 100644 --- a/src/main/java/com/github/catvod/utils/Utils.java +++ b/src/main/java/com/github/catvod/utils/Utils.java @@ -6,6 +6,7 @@ import com.github.catvod.spider.Proxy; import io.ktor.http.ContentType; import okhttp3.Response; +import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpHeaders; import org.apache.http.client.utils.DateUtils; @@ -381,6 +382,7 @@ public static String base64Encode(String str) { } public static String base64Decode(String str) { + if(StringUtils.isBlank(str)) return ""; return new String(Base64.getDecoder().decode(str)); } }