pull/48/head
kunfei 5 years ago
parent dac407a470
commit 6ad7cbed20
  1. 1
      app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt
  2. 15
      app/src/main/java/io/legado/app/model/webbook/BookContent.kt
  3. 4
      app/src/main/java/io/legado/app/model/webbook/BookList.kt

@ -159,6 +159,7 @@ object BookChapterList {
for (item in elements) { for (item in elements) {
analyzeRule.setContent(item) analyzeRule.setContent(item)
val bookChapter = BookChapter(bookUrl = book.bookUrl) val bookChapter = BookChapter(bookUrl = book.bookUrl)
analyzeRule.chapter = bookChapter
bookChapter.title = analyzeRule.getString(nameRule) bookChapter.title = analyzeRule.getString(nameRule)
bookChapter.url = analyzeRule.getString(urlRule, true) bookChapter.url = analyzeRule.getString(urlRule, true)
if (bookChapter.url.isEmpty()) bookChapter.url = baseUrl if (bookChapter.url.isEmpty()) bookChapter.url = baseUrl

@ -35,7 +35,7 @@ object BookContent {
val content = StringBuilder() val content = StringBuilder()
val nextUrlList = arrayListOf(baseUrl) val nextUrlList = arrayListOf(baseUrl)
val contentRule = bookSource.getContentRule() val contentRule = bookSource.getContentRule()
var contentData = analyzeContent(body, contentRule, book, bookSource, baseUrl) var contentData = analyzeContent(body, contentRule, book, bookChapter, bookSource, baseUrl)
content.append(contentData.content) content.append(contentData.content)
if (contentData.nextUrl.size == 1) { if (contentData.nextUrl.size == 1) {
var nextUrl = contentData.nextUrl[0] var nextUrl = contentData.nextUrl[0]
@ -56,7 +56,15 @@ object BookContent {
).getResponseAwait() ).getResponseAwait()
.body()?.let { nextBody -> .body()?.let { nextBody ->
contentData = contentData =
analyzeContent(nextBody, contentRule, book, bookSource, baseUrl, false) analyzeContent(
nextBody,
contentRule,
book,
bookChapter,
bookSource,
baseUrl,
false
)
nextUrl = nextUrl =
if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else ""
content.append(contentData.content) content.append(contentData.content)
@ -82,6 +90,7 @@ object BookContent {
it, it,
contentRule, contentRule,
book, book,
bookChapter,
bookSource, bookSource,
item.nextUrl, item.nextUrl,
false false
@ -106,6 +115,7 @@ object BookContent {
body: String, body: String,
contentRule: ContentRule, contentRule: ContentRule,
book: Book, book: Book,
chapter: BookChapter,
bookSource: BookSource, bookSource: BookSource,
baseUrl: String, baseUrl: String,
printLog: Boolean = true printLog: Boolean = true
@ -113,6 +123,7 @@ object BookContent {
val nextUrlList = arrayListOf<String>() val nextUrlList = arrayListOf<String>()
val analyzeRule = AnalyzeRule(book) val analyzeRule = AnalyzeRule(book)
analyzeRule.setContent(body, baseUrl) analyzeRule.setContent(body, baseUrl)
analyzeRule.chapter = chapter
val nextUrlRule = contentRule.nextContentUrl val nextUrlRule = contentRule.nextContentUrl
if (!nextUrlRule.isNullOrEmpty()) { if (!nextUrlRule.isNullOrEmpty()) {
SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取正文下一页链接", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取正文下一页链接", printLog)

@ -111,7 +111,7 @@ object BookList {
searchBook.originName = bookSource.bookSourceName searchBook.originName = bookSource.bookSourceName
searchBook.originOrder = bookSource.customOrder searchBook.originOrder = bookSource.customOrder
searchBook.type = bookSource.bookSourceType searchBook.type = bookSource.bookSourceType
analyzeRule.setBook(searchBook) analyzeRule.book = searchBook
with(bookSource.getBookInfoRule()) { with(bookSource.getBookInfoRule()) {
init?.let { init?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
@ -167,7 +167,7 @@ object BookList {
searchBook.originName = bookSource.bookSourceName searchBook.originName = bookSource.bookSourceName
searchBook.type = bookSource.bookSourceType searchBook.type = bookSource.bookSourceType
searchBook.originOrder = bookSource.customOrder searchBook.originOrder = bookSource.customOrder
analyzeRule.setBook(searchBook) analyzeRule.book = searchBook
analyzeRule.setContent(item) analyzeRule.setContent(item)
SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取书名", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取书名", printLog)
searchBook.name = analyzeRule.getString(ruleName) searchBook.name = analyzeRule.getString(ruleName)

Loading…
Cancel
Save