|
|
@ -1,6 +1,7 @@ |
|
|
|
package io.legado.app.model.webBook |
|
|
|
package io.legado.app.model.webBook |
|
|
|
|
|
|
|
|
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
|
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
import io.legado.app.data.entities.rule.BookListRule |
|
|
|
import io.legado.app.data.entities.rule.BookListRule |
|
|
@ -124,59 +125,16 @@ object BookList { |
|
|
|
baseUrl: String, |
|
|
|
baseUrl: String, |
|
|
|
variable: String? |
|
|
|
variable: String? |
|
|
|
): SearchBook? { |
|
|
|
): SearchBook? { |
|
|
|
val searchBook = SearchBook(variable = variable) |
|
|
|
val book = Book(variable = variable) |
|
|
|
searchBook.bookUrl = baseUrl |
|
|
|
book.bookUrl = baseUrl |
|
|
|
searchBook.origin = bookSource.bookSourceUrl |
|
|
|
book.origin = bookSource.bookSourceUrl |
|
|
|
searchBook.originName = bookSource.bookSourceName |
|
|
|
book.originName = bookSource.bookSourceName |
|
|
|
searchBook.originOrder = bookSource.customOrder |
|
|
|
book.originOrder = bookSource.customOrder |
|
|
|
searchBook.type = bookSource.bookSourceType |
|
|
|
book.type = bookSource.bookSourceType |
|
|
|
analyzeRule.book = searchBook |
|
|
|
analyzeRule.book = book |
|
|
|
with(bookSource.getBookInfoRule()) { |
|
|
|
BookInfo.analyzeBookInfo(scope, book, analyzeRule, bookSource, baseUrl, baseUrl, false) |
|
|
|
init?.let { |
|
|
|
if (book.name.isNotBlank()) { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
return book.toSearchBook() |
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "≡执行详情页初始化规则") |
|
|
|
|
|
|
|
analyzeRule.setContent(analyzeRule.getElement(it)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取书名") |
|
|
|
|
|
|
|
searchBook.name = BookHelp.formatBookName(analyzeRule.getString(name)) |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.name}") |
|
|
|
|
|
|
|
if (searchBook.name.isNotEmpty()) { |
|
|
|
|
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取作者") |
|
|
|
|
|
|
|
searchBook.author = BookHelp.formatBookAuthor(analyzeRule.getString(author)) |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.author}") |
|
|
|
|
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取分类") |
|
|
|
|
|
|
|
searchBook.kind = analyzeRule.getStringList(kind)?.joinToString(",") |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.kind}") |
|
|
|
|
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取字数") |
|
|
|
|
|
|
|
searchBook.wordCount = wordCountFormat(analyzeRule.getString(wordCount)) |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.wordCount}") |
|
|
|
|
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取最新章节") |
|
|
|
|
|
|
|
searchBook.latestChapterTitle = analyzeRule.getString(lastChapter) |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.latestChapterTitle}") |
|
|
|
|
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取简介") |
|
|
|
|
|
|
|
searchBook.intro = analyzeRule.getString(intro).htmlFormat() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.intro}") |
|
|
|
|
|
|
|
scope.ensureActive() |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接") |
|
|
|
|
|
|
|
searchBook.coverUrl = analyzeRule.getString(coverUrl, true) |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.coverUrl}") |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取目录链接") |
|
|
|
|
|
|
|
searchBook.tocUrl = analyzeRule.getString(tocUrl, true) |
|
|
|
|
|
|
|
if (searchBook.tocUrl.isEmpty()) searchBook.tocUrl = baseUrl |
|
|
|
|
|
|
|
if (searchBook.tocUrl == baseUrl) { |
|
|
|
|
|
|
|
searchBook.tocHtml = analyzeRule.content.toString() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${searchBook.tocUrl}") |
|
|
|
|
|
|
|
return searchBook |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|