From baccd099e6fc6da123176ae180cbdf58dc4ab6c2 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Thu, 13 Jan 2022 15:39:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E4=B8=80=E7=BA=A7=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E6=97=B6=EF=BC=8C=E7=9B=AE=E5=BD=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/webBook/BookChapterList.kt | 4 ++-- app/src/main/java/io/legado/app/model/webBook/WebBook.kt | 4 ++-- .../app/ui/book/read/page/provider/ChapterProvider.kt | 6 +++--- 3 files changed, 7 insertions(+), 7 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 72d13880d..faf5f1fa4 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 @@ -193,8 +193,8 @@ object BookChapterList { } if (bookChapter.url.isEmpty()) { if (bookChapter.isVolume) { - bookChapter.url = bookChapter.title - Debug.log(bookSource.bookSourceUrl, "一级目录${index}未获取到url,使用章节标题替代") + bookChapter.url = bookChapter.title + index + Debug.log(bookSource.bookSourceUrl, "一级目录${index}未获取到url,使用${bookChapter.title}${index}替代") } else { bookChapter.url = baseUrl Debug.log(bookSource.bookSourceUrl, "目录${index}未获取到url,使用baseUrl替代") diff --git a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt index c1f727fd0..9cda244cf 100644 --- a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt @@ -261,8 +261,8 @@ object WebBook { Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}") return bookChapter.url } - if(bookChapter.isVolume && bookChapter.url == bookChapter.title) { - Debug.log(bookSource.bookSourceUrl, "⇒一级目录获取链接为空,使用${bookChapter.tag}") + if(bookChapter.isVolume && bookChapter.url.startsWith(bookChapter.title)) { + Debug.log(bookSource.bookSourceUrl, "⇒一级目录正文不解析规则") return bookChapter.tag ?: "" } return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index d42c60a66..ebfbcb0f8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -129,7 +129,7 @@ object ChapterProvider { matcher.appendTail(sb) text = sb.toString() val isTitle = index == 0 - val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank() + val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1 val textPaint = if (isTitle) titlePaint else contentPaint if (!(isTitle && ReadBookConfig.titleMode == 2)) { setTypeText( @@ -147,7 +147,7 @@ object ChapterProvider { val text = content.substring(start, matcher.start()) if (text.isNotBlank()) { val isTitle = index == 0 - val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank() + val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1 val textPaint = if (isTitle) titlePaint else contentPaint if (!(isTitle && ReadBookConfig.titleMode == 2)) { setTypeText( @@ -169,7 +169,7 @@ object ChapterProvider { val text = content.substring(start, content.length) if (text.isNotBlank()) { val isTitle = index == 0 - val isVolumeTitle = bookChapter.isVolume && isTitle && bookChapter.url == bookChapter.title && bookChapter.tag.isNullOrBlank() + val isVolumeTitle = bookChapter.isVolume && isTitle && contents.size == 1 val textPaint = if (isTitle) titlePaint else contentPaint if (!(isTitle && ReadBookConfig.titleMode == 2)) { setTypeText( From 2ddb8cebe7b3d17ec289cb1cb41e2c09744f2b4c Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Thu, 13 Jan 2022 17:23:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E7=9A=84=E5=8D=B7=E8=BF=9E=E6=8E=A5=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=20=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=BF=94=E5=9B=9E=E4=B8=BA=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/entities/BookChapter.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt index cf5b2b2b7..5c80fc034 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt @@ -109,6 +109,8 @@ data class BookChapter( } fun getAbsoluteURL(): String { + //二级目录解析的卷链接为空 返回目录页的链接 + if (url.startsWith(title) && isVolume) return baseUrl val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) val urlBefore = if (urlMatcher.find()) url.substring(0, urlMatcher.start()) else url val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl, urlBefore)