|
|
@ -33,10 +33,14 @@ object BookContent { |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") |
|
|
|
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") |
|
|
|
|
|
|
|
val analyzeRule = AnalyzeRule(book) |
|
|
|
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, bookChapter, bookSource, baseUrl) |
|
|
|
var contentData = analyzeContent( |
|
|
|
|
|
|
|
analyzeRule.setContent(body, baseUrl), |
|
|
|
|
|
|
|
contentRule, bookChapter, bookSource |
|
|
|
|
|
|
|
) |
|
|
|
content.append(contentData.content.replace(bookChapter.title, "")) |
|
|
|
content.append(contentData.content.replace(bookChapter.title, "")) |
|
|
|
if (contentData.nextUrl.size == 1) { |
|
|
|
if (contentData.nextUrl.size == 1) { |
|
|
|
var nextUrl = contentData.nextUrl[0] |
|
|
|
var nextUrl = contentData.nextUrl[0] |
|
|
@ -58,8 +62,8 @@ object BookContent { |
|
|
|
.body?.let { nextBody -> |
|
|
|
.body?.let { nextBody -> |
|
|
|
contentData = |
|
|
|
contentData = |
|
|
|
analyzeContent( |
|
|
|
analyzeContent( |
|
|
|
nextBody, contentRule, book, |
|
|
|
analyzeRule.setContent(nextBody, nextUrl), |
|
|
|
bookChapter, bookSource, baseUrl, false |
|
|
|
contentRule, bookChapter, bookSource, false |
|
|
|
) |
|
|
|
) |
|
|
|
nextUrl = |
|
|
|
nextUrl = |
|
|
|
if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" |
|
|
|
if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" |
|
|
@ -83,8 +87,8 @@ object BookContent { |
|
|
|
.body?.let { |
|
|
|
.body?.let { |
|
|
|
contentData = |
|
|
|
contentData = |
|
|
|
analyzeContent( |
|
|
|
analyzeContent( |
|
|
|
it, contentRule, book, bookChapter, |
|
|
|
analyzeRule.setContent(it, item.nextUrl), |
|
|
|
bookSource, item.nextUrl, false |
|
|
|
contentRule, bookChapter, bookSource, false |
|
|
|
) |
|
|
|
) |
|
|
|
item.content = contentData.content |
|
|
|
item.content = contentData.content |
|
|
|
} |
|
|
|
} |
|
|
@ -94,6 +98,7 @@ object BookContent { |
|
|
|
content.append(item.content) |
|
|
|
content.append(item.content) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取章节名称") |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取章节名称") |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${bookChapter.title}") |
|
|
|
Debug.log(bookSource.bookSourceUrl, "└${bookChapter.title}") |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取正文内容") |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取正文内容") |
|
|
@ -103,17 +108,13 @@ object BookContent { |
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
@Throws(Exception::class) |
|
|
|
private fun analyzeContent( |
|
|
|
private fun analyzeContent( |
|
|
|
body: String, |
|
|
|
analyzeRule: AnalyzeRule, |
|
|
|
contentRule: ContentRule, |
|
|
|
contentRule: ContentRule, |
|
|
|
book: Book, |
|
|
|
|
|
|
|
chapter: BookChapter, |
|
|
|
chapter: BookChapter, |
|
|
|
bookSource: BookSource, |
|
|
|
bookSource: BookSource, |
|
|
|
baseUrl: String, |
|
|
|
|
|
|
|
printLog: Boolean = true |
|
|
|
printLog: Boolean = true |
|
|
|
): ContentData<List<String>> { |
|
|
|
): ContentData<List<String>> { |
|
|
|
val nextUrlList = arrayListOf<String>() |
|
|
|
val nextUrlList = arrayListOf<String>() |
|
|
|
val analyzeRule = AnalyzeRule(book) |
|
|
|
|
|
|
|
analyzeRule.setContent(body, baseUrl) |
|
|
|
|
|
|
|
analyzeRule.chapter = chapter |
|
|
|
analyzeRule.chapter = chapter |
|
|
|
val nextUrlRule = contentRule.nextContentUrl |
|
|
|
val nextUrlRule = contentRule.nextContentUrl |
|
|
|
if (!nextUrlRule.isNullOrEmpty()) { |
|
|
|
if (!nextUrlRule.isNullOrEmpty()) { |
|
|
|