|
|
@ -24,7 +24,8 @@ object BookChapterList { |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|
body: String?, |
|
|
|
body: String?, |
|
|
|
bookSource: BookSource, |
|
|
|
bookSource: BookSource, |
|
|
|
baseUrl: String |
|
|
|
baseUrl: String, |
|
|
|
|
|
|
|
redirectUrl: String |
|
|
|
): List<BookChapter> = suspendCancellableCoroutine { block -> |
|
|
|
): List<BookChapter> = suspendCancellableCoroutine { block -> |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
val chapterList = ArrayList<BookChapter>() |
|
|
|
val chapterList = ArrayList<BookChapter>() |
|
|
@ -46,7 +47,15 @@ object BookChapterList { |
|
|
|
} |
|
|
|
} |
|
|
|
var chapterData = |
|
|
|
var chapterData = |
|
|
|
analyzeChapterList( |
|
|
|
analyzeChapterList( |
|
|
|
scope, book, baseUrl, body, tocRule, listRule, bookSource, log = true |
|
|
|
scope, |
|
|
|
|
|
|
|
book, |
|
|
|
|
|
|
|
baseUrl, |
|
|
|
|
|
|
|
redirectUrl, |
|
|
|
|
|
|
|
body, |
|
|
|
|
|
|
|
tocRule, |
|
|
|
|
|
|
|
listRule, |
|
|
|
|
|
|
|
bookSource, |
|
|
|
|
|
|
|
log = true |
|
|
|
) |
|
|
|
) |
|
|
|
chapterData.chapterList?.let { |
|
|
|
chapterData.chapterList?.let { |
|
|
|
chapterList.addAll(it) |
|
|
|
chapterList.addAll(it) |
|
|
@ -66,7 +75,14 @@ object BookChapterList { |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
headerMapF = bookSource.getHeaderMap() |
|
|
|
).getStrResponse(bookSource.bookSourceUrl).body?.let { nextBody -> |
|
|
|
).getStrResponse(bookSource.bookSourceUrl).body?.let { nextBody -> |
|
|
|
chapterData = analyzeChapterList( |
|
|
|
chapterData = analyzeChapterList( |
|
|
|
this, book, nextUrl, nextBody, tocRule, listRule, bookSource |
|
|
|
this, |
|
|
|
|
|
|
|
book, |
|
|
|
|
|
|
|
nextUrl, |
|
|
|
|
|
|
|
nextUrl, |
|
|
|
|
|
|
|
nextBody, |
|
|
|
|
|
|
|
tocRule, |
|
|
|
|
|
|
|
listRule, |
|
|
|
|
|
|
|
bookSource |
|
|
|
) |
|
|
|
) |
|
|
|
nextUrl = chapterData.nextUrl.firstOrNull() ?: "" |
|
|
|
nextUrl = chapterData.nextUrl.firstOrNull() ?: "" |
|
|
|
chapterData.chapterList?.let { |
|
|
|
chapterData.chapterList?.let { |
|
|
@ -128,7 +144,15 @@ object BookChapterList { |
|
|
|
).getStrResponse(bookSource.bookSourceUrl).body |
|
|
|
).getStrResponse(bookSource.bookSourceUrl).body |
|
|
|
?: throw Exception("${chapterData.nextUrl}, 下载失败") |
|
|
|
?: throw Exception("${chapterData.nextUrl}, 下载失败") |
|
|
|
val nextChapterData = analyzeChapterList( |
|
|
|
val nextChapterData = analyzeChapterList( |
|
|
|
this, book, chapterData.nextUrl, nextBody, tocRule, listRule, bookSource, false |
|
|
|
this, |
|
|
|
|
|
|
|
book, |
|
|
|
|
|
|
|
chapterData.nextUrl, |
|
|
|
|
|
|
|
chapterData.nextUrl, |
|
|
|
|
|
|
|
nextBody, |
|
|
|
|
|
|
|
tocRule, |
|
|
|
|
|
|
|
listRule, |
|
|
|
|
|
|
|
bookSource, |
|
|
|
|
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
synchronized(chapterDataList) { |
|
|
|
synchronized(chapterDataList) { |
|
|
|
val isFinished = addChapterListIsFinish( |
|
|
|
val isFinished = addChapterListIsFinish( |
|
|
@ -195,6 +219,7 @@ object BookChapterList { |
|
|
|
scope: CoroutineScope, |
|
|
|
scope: CoroutineScope, |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|
baseUrl: String, |
|
|
|
baseUrl: String, |
|
|
|
|
|
|
|
redirectUrl: String, |
|
|
|
body: String, |
|
|
|
body: String, |
|
|
|
tocRule: TocRule, |
|
|
|
tocRule: TocRule, |
|
|
|
listRule: String, |
|
|
|
listRule: String, |
|
|
@ -204,6 +229,7 @@ object BookChapterList { |
|
|
|
): ChapterData<List<String>> { |
|
|
|
): ChapterData<List<String>> { |
|
|
|
val analyzeRule = AnalyzeRule(book) |
|
|
|
val analyzeRule = AnalyzeRule(book) |
|
|
|
analyzeRule.setContent(body).setBaseUrl(baseUrl) |
|
|
|
analyzeRule.setContent(body).setBaseUrl(baseUrl) |
|
|
|
|
|
|
|
analyzeRule.setRedirectUrl(redirectUrl) |
|
|
|
//获取目录列表 |
|
|
|
//获取目录列表 |
|
|
|
val chapterList = arrayListOf<BookChapter>() |
|
|
|
val chapterList = arrayListOf<BookChapter>() |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取目录列表", log) |
|
|
|
Debug.log(bookSource.bookSourceUrl, "┌获取目录列表", log) |
|
|
|