From 2a6cfd97fd74a252c3e308483731e8ffd34d29eb Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 19 Feb 2021 09:19:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E4=B8=80=E9=A1=B5=E8=A7=84=E5=88=99?= =?UTF-8?q?=E6=94=BE=E5=88=B0=E5=90=8E=E9=9D=A2=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/webBook/BookChapterList.kt | 36 ++++++++++--------- .../legado/app/model/webBook/BookContent.kt | 4 ++- 2 files changed, 22 insertions(+), 18 deletions(-) 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 008ad3d6c..706de5022 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 @@ -204,24 +204,8 @@ object BookChapterList { ): ChapterData> { val analyzeRule = AnalyzeRule(book) analyzeRule.setContent(body).setBaseUrl(baseUrl) + //获取目录列表 val chapterList = arrayListOf() - val nextUrlList = arrayListOf() - val nextTocRule = tocRule.nextTocUrl - if (getNextUrl && !nextTocRule.isNullOrEmpty()) { - Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", log) - analyzeRule.getStringList(nextTocRule, true)?.let { - for (item in it) { - if (item != baseUrl) { - nextUrlList.add(item) - } - } - } - Debug.log( - bookSource.bookSourceUrl, - "└" + TextUtils.join(",\n", nextUrlList), - log - ) - } Debug.log(bookSource.bookSourceUrl, "┌获取目录列表", log) val elements = analyzeRule.getElements(listRule) Debug.log(bookSource.bookSourceUrl, "└列表大小:${elements.size}", log) @@ -258,6 +242,24 @@ object BookChapterList { Debug.log(bookSource.bookSourceUrl, "┌获取首章信息", log) Debug.log(bookSource.bookSourceUrl, "└${chapterList[0].tag}", log) } + //获取下一页链接 + val nextUrlList = arrayListOf() + val nextTocRule = tocRule.nextTocUrl + if (getNextUrl && !nextTocRule.isNullOrEmpty()) { + Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", log) + analyzeRule.getStringList(nextTocRule, true)?.let { + for (item in it) { + if (item != baseUrl) { + nextUrlList.add(item) + } + } + } + Debug.log( + bookSource.bookSourceUrl, + "└" + TextUtils.join(",\n", nextUrlList), + log + ) + } return ChapterData(chapterList, nextUrlList) } diff --git a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt index 77069b178..265035e1c 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt @@ -121,6 +121,9 @@ object BookContent { analyzeRule.setContent(body).setBaseUrl(baseUrl) val nextUrlList = arrayListOf() analyzeRule.chapter = chapter + //获取正文 + val content = analyzeRule.getString(contentRule.content) + //获取下一页链接 val nextUrlRule = contentRule.nextContentUrl if (!nextUrlRule.isNullOrEmpty()) { Debug.log(bookSource.bookSourceUrl, "┌获取正文下一页链接", printLog) @@ -129,7 +132,6 @@ object BookContent { } Debug.log(bookSource.bookSourceUrl, "└" + nextUrlList.joinToString(","), printLog) } - val content = analyzeRule.getString(contentRule.content) return ContentData(content, nextUrlList) } } \ No newline at end of file