pull/38/head
kunfei 5 years ago
parent 66f17ba898
commit ca910982eb
  1. 12
      app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt
  2. 47
      app/src/main/java/io/legado/app/model/webbook/BookList.kt
  3. 18
      app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt

@ -133,7 +133,7 @@ object BookChapterList {
val analyzeRule = AnalyzeRule(book)
analyzeRule.setContent(body, baseUrl)
if (getNextUrl) {
SourceDebug.printLog(bookSource.bookSourceUrl, "获取目录下一页列表", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取目录下一页列表", printLog)
analyzeRule.getStringList(tocRule.nextTocUrl ?: "", true)?.let {
for (item in it) {
if (item != baseUrl) {
@ -144,14 +144,14 @@ object BookChapterList {
SourceDebug.printLog(
bookSource.bookSourceUrl,
TextUtils.join(",", nextUrlList),
print = printLog
printLog
)
}
SourceDebug.printLog(bookSource.bookSourceUrl, "解析目录列表", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "解析目录列表", printLog)
val elements = analyzeRule.getElements(listRule)
SourceDebug.printLog(bookSource.bookSourceUrl, "目录数${elements.size}", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "目录数${elements.size}", printLog)
if (elements.isNotEmpty()) {
SourceDebug.printLog(bookSource.bookSourceUrl, "获取目录", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取目录", printLog)
val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName ?: "")
val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl ?: "")
for (item in elements) {
@ -168,7 +168,7 @@ object BookChapterList {
SourceDebug.printLog(
bookSource.bookSourceUrl,
"${chapterList[0].title}${chapterList[0].url}",
print = printLog
printLog
)
}
return ChapterData(chapterList, nextUrlList)

@ -133,11 +133,7 @@ object BookList {
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.kind)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取简介")
searchBook.intro = analyzeRule.getString(intro ?: "")
SourceDebug.printLog(
bookSource.bookSourceUrl,
msg = searchBook.intro,
isHtml = true
)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.intro, true)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取字数")
searchBook.wordCount = analyzeRule.getString(wordCount ?: "")
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.wordCount)
@ -174,43 +170,34 @@ object BookList {
searchBook.originOrder = bookSource.customOrder
analyzeRule.setBook(searchBook)
analyzeRule.setContent(item)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取书名", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取书名", printLog)
searchBook.name = analyzeRule.getString(ruleName)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.name, print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.name, printLog)
if (searchBook.name.isNotEmpty()) {
SourceDebug.printLog(bookSource.bookSourceUrl, "获取书籍Url", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取书籍Url", printLog)
searchBook.bookUrl = analyzeRule.getString(ruleBookUrl, true)
if (searchBook.bookUrl.isEmpty()) {
searchBook.bookUrl = baseUrl
}
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.bookUrl, print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取作者", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.bookUrl, printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取作者", printLog)
searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(ruleAuthor))
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.author, print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取分类", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.author, printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取分类", printLog)
searchBook.kind = analyzeRule.getString(ruleKind)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.kind, print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取简介", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.kind, printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取简介", printLog)
searchBook.intro = analyzeRule.getString(ruleIntro)
SourceDebug.printLog(
bookSource.bookSourceUrl,
searchBook.intro,
print = printLog,
isHtml = true
)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取字数", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.intro, printLog, true)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取字数", printLog)
searchBook.wordCount = analyzeRule.getString(ruleWordCount)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.wordCount, print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取封面Url", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.wordCount, printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取封面Url", printLog)
searchBook.coverUrl = analyzeRule.getString(ruleCoverUrl, true)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.coverUrl, print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取最新章节", print = printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.coverUrl, printLog)
SourceDebug.printLog(bookSource.bookSourceUrl, "获取最新章节", printLog)
searchBook.latestChapterTitle = analyzeRule.getString(ruleLastChapter)
SourceDebug.printLog(
bookSource.bookSourceUrl,
searchBook.latestChapterTitle,
print = printLog
)
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.latestChapterTitle, printLog)
return searchBook
}
return null

@ -25,10 +25,10 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
fun printLog(
sourceUrl: String?,
msg: String?,
state: Int = 1,
print: Boolean = true,
isHtml: Boolean = false,
showTime: Boolean = true
showTime: Boolean = true,
state: Int = 1
) {
if (debugSource != sourceUrl || callback == null || !print) return
var printMsg = msg ?: ""
@ -82,12 +82,12 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
printLog(debugSource, "", showTime = false)
infoDebug(searchBooks[0].toBook())
} else {
printLog(debugSource, "未获取到书籍", -1)
printLog(debugSource, "未获取到书籍", state = -1)
}
}
}
.onError {
printLog(debugSource, it.localizedMessage, -1)
printLog(debugSource, it.localizedMessage, state = -1)
}
tasks.add(search)
}
@ -101,7 +101,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
tocDebug(book)
}
.onError {
printLog(debugSource, it.localizedMessage, -1)
printLog(debugSource, it.localizedMessage, state = -1)
}
tasks.add(info)
}
@ -117,12 +117,12 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
val nextChapterUrl = if (it.size > 1) it[1].url else null
contentDebug(book, it[0], nextChapterUrl)
} else {
printLog(debugSource, "目录列表为空", -1)
printLog(debugSource, "目录列表为空", state = -1)
}
}
}
.onError {
printLog(debugSource, it.localizedMessage, -1)
printLog(debugSource, it.localizedMessage, state = -1)
}
tasks.add(chapterList)
}
@ -132,11 +132,11 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) {
val content = webBook.getContent(book, bookChapter, nextChapterUrl)
.onSuccess { content ->
content?.let {
printLog(debugSource, it, 1000)
printLog(debugSource, it, state = 1000)
}
}
.onError {
printLog(debugSource, it.localizedMessage, -1)
printLog(debugSource, it.localizedMessage, state = -1)
}
tasks.add(content)
}

Loading…
Cancel
Save