|
|
|
@ -28,14 +28,14 @@ object BookList { |
|
|
|
|
analyzeUrl.ruleUrl |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取成功:${analyzeUrl.ruleUrl}") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取成功:${analyzeUrl.ruleUrl}") |
|
|
|
|
val analyzeRule = AnalyzeRule(null) |
|
|
|
|
analyzeRule.setContent(body, baseUrl) |
|
|
|
|
bookSource.bookUrlPattern?.let { |
|
|
|
|
if (baseUrl.matches(it.toRegex())) { |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "url为详情页") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "url为详情页") |
|
|
|
|
getInfoItem(analyzeRule, bookSource, baseUrl)?.let { searchBook -> |
|
|
|
|
searchBook.bookInfoHtml = body |
|
|
|
|
searchBook.infoHtml = body |
|
|
|
|
bookList.add(searchBook) |
|
|
|
|
} |
|
|
|
|
return bookList |
|
|
|
@ -56,12 +56,12 @@ object BookList { |
|
|
|
|
if (ruleList.startsWith("+")) { |
|
|
|
|
ruleList = ruleList.substring(1) |
|
|
|
|
} |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "解析书籍列表") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "解析书籍列表") |
|
|
|
|
collections = analyzeRule.getElements(ruleList) |
|
|
|
|
if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) { |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "列表为空,按详情页解析") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "列表为空,按详情页解析") |
|
|
|
|
getInfoItem(analyzeRule, bookSource, baseUrl)?.let { searchBook -> |
|
|
|
|
searchBook.bookInfoHtml = body |
|
|
|
|
searchBook.infoHtml = body |
|
|
|
|
bookList.add(searchBook) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -73,7 +73,7 @@ object BookList { |
|
|
|
|
val ruleKind = analyzeRule.splitSourceRule(bookListRule.kind ?: "") |
|
|
|
|
val ruleLastChapter = analyzeRule.splitSourceRule(bookListRule.lastChapter ?: "") |
|
|
|
|
val ruleWordCount = analyzeRule.splitSourceRule(bookListRule.wordCount ?: "") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "列表数为${collections.size}") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "列表数为${collections.size}") |
|
|
|
|
for ((index, item) in collections.withIndex()) { |
|
|
|
|
getSearchItem( |
|
|
|
|
item, |
|
|
|
@ -91,7 +91,7 @@ object BookList { |
|
|
|
|
ruleWordCount = ruleWordCount |
|
|
|
|
)?.let { searchBook -> |
|
|
|
|
if (baseUrl == searchBook.bookUrl) { |
|
|
|
|
searchBook.bookInfoHtml = body |
|
|
|
|
searchBook.infoHtml = body |
|
|
|
|
} |
|
|
|
|
bookList.add(searchBook) |
|
|
|
|
} |
|
|
|
@ -117,38 +117,36 @@ object BookList { |
|
|
|
|
with(bookSource.getBookInfoRule()) { |
|
|
|
|
init?.let { |
|
|
|
|
if (it.isNotEmpty()) { |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "执行详情页初始化规则") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "执行详情页初始化规则") |
|
|
|
|
analyzeRule.setContent(analyzeRule.getElement(it)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取书名") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取书名") |
|
|
|
|
searchBook.name = analyzeRule.getString(name ?: "") ?: "" |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.name) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.name) |
|
|
|
|
if (searchBook.name.isNotEmpty()) { |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取作者") |
|
|
|
|
searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(author ?: "")) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.author) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取分类") |
|
|
|
|
searchBook.kind = analyzeRule.getString(kind ?: "") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取简介") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.kind) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取简介") |
|
|
|
|
searchBook.intro = analyzeRule.getString(intro ?: "") |
|
|
|
|
SourceDebug.printLog( |
|
|
|
|
bookSource.bookSourceUrl, 1, searchBook.intro |
|
|
|
|
?: "", isHtml = true |
|
|
|
|
bookSource.bookSourceUrl, |
|
|
|
|
msg = searchBook.intro, |
|
|
|
|
isHtml = true |
|
|
|
|
) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取字数") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取字数") |
|
|
|
|
searchBook.wordCount = analyzeRule.getString(wordCount ?: "") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.wordCount ?: "") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取封面Url") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.wordCount) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取封面Url") |
|
|
|
|
searchBook.coverUrl = analyzeRule.getString(coverUrl ?: "", true) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.coverUrl ?: "") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取最新章节") |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.coverUrl) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取最新章节") |
|
|
|
|
searchBook.latestChapterTitle = analyzeRule.getString(lastChapter ?: "") |
|
|
|
|
SourceDebug.printLog( |
|
|
|
|
bookSource.bookSourceUrl, 1, searchBook.latestChapterTitle |
|
|
|
|
?: "" |
|
|
|
|
) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.latestChapterTitle) |
|
|
|
|
return searchBook |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -176,36 +174,42 @@ object BookList { |
|
|
|
|
searchBook.originOrder = bookSource.customOrder |
|
|
|
|
analyzeRule.setBook(searchBook) |
|
|
|
|
analyzeRule.setContent(item) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取书名", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取书名", print = printLog) |
|
|
|
|
searchBook.name = analyzeRule.getString(ruleName) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.name, printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.name, print = printLog) |
|
|
|
|
if (searchBook.name.isNotEmpty()) { |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取书籍Url", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取书籍Url", print = printLog) |
|
|
|
|
searchBook.bookUrl = analyzeRule.getString(ruleBookUrl, true) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.bookUrl, printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取作者", printLog) |
|
|
|
|
if (searchBook.bookUrl.isEmpty()) { |
|
|
|
|
searchBook.bookUrl = baseUrl |
|
|
|
|
} |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.bookUrl, print = printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取作者", print = printLog) |
|
|
|
|
searchBook.author = BookHelp.formatAuthor(analyzeRule.getString(ruleAuthor)) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.author, printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取分类", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.author, print = printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取分类", print = printLog) |
|
|
|
|
searchBook.kind = analyzeRule.getString(ruleKind) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.kind ?: "", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取简介", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.kind, print = printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取简介", print = printLog) |
|
|
|
|
searchBook.intro = analyzeRule.getString(ruleIntro) |
|
|
|
|
SourceDebug.printLog( |
|
|
|
|
bookSource.bookSourceUrl, 1, searchBook.intro |
|
|
|
|
?: "", printLog, true |
|
|
|
|
bookSource.bookSourceUrl, |
|
|
|
|
searchBook.intro, |
|
|
|
|
print = printLog, |
|
|
|
|
isHtml = true |
|
|
|
|
) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取字数", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取字数", print = printLog) |
|
|
|
|
searchBook.wordCount = analyzeRule.getString(ruleWordCount) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.wordCount ?: "", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取封面Url", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.wordCount, print = printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取封面Url", print = printLog) |
|
|
|
|
searchBook.coverUrl = analyzeRule.getString(ruleCoverUrl, true) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, searchBook.coverUrl ?: "", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取最新章节", printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, searchBook.coverUrl, print = printLog) |
|
|
|
|
SourceDebug.printLog(bookSource.bookSourceUrl, "获取最新章节", print = printLog) |
|
|
|
|
searchBook.latestChapterTitle = analyzeRule.getString(ruleLastChapter) |
|
|
|
|
SourceDebug.printLog( |
|
|
|
|
bookSource.bookSourceUrl, 1, searchBook.latestChapterTitle |
|
|
|
|
?: "", printLog |
|
|
|
|
bookSource.bookSourceUrl, |
|
|
|
|
searchBook.latestChapterTitle, |
|
|
|
|
print = printLog |
|
|
|
|
) |
|
|
|
|
return searchBook |
|
|
|
|
} |
|
|
|
|