|
|
@ -188,7 +188,7 @@ object WebBook { |
|
|
|
context: CoroutineContext = Dispatchers.IO |
|
|
|
context: CoroutineContext = Dispatchers.IO |
|
|
|
): Coroutine<List<BookChapter>> { |
|
|
|
): Coroutine<List<BookChapter>> { |
|
|
|
return Coroutine.async(scope, context) { |
|
|
|
return Coroutine.async(scope, context) { |
|
|
|
getChapterListAwait(scope, bookSource, book) |
|
|
|
getChapterListAwait(scope, bookSource, book).getOrThrow() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -196,40 +196,42 @@ object WebBook { |
|
|
|
scope: CoroutineScope, |
|
|
|
scope: CoroutineScope, |
|
|
|
bookSource: BookSource, |
|
|
|
bookSource: BookSource, |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|
): List<BookChapter> { |
|
|
|
): Result<List<BookChapter>> { |
|
|
|
book.type = bookSource.bookSourceType |
|
|
|
book.type = bookSource.bookSourceType |
|
|
|
return if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { |
|
|
|
return kotlin.runCatching { |
|
|
|
BookChapterList.analyzeChapterList( |
|
|
|
if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { |
|
|
|
scope = scope, |
|
|
|
BookChapterList.analyzeChapterList( |
|
|
|
bookSource = bookSource, |
|
|
|
scope = scope, |
|
|
|
book = book, |
|
|
|
bookSource = bookSource, |
|
|
|
baseUrl = book.tocUrl, |
|
|
|
book = book, |
|
|
|
redirectUrl = book.tocUrl, |
|
|
|
baseUrl = book.tocUrl, |
|
|
|
body = book.tocHtml |
|
|
|
redirectUrl = book.tocUrl, |
|
|
|
) |
|
|
|
body = book.tocHtml |
|
|
|
} else { |
|
|
|
) |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
} else { |
|
|
|
mUrl = book.tocUrl, |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
baseUrl = book.bookUrl, |
|
|
|
mUrl = book.tocUrl, |
|
|
|
source = bookSource, |
|
|
|
baseUrl = book.bookUrl, |
|
|
|
ruleData = book, |
|
|
|
source = bookSource, |
|
|
|
headerMapF = bookSource.getHeaderMap(true) |
|
|
|
ruleData = book, |
|
|
|
) |
|
|
|
headerMapF = bookSource.getHeaderMap(true) |
|
|
|
var res = analyzeUrl.getStrResponseAwait() |
|
|
|
) |
|
|
|
//检测书源是否已登录 |
|
|
|
var res = analyzeUrl.getStrResponseAwait() |
|
|
|
bookSource.loginCheckJs?.let { checkJs -> |
|
|
|
//检测书源是否已登录 |
|
|
|
if (checkJs.isNotBlank()) { |
|
|
|
bookSource.loginCheckJs?.let { checkJs -> |
|
|
|
res = analyzeUrl.evalJS(checkJs, result = res) as StrResponse |
|
|
|
if (checkJs.isNotBlank()) { |
|
|
|
|
|
|
|
res = analyzeUrl.evalJS(checkJs, result = res) as StrResponse |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
BookChapterList.analyzeChapterList( |
|
|
|
|
|
|
|
scope = scope, |
|
|
|
|
|
|
|
bookSource = bookSource, |
|
|
|
|
|
|
|
book = book, |
|
|
|
|
|
|
|
baseUrl = book.tocUrl, |
|
|
|
|
|
|
|
redirectUrl = res.url, |
|
|
|
|
|
|
|
body = res.body |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
BookChapterList.analyzeChapterList( |
|
|
|
|
|
|
|
scope = scope, |
|
|
|
|
|
|
|
bookSource = bookSource, |
|
|
|
|
|
|
|
book = book, |
|
|
|
|
|
|
|
baseUrl = book.tocUrl, |
|
|
|
|
|
|
|
redirectUrl = res.url, |
|
|
|
|
|
|
|
body = res.body |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|