pull/28/head
fengyuecanzhu 2 years ago
parent bee5bb5ff0
commit aeacb04f7c
No known key found for this signature in database
GPG Key ID: 04B78AD06A9D6E6C
  1. 31
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix4.kt
  2. 21
      dynamic/src/main/java/xyz/fycz/dynamic/utils/LanZouUtils.kt

@ -22,18 +22,24 @@ import me.fycz.maple.MapleBridge
import me.fycz.maple.MapleUtils import me.fycz.maple.MapleUtils
import me.fycz.maple.MethodReplacement import me.fycz.maple.MethodReplacement
import xyz.fycz.dynamic.utils.LanZouUtils import xyz.fycz.dynamic.utils.LanZouUtils
import xyz.fycz.myreader.base.observer.MyObserver
import xyz.fycz.myreader.util.utils.RxUtils
import xyz.fycz.myreader.webapi.LanZouApi import xyz.fycz.myreader.webapi.LanZouApi
import xyz.fycz.myreader.webapi.LanZousApi
import xyz.fycz.myreader.webapi.ResultCallback
import java.lang.Exception
/** /**
* @author fengyue * @author fengyue
* @date 2022/6/30 20:40 * @date 2022/6/30 20:40
*/ */
@AppFix([243, 244, 245, 246], ["修复书源订阅失败的问题"], "2022-06-30") @AppFix([243, 244, 245, 246], ["修复书源订阅失败的问题", "修复字体下载失败的问题"], "2022-06-30")
class App246Fix4: AppFixHandle { class App246Fix4: AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
return handleFix( return handleFix(
key, key,
"lanZouApi" to { fxLanZouApi() }, "lanZouApi" to { fxLanZouApi() },
"fontLanZouApi" to { fxFontLanZouApi() },
) )
} }
@ -51,5 +57,28 @@ class App246Fix4: AppFixHandle {
) )
} }
private fun fxFontLanZouApi(){
MapleUtils.findAndHookMethod(
LanZousApi::class.java,
"getUrl",
String::class.java,
ResultCallback::class.java,
object : MethodReplacement(){
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam) {
val callback = param.args[1] as ResultCallback
LanZouUtils.getFileUrl(param.args[0] as String)
.compose { RxUtils.toSimpleSingle(it) }
.subscribe(object : MyObserver<String>(){
override fun onNext(t: String) {
callback.onFinish(t, 1)
}
override fun onError(e: Throwable) {
callback.onError(e as Exception)
}
})
}
}
)
}
} }

@ -18,6 +18,7 @@
package xyz.fycz.dynamic.utils package xyz.fycz.dynamic.utils
import android.util.Log
import io.reactivex.Observable import io.reactivex.Observable
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.RequestBody.Companion.toRequestBody
@ -46,11 +47,15 @@ object LanZouUtils {
*/ */
fun getFileUrl(url: String, password: String = ""): Observable<String> { fun getFileUrl(url: String, password: String = ""): Observable<String> {
return Observable.create { return Observable.create {
val html = OkHttpUtils.getHtml(url) var html = OkHttpUtils.getHtml(url)
val url2 = if (password.isEmpty()) { val url2 = if (password.isEmpty()) {
val url1 = getUrl1(html) val url1 = getUrl1(html)
val data = StringUtils.getSubString(OkHttpUtils.getHtml(url1), "},", "},") html = OkHttpUtils.getHtml(url1)
val key = getKeyValueByKey(data, "sign") + "&" + getKeyValueByKey(data, "websignkey") val data = getDataString(html)
Log.d("LanZouUtils", "data:$data")
val key = getKeyValueByKey(html, data, "sign") +
"&" + getKeyValueByKey(html, data, "websignkey")
Log.d("LanZouUtils", "key:$key")
getUrl2(key, url1) getUrl2(key, url1)
} else { } else {
getUrl2(StringHelper.getSubString(html, "sign=", "&"), url, password) getUrl2(StringHelper.getSubString(html, "sign=", "&"), url, password)
@ -69,8 +74,8 @@ object LanZouUtils {
return URLCONST.LAN_ZOU_URL + doc.getElementsByTag("iframe").attr("src") return URLCONST.LAN_ZOU_URL + doc.getElementsByTag("iframe").attr("src")
} }
fun getKeyValueByKey(html: String, key: String): String { fun getKeyValueByKey(html: String, data: String, key: String): String {
val keyName = StringHelper.getSubString(html, "'$key':", ",") val keyName = StringHelper.getSubString(data, "'$key':", ",")
return if (keyName.endsWith("'")) { return if (keyName.endsWith("'")) {
key + "=" + keyName.replace("'", "") key + "=" + keyName.replace("'", "")
} else { } else {
@ -135,4 +140,10 @@ object LanZouUtils {
conn.disconnect() conn.disconnect()
return redirectUrl return redirectUrl
} }
fun getDataString(html: String): String {
val start = html.lastIndexOf("data :") + "data :".length
val end = html.indexOf("},", start) + 1
return html.substring(start, end)
}
} }
Loading…
Cancel
Save