diff --git a/app/src/main/java/xyz/fycz/myreader/entity/LanZouBean.kt b/app/src/main/java/xyz/fycz/myreader/entity/LanZouBean.kt new file mode 100644 index 0000000..fce8743 --- /dev/null +++ b/app/src/main/java/xyz/fycz/myreader/entity/LanZouBean.kt @@ -0,0 +1,12 @@ +package xyz.fycz.myreader.entity + +/** + * @author fengyue + * @date 2022/1/22 20:15 + */ +data class LanZouBean( + var zt: Int, + var dom: String, + var url: String, + var inf: String +) diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java index 96fb8b5..7377d84 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java @@ -119,10 +119,10 @@ public class AboutActivity extends BaseActivity { String[] str = new String[1]; MyAlertDialog.createInputDia(this, getString(R.string.lan_zou_parse), "格式:链接+逗号+密码(没有密码就不用填)", "", true, - 100, text -> str[0] = text, (dialog, which) -> { + 100, text -> str[0] = text.replaceAll("\\s", ""), (dialog, which) -> { String url, pwd = ""; - if (str[0].contains(",") || str[0].contains(",")) { - String[] strs = str[0].split("[,,]"); + if (str[0].contains(",") || str[0].contains(",") || str[0].contains("密码:")) { + String[] strs = str[0].split(",|,|密码:"); url = strs[0]; pwd = strs[1]; } else { diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt b/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt index 6cf823e..264405d 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt +++ b/app/src/main/java/xyz/fycz/myreader/webapi/LanZouApi.kt @@ -5,8 +5,11 @@ 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.LanZouBean 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.fromJsonObject import java.net.HttpURLConnection import java.net.URL import java.util.* @@ -32,7 +35,11 @@ object LanZouApi { } else { getUrl2(StringHelper.getSubString(html, "sign=", "&"), url, password) } - it.onNext(getRedirectUrl(url2)) + if (url2.contains("file")) { + it.onNext(getRedirectUrl(url2)) + } else { + it.onError(Throwable(url2)) + } it.onComplete() } } @@ -74,7 +81,7 @@ object LanZouApi { } private fun getUrl2(o: String): String { - val info = o.split(",").toTypedArray() + /*val info = o.split(",").toTypedArray() val zt = info[0].substring(info[0].indexOf(":") + 1) if (!"1".endsWith(zt)) { return "" @@ -82,8 +89,16 @@ object LanZouApi { var dom = info[1].substring(info[1].indexOf(":") + 2, info[1].lastIndexOf("\"")) var url = info[2].substring(info[2].indexOf(":") + 2, info[2].lastIndexOf("\"")) dom = dom.replace("\\", "") - url = url.replace("\\", "") - return "$dom/file/$url" + url = url.replace("\\", "")*/ + val lanZouBean = GSON.fromJsonObject(o) + lanZouBean?.run { + return if (zt == 1) { + "$dom/file/$url" + } else { + inf + } + } + return "" } /**