Merge pull request #45 from Celeter/master

增加发现页调试
pull/46/head
kunfei 5 years ago committed by GitHub
commit b3b21725c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt

@ -65,14 +65,38 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
val book = Book() val book = Book()
book.origin = webBook.sourceUrl book.origin = webBook.sourceUrl
book.bookUrl = key book.bookUrl = key
printLog(webBook.sourceUrl, "⇒开始访问:$key") printLog(webBook.sourceUrl, "⇒开始访问详情页:$key")
infoDebug(book) infoDebug(book)
} else if (key.contains("::")) {
val url = key.substring(key.indexOf("::") + 2)
printLog(webBook.sourceUrl, "⇒开始访问发现页:$url")
exploreDebug(url)
} else { } else {
printLog(webBook.sourceUrl, "⇒开始搜索关键字:$key") printLog(webBook.sourceUrl, "⇒开始搜索关键字:$key")
searchDebug(key) searchDebug(key)
} }
} }
private fun exploreDebug(url: String) {
printLog(debugSource, "︾开始解析发现页")
val explore = webBook.exploreBook(url, 1)
.onSuccess { exploreBooks ->
exploreBooks?.let {
if (exploreBooks.isNotEmpty()) {
printLog(debugSource, "︽发现页解析完成")
printLog(debugSource, "", showTime = false)
infoDebug(exploreBooks[0].toBook())
} else {
printLog(debugSource, "︽未获取到书籍", state = -1)
}
}
}
.onError {
printLog(debugSource, it.localizedMessage, state = -1)
}
tasks.add(explore)
}
private fun searchDebug(key: String) { private fun searchDebug(key: String) {
printLog(debugSource, "︾开始解析搜索页") printLog(debugSource, "︾开始解析搜索页")
val search = webBook.searchBook(key, 1) val search = webBook.searchBook(key, 1)

Loading…
Cancel
Save