parent
1c99b3ee76
commit
0b739766fa
@ -0,0 +1,60 @@ |
|||||||
|
/* |
||||||
|
* This file is part of FYReader. |
||||||
|
* FYReader is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* FYReader is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with FYReader. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
* |
||||||
|
* Copyright (C) 2020 - 2022 fengyuecanzhu |
||||||
|
*/ |
||||||
|
|
||||||
|
package xyz.fycz.dynamic.fix |
||||||
|
|
||||||
|
import me.fycz.maple.MapleBridge |
||||||
|
import me.fycz.maple.MapleUtils |
||||||
|
import me.fycz.maple.MethodReplacement |
||||||
|
import xyz.fycz.dynamic.utils.LanZouUtils |
||||||
|
import xyz.fycz.myreader.webapi.LanZouApi |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/6/30 20:40 |
||||||
|
*/ |
||||||
|
@AppFix([243, 244, 245, 246], ["修复书源订阅失败的问题"], "2022-06-30") |
||||||
|
class App246Fix4: AppFixHandle { |
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
val result = try { |
||||||
|
fxLanZouApi() |
||||||
|
true |
||||||
|
} catch (e: Exception) { |
||||||
|
MapleUtils.log(e) |
||||||
|
false |
||||||
|
} |
||||||
|
fixResult(key, "lanZouApi", result) |
||||||
|
return booleanArrayOf(result) |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxLanZouApi() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
LanZouApi::class.java, |
||||||
|
"getFileUrl", |
||||||
|
String::class.java, |
||||||
|
String::class.java, |
||||||
|
object : MethodReplacement(){ |
||||||
|
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam): Any { |
||||||
|
return LanZouUtils.getFileUrl(param.args[0] as String, param.args[1] as String) |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
/* |
||||||
|
* This file is part of FYReader. |
||||||
|
* FYReader is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* FYReader is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with FYReader. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
* |
||||||
|
* Copyright (C) 2020 - 2022 fengyuecanzhu |
||||||
|
*/ |
||||||
|
|
||||||
|
package xyz.fycz.dynamic.fix |
||||||
|
|
||||||
|
import me.fycz.maple.MapleBridge |
||||||
|
import me.fycz.maple.MapleUtils |
||||||
|
import me.fycz.maple.MethodHook |
||||||
|
import xyz.fycz.myreader.common.URLCONST |
||||||
|
import xyz.fycz.myreader.webapi.LanZouApi |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/6/21 18:30 |
||||||
|
*/ |
||||||
|
@AppFix([], ["更新订阅书源链接,仅支持v2.4.3版本及以上版本"], "2022-06-21") |
||||||
|
class AppSubSourceFix : AppFixHandle{ |
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
val result = try { |
||||||
|
fxSubSource() |
||||||
|
true |
||||||
|
} catch (e: Exception) { |
||||||
|
MapleUtils.log(e) |
||||||
|
false |
||||||
|
} |
||||||
|
fixResult(key, "subSource", result) |
||||||
|
return booleanArrayOf(result) |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxSubSource() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
LanZouApi::class.java, |
||||||
|
"getFoldFiles", |
||||||
|
String::class.java, |
||||||
|
Int::class.java, |
||||||
|
String::class.java, |
||||||
|
object : MethodHook(){ |
||||||
|
override fun beforeHookedMethod(param: MapleBridge.MethodHookParam) { |
||||||
|
if (param.args[0] == URLCONST.SUB_SOURCE_URL){ |
||||||
|
param.args[0] = "https://fycz.lanzoum.com/b00pucrch" |
||||||
|
param.args[2] = "b0ox" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,138 @@ |
|||||||
|
/* |
||||||
|
* This file is part of FYReader. |
||||||
|
* FYReader is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* FYReader is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with FYReader. If not, see <https://www.gnu.org/licenses/>. |
||||||
|
* |
||||||
|
* Copyright (C) 2020 - 2022 fengyuecanzhu |
||||||
|
*/ |
||||||
|
|
||||||
|
package xyz.fycz.dynamic.utils |
||||||
|
|
||||||
|
import io.reactivex.Observable |
||||||
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull |
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody |
||||||
|
import org.jsoup.Jsoup |
||||||
|
import xyz.fycz.myreader.common.URLCONST |
||||||
|
import xyz.fycz.myreader.entity.lanzou.LanZouParseBean |
||||||
|
import xyz.fycz.myreader.util.help.StringHelper |
||||||
|
import xyz.fycz.myreader.util.utils.GSON |
||||||
|
import xyz.fycz.myreader.util.utils.OkHttpUtils |
||||||
|
import xyz.fycz.myreader.util.utils.StringUtils |
||||||
|
import xyz.fycz.myreader.util.utils.fromJsonObject |
||||||
|
import java.net.HttpURLConnection |
||||||
|
import java.net.URL |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/1/22 18:50 |
||||||
|
*/ |
||||||
|
object LanZouUtils { |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过api获取蓝奏云可下载直链 |
||||||
|
* |
||||||
|
* @param url |
||||||
|
* @param password |
||||||
|
*/ |
||||||
|
fun getFileUrl(url: String, password: String = ""): Observable<String> { |
||||||
|
return Observable.create { |
||||||
|
val html = OkHttpUtils.getHtml(url) |
||||||
|
val url2 = if (password.isEmpty()) { |
||||||
|
val url1 = getUrl1(html) |
||||||
|
val data = StringUtils.getSubString(OkHttpUtils.getHtml(url1), "},", "},") |
||||||
|
val key = getKeyValueByKey(data, "sign") + "&" + getKeyValueByKey(data, "websignkey") |
||||||
|
getUrl2(key, url1) |
||||||
|
} else { |
||||||
|
getUrl2(StringHelper.getSubString(html, "sign=", "&"), url, password) |
||||||
|
} |
||||||
|
if (url2.contains("file")) { |
||||||
|
it.onNext(getRedirectUrl(url2)) |
||||||
|
} else { |
||||||
|
it.onError(Throwable(url2)) |
||||||
|
} |
||||||
|
it.onComplete() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun getUrl1(html: String): String { |
||||||
|
val doc = Jsoup.parse(html) |
||||||
|
return URLCONST.LAN_ZOU_URL + doc.getElementsByTag("iframe").attr("src") |
||||||
|
} |
||||||
|
|
||||||
|
fun getKeyValueByKey(html: String, key: String): String { |
||||||
|
val keyName = StringHelper.getSubString(html, "'$key':", ",") |
||||||
|
return if (keyName.endsWith("'")) { |
||||||
|
key + "=" + keyName.replace("'", "") |
||||||
|
} else { |
||||||
|
val lanzousKeyStart = "var $keyName = '" |
||||||
|
key + "=" + StringHelper.getSubString(html, lanzousKeyStart, "'") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun getUrl2(key: String, referer: String, password: String = ""): String { |
||||||
|
val mediaType = "application/x-www-form-urlencoded".toMediaTypeOrNull() |
||||||
|
val body = if (password.isEmpty()) { |
||||||
|
"action=downprocess&signs=?ctdf&websign=&ves=1&$key" |
||||||
|
} else { |
||||||
|
"action=downprocess&sign=$key&p=$password" |
||||||
|
} |
||||||
|
val requestBody = body.toRequestBody(mediaType) |
||||||
|
|
||||||
|
val headers = HashMap<String, String>() |
||||||
|
headers["Referer"] = referer |
||||||
|
|
||||||
|
val html = OkHttpUtils.getHtml( |
||||||
|
URLCONST.LAN_ZOU_URL + "/ajaxm.php", requestBody, |
||||||
|
"UTF-8", headers |
||||||
|
) |
||||||
|
return getUrl2(html) |
||||||
|
} |
||||||
|
|
||||||
|
private fun getUrl2(o: String): String { |
||||||
|
val lanZouBean = GSON.fromJsonObject<LanZouParseBean>(o) |
||||||
|
lanZouBean?.run { |
||||||
|
return if (zt == 1) { |
||||||
|
"$dom/file/$url" |
||||||
|
} else { |
||||||
|
"解析失败\n信息:$inf" |
||||||
|
} |
||||||
|
} |
||||||
|
return "" |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取重定向地址 |
||||||
|
* |
||||||
|
* @param path |
||||||
|
*/ |
||||||
|
fun getRedirectUrl(path: String): String { |
||||||
|
val conn = URL(path) |
||||||
|
.openConnection() as HttpURLConnection |
||||||
|
conn.instanceFollowRedirects = false |
||||||
|
conn.connectTimeout = 5000 |
||||||
|
conn.setRequestProperty( |
||||||
|
"User-Agent", |
||||||
|
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" |
||||||
|
) |
||||||
|
conn.setRequestProperty("Accept-Language", "zh-cn") |
||||||
|
conn.setRequestProperty("Connection", "Keep-Alive") |
||||||
|
conn.setRequestProperty( |
||||||
|
"Accept", |
||||||
|
"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, */*" |
||||||
|
) |
||||||
|
conn.connect() |
||||||
|
val redirectUrl = conn.getHeaderField("Location") |
||||||
|
conn.disconnect() |
||||||
|
return redirectUrl |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue