Merge remote-tracking branch 'origin/master'

pull/48/head
kunfei 5 years ago
commit c5fbe83ef8
  1. 19
      app/src/main/java/io/legado/app/help/storage/OldRule.kt
  2. 5
      app/src/main/java/io/legado/app/model/webbook/BookContent.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("<searchPage([-+]1)>".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"))
}

@ -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)

Loading…
Cancel
Save