diff --git a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt index 342ce041d..3d42ede02 100644 --- a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt +++ b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt @@ -45,16 +45,8 @@ object RssParserByRule { val ruleLink = analyzeRule.splitSourceRule(rssSource.ruleLink ?: "") for ((index, item) in collections.withIndex()) { getItem( - sourceUrl, - item, - analyzeRule, - index == 0, - ruleTitle, - rulePubDate, - ruleCategories, - ruleDescription, - ruleImage, - ruleLink + sourceUrl, item, analyzeRule, index == 0, ruleTitle, + rulePubDate, ruleCategories, ruleDescription, ruleImage, ruleLink )?.let { it.origin = rssSource.sourceUrl articleList.add(it) @@ -87,11 +79,19 @@ object RssParserByRule { Debug.log(sourceUrl, "┌获取标题", log) rssArticle.title = analyzeRule.getString(ruleTitle) Debug.log(sourceUrl, "└${rssArticle.title}", log) + Debug.log(sourceUrl, "┌获取时间", log) rssArticle.pubDate = analyzeRule.getString(rulePubDate) + Debug.log(sourceUrl, "└${rssArticle.pubDate}", log) + Debug.log(sourceUrl, "┌获取类别", log) rssArticle.categories = analyzeRule.getString(ruleCategories) + Debug.log(sourceUrl, "└${rssArticle.categories}", log) rssArticle.description = analyzeRule.getString(ruleDescription) + Debug.log(sourceUrl, "┌获取图片url", log) rssArticle.image = analyzeRule.getString(ruleImage, true) + Debug.log(sourceUrl, "└${rssArticle.image}", log) + Debug.log(sourceUrl, "┌获取文章链接", log) rssArticle.link = analyzeRule.getString(ruleLink) + Debug.log(sourceUrl, "└${rssArticle.link}", log) if (rssArticle.title.isBlank()) { return null } diff --git a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt index 9d2aaf9a0..50419000b 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt @@ -39,7 +39,7 @@ object BookChapterList { listRule = listRule.substring(1) } var chapterData = - analyzeChapterList(body, baseUrl, tocRule, listRule, book, bookSource, printLog = true) + analyzeChapterList(body, baseUrl, tocRule, listRule, book, bookSource, log = true) chapterData.chapterList?.let { chapterList.addAll(it) } @@ -48,19 +48,12 @@ object BookChapterList { while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) { nextUrlList.add(nextUrl) AnalyzeUrl( - ruleUrl = nextUrl, - book = book, - headerMapF = bookSource.getHeaderMap() + ruleUrl = nextUrl, book = book, headerMapF = bookSource.getHeaderMap() ).getResponseAwait() .body()?.let { nextBody -> chapterData = analyzeChapterList( - nextBody, - nextUrl, - tocRule, - listRule, - book, - bookSource, - printLog = false + nextBody, nextUrl, tocRule, listRule, + book, bookSource, log = false ) nextUrl = if (chapterData.nextUrl.isNotEmpty()) chapterData.nextUrl[0] @@ -79,18 +72,13 @@ object BookChapterList { } for (item in chapterDataList) { withContext(coroutineScope.coroutineContext) { - val nextResponse = AnalyzeUrl( + val nextBody = AnalyzeUrl( ruleUrl = item.nextUrl, book = book, headerMapF = bookSource.getHeaderMap() - ).getResponseAwait() + ).getResponseAwait().body() ?: "" val nextChapterData = analyzeChapterList( - nextResponse.body() ?: "", - item.nextUrl, - tocRule, - listRule, - book, - bookSource + nextBody, item.nextUrl, tocRule, listRule, book, bookSource ) item.chapterList = nextChapterData.chapterList } @@ -128,7 +116,7 @@ object BookChapterList { book: Book, bookSource: BookSource, getNextUrl: Boolean = true, - printLog: Boolean = false + log: Boolean = false ): ChapterData> { val chapterList = arrayListOf() val nextUrlList = arrayListOf() @@ -136,7 +124,7 @@ object BookChapterList { analyzeRule.setContent(body, baseUrl) val nextTocRule = tocRule.nextTocUrl if (getNextUrl && !nextTocRule.isNullOrEmpty()) { - Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", printLog) + Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", log) analyzeRule.getStringList(nextTocRule, true)?.let { for (item in it) { if (item != baseUrl) { @@ -147,14 +135,14 @@ object BookChapterList { Debug.log( bookSource.bookSourceUrl, "└" + TextUtils.join(",\n", nextUrlList), - printLog + log ) } - Debug.log(bookSource.bookSourceUrl, "┌获取目录列表", printLog) + Debug.log(bookSource.bookSourceUrl, "┌获取目录列表", log) val elements = analyzeRule.getElements(listRule) - Debug.log(bookSource.bookSourceUrl, "└列表大小:${elements.size}", printLog) + Debug.log(bookSource.bookSourceUrl, "└列表大小:${elements.size}", log) if (elements.isNotEmpty()) { - Debug.log(bookSource.bookSourceUrl, "┌获取首章名称", printLog) + Debug.log(bookSource.bookSourceUrl, "┌获取首章名称", log) val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName) val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl) val vipRule = analyzeRule.splitSourceRule(tocRule.isVip) @@ -176,9 +164,9 @@ object BookChapterList { chapterList.add(bookChapter) } } - Debug.log(bookSource.bookSourceUrl, "└${chapterList[0].title}", printLog) - Debug.log(bookSource.bookSourceUrl, "┌获取首章链接", printLog) - Debug.log(bookSource.bookSourceUrl, "└${chapterList[0].url}", printLog) + Debug.log(bookSource.bookSourceUrl, "└${chapterList[0].title}", log) + Debug.log(bookSource.bookSourceUrl, "┌获取首章链接", log) + Debug.log(bookSource.bookSourceUrl, "└${chapterList[0].url}", log) } return ChapterData(chapterList, nextUrlList) } diff --git a/app/src/main/java/io/legado/app/model/webbook/BookList.kt b/app/src/main/java/io/legado/app/model/webbook/BookList.kt index d1cd885f3..ed440b9f2 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookList.kt @@ -75,19 +75,10 @@ object BookList { Debug.log(bookSource.bookSourceUrl, "└列表大小:${collections.size}") for ((index, item) in collections.withIndex()) { getSearchItem( - item, - analyzeRule, - bookSource, - baseUrl, - index == 0, - ruleName = ruleName, - ruleBookUrl = ruleBookUrl, - ruleAuthor = ruleAuthor, - ruleCoverUrl = ruleCoverUrl, - ruleIntro = ruleIntro, - ruleKind = ruleKind, - ruleLastChapter = ruleLastChapter, - ruleWordCount = ruleWordCount + item, analyzeRule, bookSource, baseUrl, index == 0, + ruleName = ruleName, ruleBookUrl = ruleBookUrl, ruleAuthor = ruleAuthor, + ruleCoverUrl = ruleCoverUrl, ruleIntro = ruleIntro, ruleKind = ruleKind, + ruleLastChapter = ruleLastChapter, ruleWordCount = ruleWordCount )?.let { searchBook -> if (baseUrl == searchBook.bookUrl) { searchBook.infoHtml = body