pull/32/head
kunfei 5 years ago
parent 3082db966a
commit 87523bba2d
  1. 11
      app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt

@ -5,7 +5,6 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.coroutine.CompositeCoroutine import io.legado.app.help.coroutine.CompositeCoroutine
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
import io.legado.app.utils.htmlFormat import io.legado.app.utils.htmlFormat
import io.legado.app.utils.isAbsUrl import io.legado.app.utils.isAbsUrl
@ -66,11 +65,12 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
} }
} }
fun searchDebug(key: String) { private fun searchDebug(key: String) {
val search = webBook.searchBook(key, 1) val search = webBook.searchBook(key, 1)
.onSuccess { searchBooks -> .onSuccess { searchBooks ->
searchBooks?.let { searchBooks?.let {
if (searchBooks.isNotEmpty()) { if (searchBooks.isNotEmpty()) {
callback?.printLog(1, "")
infoDebug(BookHelp.toBook(searchBooks[0])) infoDebug(BookHelp.toBook(searchBooks[0]))
} }
} }
@ -81,9 +81,11 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
tasks.add(search) tasks.add(search)
} }
fun infoDebug(book: Book) { private fun infoDebug(book: Book) {
printLog(debugSource, 1, "开始获取详情页")
val info = webBook.getBookInfo(book) val info = webBook.getBookInfo(book)
.onSuccess { .onSuccess {
callback?.printLog(1, "")
tocDebug(book) tocDebug(book)
} }
.onError { .onError {
@ -93,10 +95,12 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
} }
private fun tocDebug(book: Book) { private fun tocDebug(book: Book) {
printLog(debugSource, 1, "开始获取目录页")
val chapterList = webBook.getChapterList(book) val chapterList = webBook.getChapterList(book)
.onSuccess { chapterList -> .onSuccess { chapterList ->
chapterList?.let { chapterList?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
callback?.printLog(1, "")
contentDebug(book, it[0]) contentDebug(book, it[0])
} }
} }
@ -108,6 +112,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
} }
private fun contentDebug(book: Book, bookChapter: BookChapter) { private fun contentDebug(book: Book, bookChapter: BookChapter) {
printLog(debugSource, 1, "开始获取内容")
val content = webBook.getContent(book, bookChapter) val content = webBook.getContent(book, bookChapter)
.onSuccess { content -> .onSuccess { content ->
content?.let { content?.let {

Loading…
Cancel
Save