From d5decd9bee4c2bc5a993359650085e47f3599357 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 22 Nov 2019 11:21:12 +0800 Subject: [PATCH] up --- .../java/io/legado/app/help/storage/OldRule.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 ede6f2c13..36e134afa 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 @@ -1,6 +1,7 @@ package io.legado.app.help.storage 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.rule.* import io.legado.app.help.storage.Restore.jsonPath @@ -32,6 +33,8 @@ object OldRule { header = uaToHeader(jsonItem.readString("httpUserAgent")) searchUrl = toNewUrl(jsonItem.readString("ruleSearchUrl")) exploreUrl = toNewUrls(jsonItem.readString("ruleFindUrl")) + bookSourceType = + if (jsonItem.readString("bookSourceType") == "AUDIO") BookType.audio else BookType.default if (exploreUrl.isNullOrBlank()) { enabledExplore = false } @@ -98,7 +101,7 @@ object OldRule { val urls = oldUrl.split("(&&|\n)+".toRegex()) var newUrl = "" for (url in urls) { - newUrl += toNewUrl(url)?.replace("\\n\\s*".toRegex(),"") + "\n" + newUrl += toNewUrl(url)?.replace("\\n\\s*".toRegex(), "") + "\n" } return newUrl } @@ -132,10 +135,13 @@ object OldRule { url = url.replace("{", "<").replace("}", ">") url = url.replace("searchKey", "{{key}}") url = url.replace("".toRegex(), "{{page$1}}") - .replace("searchPage([-+]1)".toRegex(), "{{page$1}}") - .replace("searchPage", "{{page}}") + .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")) + url = url.replace( + "$$index", + item.replace("searchKey", "key").replace("searchPage", "page") + ) } urlList = url.split("@") url = urlList[0]