diff --git a/app/src/main/java/io/legado/app/data/entities/rule/BookListRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/BookListRule.kt new file mode 100644 index 000000000..31676052d --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/rule/BookListRule.kt @@ -0,0 +1,14 @@ +package io.legado.app.data.entities.rule + +interface BookListRule { + var bookList: String? + var name: String? + var author: String? + var intro: String? + var kind: String? + var lastChapter: String? + var updateTime: String? + var bookUrl: String? + var coverUrl: String? + var wordCount: String? +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt index 6f262857e..12792f7b7 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt @@ -2,14 +2,14 @@ package io.legado.app.data.entities.rule data class ExploreRule( var exploreUrl: String? = null, - var bookList: String? = null, - var name: String? = null, - var author: String? = null, - var intro: String? = null, - var kind: String? = null, - var lastChapter: String? = null, - var updateTime: String? = null, - var bookUrl: String? = null, - var coverUrl: String? = null, - var wordCount: String? = null -) \ No newline at end of file + override var bookList: String? = null, + override var name: String? = null, + override var author: String? = null, + override var intro: String? = null, + override var kind: String? = null, + override var lastChapter: String? = null, + override var updateTime: String? = null, + override var bookUrl: String? = null, + override var coverUrl: String? = null, + override var wordCount: String? = null +) : BookListRule \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt index e0b047df5..bef943962 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt @@ -2,14 +2,14 @@ package io.legado.app.data.entities.rule data class SearchRule( var searchUrl: String? = null, - var bookList: String? = null, - var name: String? = null, - var author: String? = null, - var intro: String? = null, - var kind: String? = null, - var lastChapter: String? = null, - var updateTime: String? = null, - var bookUrl: String? = null, - var coverUrl: String? = null, - var wordCount: String? = null -) \ No newline at end of file + override var bookList: String? = null, + override var name: String? = null, + override var author: String? = null, + override var intro: String? = null, + override var kind: String? = null, + override var lastChapter: String? = null, + override var updateTime: String? = null, + override var bookUrl: String? = null, + override var coverUrl: String? = null, + override var wordCount: String? = null +) : BookListRule \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 0aaa0d6ff..264e646c2 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -107,7 +107,7 @@ object Restore { source.loginUrl = jsonItem.readString("loginUrl") source.bookUrlPattern = jsonItem.readString("ruleBookUrlPattern") val searchRule = SearchRule( - searchUrl = jsonItem.readString("ruleSearchUrl"), + searchUrl = jsonItem.readString("ruleSearchUrl"), bookList = jsonItem.readString("ruleSearchList"), name = jsonItem.readString("ruleSearchName"), author = jsonItem.readString("ruleSearchAuthor"), @@ -119,7 +119,7 @@ object Restore { ) source.ruleSearch = GSON.toJson(searchRule) val exploreRule = ExploreRule( - exploreUrl = jsonItem.readString("ruleFindUrl"), + exploreUrl = jsonItem.readString("ruleFindUrl"), bookList = jsonItem.readString("ruleFindList"), name = jsonItem.readString("ruleFindName"), author = jsonItem.readString("ruleFindAuthor"), diff --git a/app/src/main/java/io/legado/app/model/webbook/BookList.kt b/app/src/main/java/io/legado/app/model/webbook/BookList.kt index 827384c57..c1212aed7 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookList.kt @@ -37,6 +37,31 @@ class BookList { } return bookList } + } + val collections: List + var reverse = false + var allInOne = false + val bookListRule = if (isSearch) bookSource.getSearchRule() else bookSource.getExploreRule() + var ruleList = bookListRule.bookList ?: "" + if (ruleList.startsWith("-")) { + reverse = true + ruleList = ruleList.substring(1) + } + if (ruleList.startsWith(":")) { + ruleList = ruleList.substring(1) + } + if (ruleList.startsWith("+")) { + allInOne = true + ruleList = ruleList.substring(1) + } + collections = analyzer.getElements(ruleList) + if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) { + getItem(analyzer, bookSource, baseUrl)?.let { searchBook -> + searchBook.bookInfoHtml = body + bookList.add(searchBook) + } + } else { + } return bookList }