|
|
@ -1,16 +1,15 @@ |
|
|
|
package io.legado.app.model.webbook |
|
|
|
package io.legado.app.model.webbook |
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
import android.annotation.SuppressLint |
|
|
|
import io.legado.app.App |
|
|
|
|
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.data.entities.BookChapter |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
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 java.text.SimpleDateFormat |
|
|
|
import java.text.SimpleDateFormat |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
class Debug(sourceUrl: String) { |
|
|
|
class SourceDebug(val webBook: WebBook) { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
var debugSource: String? = null |
|
|
|
var debugSource: String? = null |
|
|
@ -36,16 +35,8 @@ class Debug(sourceUrl: String) { |
|
|
|
fun printLog(state: Int, msg: String) |
|
|
|
fun printLog(state: Int, msg: String) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private var bookSource: BookSource? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
|
|
|
debugSource = sourceUrl |
|
|
|
|
|
|
|
bookSource = App.db.bookSourceDao().findByKey(sourceUrl) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun searchDebug(key: String) { |
|
|
|
fun searchDebug(key: String) { |
|
|
|
bookSource?.let { |
|
|
|
webBook.searchBook(key, 1) |
|
|
|
WebBook(it).searchBook(key, 1) |
|
|
|
|
|
|
|
.onSuccess { searchBooks -> |
|
|
|
.onSuccess { searchBooks -> |
|
|
|
searchBooks?.let { |
|
|
|
searchBooks?.let { |
|
|
|
if (searchBooks.isNotEmpty()) { |
|
|
|
if (searchBooks.isNotEmpty()) { |
|
|
@ -53,15 +44,32 @@ class Debug(sourceUrl: String) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} ?: printLog(debugSource, -1, "未找到书源") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun infoDebug(book: Book) { |
|
|
|
fun infoDebug(book: Book) { |
|
|
|
bookSource?.let { |
|
|
|
webBook.getBookInfo(book) |
|
|
|
WebBook(it).getBookInfo(book) |
|
|
|
.onSuccess { |
|
|
|
} ?: printLog(debugSource, -1, "未找到书源") |
|
|
|
tocDebug(book) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun tocDebug(book: Book) { |
|
|
|
|
|
|
|
webBook.getChapterList(book) |
|
|
|
|
|
|
|
.onSuccess { chapterList -> |
|
|
|
|
|
|
|
chapterList?.let { |
|
|
|
|
|
|
|
if (it.isNotEmpty()) { |
|
|
|
|
|
|
|
contentDebug(book, it[0]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun contentDebug(book: Book, bookChapter: BookChapter) { |
|
|
|
|
|
|
|
webBook.getContent(book, bookChapter) |
|
|
|
|
|
|
|
.onSuccess { content -> |
|
|
|
|
|
|
|
content?.let { |
|
|
|
|
|
|
|
printLog(debugSource, 1000, it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |