pull/49/head
kunfei 5 years ago
parent a3ed717db2
commit d5decd9bee
  1. 10
      app/src/main/java/io/legado/app/help/storage/OldRule.kt

@ -1,6 +1,7 @@
package io.legado.app.help.storage package io.legado.app.help.storage
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.BookType
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.* import io.legado.app.data.entities.rule.*
import io.legado.app.help.storage.Restore.jsonPath import io.legado.app.help.storage.Restore.jsonPath
@ -32,6 +33,8 @@ object OldRule {
header = uaToHeader(jsonItem.readString("httpUserAgent")) header = uaToHeader(jsonItem.readString("httpUserAgent"))
searchUrl = toNewUrl(jsonItem.readString("ruleSearchUrl")) searchUrl = toNewUrl(jsonItem.readString("ruleSearchUrl"))
exploreUrl = toNewUrls(jsonItem.readString("ruleFindUrl")) exploreUrl = toNewUrls(jsonItem.readString("ruleFindUrl"))
bookSourceType =
if (jsonItem.readString("bookSourceType") == "AUDIO") BookType.audio else BookType.default
if (exploreUrl.isNullOrBlank()) { if (exploreUrl.isNullOrBlank()) {
enabledExplore = false enabledExplore = false
} }
@ -98,7 +101,7 @@ object OldRule {
val urls = oldUrl.split("(&&|\n)+".toRegex()) val urls = oldUrl.split("(&&|\n)+".toRegex())
var newUrl = "" var newUrl = ""
for (url in urls) { for (url in urls) {
newUrl += toNewUrl(url)?.replace("\\n\\s*".toRegex(),"") + "\n" newUrl += toNewUrl(url)?.replace("\\n\\s*".toRegex(), "") + "\n"
} }
return newUrl return newUrl
} }
@ -135,7 +138,10 @@ object OldRule {
.replace("searchPage([-+]1)".toRegex(), "{{page$1}}") .replace("searchPage([-+]1)".toRegex(), "{{page$1}}")
.replace("searchPage", "{{page}}") .replace("searchPage", "{{page}}")
for ((index, item) in jsList.withIndex()) { for ((index, item) in jsList.withIndex()) {
url = url.replace("$$index", item.replace("searchKey", "key").replace("searchPage", "page")) url = url.replace(
"$$index",
item.replace("searchKey", "key").replace("searchPage", "page")
)
} }
urlList = url.split("@") urlList = url.split("@")
url = urlList[0] url = urlList[0]

Loading…
Cancel
Save