diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index 47d97b360..e58c3d682 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -31,7 +31,7 @@ object OldRule { customOrder = jsonItem.readInt("serialNumber") ?: 0 header = uaToHeader(jsonItem.readString("httpUserAgent")) searchUrl = toNewUrl(jsonItem.readString("ruleSearchUrl")) - exploreUrl = toNewUrl(jsonItem.readString("ruleFindUrl")) + exploreUrl = toNewUrls(jsonItem.readString("ruleFindUrl")) if (exploreUrl.isNullOrBlank()) { enabledExplore = false } @@ -86,6 +86,19 @@ object OldRule { return source } + private fun toNewUrls(oldUrl: String?): String? { + if (oldUrl == null) return null + if (!oldUrl.contains("\n") && !oldUrl.contains("&&")) + return toNewUrl(oldUrl) + + val urls = oldUrl.split("(&&|\n)+".toRegex()) + var newUrl = "" + for (url in urls) { + newUrl += toNewUrl(url)?.replace("\\n\\s*".toRegex(),"") + "\n" + } + return newUrl + } + private fun toNewUrl(oldUrl: String?): String? { if (oldUrl == null) return null var url: String = oldUrl @@ -114,7 +127,9 @@ object OldRule { } url = url.replace("{", "<").replace("}", ">") url = url.replace("searchKey", "{{key}}") - url = url.replace("searchPage", "{{page}}") + url = url.replace("".toRegex(), "{{page$1}}") + .replace("searchPage([-+]1)".toRegex(), "{{page$1}}") + .replace("searchPage", "{{page}}") for ((index, item) in jsList.withIndex()) { url = url.replace("$$index", item.replace("searchKey", "key").replace("searchPage", "page")) } diff --git a/app/src/main/java/io/legado/app/model/webbook/BookContent.kt b/app/src/main/java/io/legado/app/model/webbook/BookContent.kt index c6a520aa7..c0d530d80 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookContent.kt @@ -94,7 +94,10 @@ object BookContent { content.append(item.content) } } - return content.toString() + SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取章节名称") + SourceDebug.printLog(bookSource.bookSourceUrl, "└${bookChapter.title}") + SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取正文内容") + return "└\n" + content.toString() } @Throws(Exception::class)