From 0cc3938c085037147d69cab0cd55d65131120d16 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 09:22:28 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E5=87=80=E5=8C=96?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E5=9C=A8=E7=AE=80=E7=B9=81=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E8=BF=9B=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/entities/BookChapter.kt | 12 ++++++------ .../main/java/io/legado/app/help/ContentProcessor.kt | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) 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 b6581689e..2f46bc002 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 @@ -81,6 +81,12 @@ data class BookChapter( ): String { var displayTitle = title.replace(AppPattern.rnRegex, "") val mDisplayTitle = displayTitle + if (chineseConvert) { + when (AppConfig.chineseConverterType) { + 1 -> displayTitle = ChineseUtils.t2s(displayTitle) + 2 -> displayTitle = ChineseUtils.s2t(displayTitle) + } + } if (useReplace && replaceRules != null) { replaceRules.forEach { item -> if (item.pattern.isNotEmpty()) { @@ -97,12 +103,6 @@ data class BookChapter( } } if (displayTitle.isBlank()) displayTitle = mDisplayTitle - if (chineseConvert) { - when (AppConfig.chineseConverterType) { - 1 -> displayTitle = ChineseUtils.t2s(displayTitle) - 2 -> displayTitle = ChineseUtils.s2t(displayTitle) - } - } return when { !isVip -> displayTitle isPay -> appCtx.getString(R.string.payed_title, displayTitle) diff --git a/app/src/main/java/io/legado/app/help/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/ContentProcessor.kt index 800fde6a7..f8ed62e9a 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -77,10 +77,6 @@ class ContentProcessor private constructor( //重新分段 mContent = ContentHelp.reSegment(mContent, chapter.title) } - if (useReplace && book.getUseReplaceRule()) { - //替换 - mContent = replaceContent(mContent) - } if (chineseConvert) { //简繁转换 try { @@ -92,6 +88,10 @@ class ContentProcessor private constructor( appCtx.toastOnUi("简繁转换出错") } } + if (useReplace && book.getUseReplaceRule()) { + //替换 + mContent = replaceContent(mContent) + } if (includeTitle) { //重新添加标题 mContent = chapter.getDisplayTitle(getReplaceRules()) + "\n" + mContent From 5404c768862dfb1fc2ecb3672a9aedb0c16f6933 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 11:55:51 +0800 Subject: [PATCH 2/8] =?UTF-8?q?txt=E8=A7=84=E5=88=99=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=AD=97=E6=95=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/localBook/TextFile.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt index 02c05ca29..e39c4f007 100644 --- a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt @@ -45,6 +45,8 @@ class TextFile(private val book: Book) { //没有标题的时候,每个章节的最大长度 private val maxLengthWithNoToc = 10 * 1024 + //使用正则划分目录,每个章节的最大允许长度 + private val maxLengthWithToc = 102400 private val tocRules = arrayListOf() private var charset: Charset = book.fileCharset() @@ -126,7 +128,7 @@ class TextFile(private val book: Book) { val chapterContent = blockContent.substring(seekPos, chapterStart) val chapterLength = chapterContent.toByteArray(charset).size val lastStart = toc.lastOrNull()?.start ?: curOffset - if (curOffset + chapterLength - lastStart > 102400) { + if (curOffset + chapterLength - lastStart > maxLengthWithToc) { bis.close() return analyze() } From eeb64942addcf923fe4946b79ca095e2ea46ee01 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 11:57:15 +0800 Subject: [PATCH 3/8] =?UTF-8?q?updateFinalMessage=EF=BC=9A=E6=9C=80?= =?UTF-8?q?=E7=BB=88=E7=9A=84=E6=A0=A1=E9=AA=8C=E6=8F=90=E7=A4=BA=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E5=8F=A6=E8=B5=B7=E4=B8=80=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/Debug.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/Debug.kt b/app/src/main/java/io/legado/app/model/Debug.kt index 690e25f96..de34e8263 100644 --- a/app/src/main/java/io/legado/app/model/Debug.kt +++ b/app/src/main/java/io/legado/app/model/Debug.kt @@ -97,8 +97,7 @@ object Debug { val spendingTime = System.currentTimeMillis() - debugTimeMap[sourceUrl]!! debugTimeMap[sourceUrl] = if (state == "成功") spendingTime else 180000L val printTime = debugTimeFormat.format(Date(spendingTime)) - val originalMessage = debugMessageMap[sourceUrl]!!.substringAfter("] ") - debugMessageMap[sourceUrl] = "$printTime $originalMessage $state" + debugMessageMap[sourceUrl] = "$printTime $state" } } From dd978469f110ca0053752256b0857909ce7a798e Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 11:58:11 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E5=88=86=E7=BB=84=E5=92=8C=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/CheckSourceService.kt | 17 ++++++++++------- .../ui/book/source/manage/BookSourceAdapter.kt | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 0d4ac1351..7735fa736 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -15,6 +15,8 @@ import io.legado.app.help.coroutine.CompositeCoroutine import io.legado.app.model.CheckSource import io.legado.app.model.Debug import io.legado.app.model.NoStackTraceException +import io.legado.app.model.ContentEmptyException +import io.legado.app.model.TocEmptyException import io.legado.app.model.webBook.WebBook import io.legado.app.ui.book.source.manage.BookSourceActivity import io.legado.app.utils.activityPendingIntent @@ -173,9 +175,10 @@ class CheckSourceService : BaseService() { if (CheckSource.checkCategory) { val toc = WebBook.getChapterListAwait(this, source, book) val nextChapterUrl = toc.getOrNull(1)?.url ?: toc.first().url + source.removeGroup("目录失效") //校验正文 if (CheckSource.checkContent) { - val content = WebBook.getContentAwait( + WebBook.getContentAwait( this, bookSource = source, book = book, @@ -183,9 +186,7 @@ class CheckSourceService : BaseService() { nextChapterUrl = nextChapterUrl, needSave = false ) - if ( !toc.first().isVolume && content.isBlank()) { - throw NoStackTraceException("正文内容为空") - } + source.removeGroup("正文失效") } } } @@ -193,20 +194,22 @@ class CheckSourceService : BaseService() { if (source.hasGroup("发现失效")) throw NoStackTraceException("发现失效") }.timeout(CheckSource.timeout) .onError(searchCoroutine) { - source.addGroup("失效") + when(it) { + is ContentEmptyException -> source.addGroup("正文失效") + is TocEmptyException -> source.addGroup("目录失效") + } if (source.bookSourceComment?.contains("Error: ") == false) { source.bookSourceComment = "Error: ${it.localizedMessage} \n\n" + "${source.bookSourceComment}" } Debug.updateFinalMessage(source.bookSourceUrl, "失败:${it.localizedMessage}") }.onSuccess(searchCoroutine) { - source.removeGroup("失效") source.bookSourceComment = source.bookSourceComment ?.split("\n\n") ?.filterNot { it.startsWith("Error: ") }?.joinToString("\n") - Debug.updateFinalMessage(source.bookSourceUrl, "成功") + Debug.updateFinalMessage(source.bookSourceUrl, "校验成功") }.onFinally(searchCoroutine) { source.respondTime = Debug.getRespondTime(source.bookSourceUrl) appDb.bookSourceDao.update(source) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 1c663c27b..9ffeed0d3 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -92,7 +92,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : var isFinalMessage = ivDebugText.text.toString().contains(Regex("成功|失败")) if (!isEmpty && !Debug.isChecking && !isFinalMessage) { - Debug.updateFinalMessage(item.bookSourceUrl, "失败") + Debug.updateFinalMessage(item.bookSourceUrl, "校验失败") ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" isFinalMessage = true } From 774cedb7960a034d4d6d8aa99683dc915e0cdebe Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 13:08:12 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=83=BD=E5=BA=94=E8=AF=A5=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=BA=90=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/CheckSourceService.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 7735fa736..31ea800b4 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -123,6 +123,11 @@ class CheckSourceService : BaseService() { searchWord = it } } + source.bookSourceComment = source.bookSourceComment + ?.split("\n\n") + ?.filterNot { + it.startsWith("Error: ") + }?.joinToString("\n") //校验搜索 用户设置校验搜索 并且 搜索链接不为空 if (CheckSource.checkSearch && !source.searchUrl.isNullOrBlank()) { val searchBooks = WebBook.searchBookAwait(this, source, searchWord) @@ -198,17 +203,10 @@ class CheckSourceService : BaseService() { is ContentEmptyException -> source.addGroup("正文失效") is TocEmptyException -> source.addGroup("目录失效") } - if (source.bookSourceComment?.contains("Error: ") == false) { - source.bookSourceComment = - "Error: ${it.localizedMessage} \n\n" + "${source.bookSourceComment}" - } + source.bookSourceComment = + "Error: ${it.localizedMessage} \n\n" + "${source.bookSourceComment}" Debug.updateFinalMessage(source.bookSourceUrl, "失败:${it.localizedMessage}") }.onSuccess(searchCoroutine) { - source.bookSourceComment = source.bookSourceComment - ?.split("\n\n") - ?.filterNot { - it.startsWith("Error: ") - }?.joinToString("\n") Debug.updateFinalMessage(source.bookSourceUrl, "校验成功") }.onFinally(searchCoroutine) { source.respondTime = Debug.getRespondTime(source.bookSourceUrl) From ad380e814a695f1cfa64232100ac5c88ff30c9ac Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 13:28:54 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0updateFinalMessage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/Debug.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/Debug.kt b/app/src/main/java/io/legado/app/model/Debug.kt index de34e8263..aad76d367 100644 --- a/app/src/main/java/io/legado/app/model/Debug.kt +++ b/app/src/main/java/io/legado/app/model/Debug.kt @@ -95,7 +95,7 @@ object Debug { fun updateFinalMessage(sourceUrl: String, state: String) { if (debugTimeMap[sourceUrl] != null && debugMessageMap[sourceUrl] != null) { val spendingTime = System.currentTimeMillis() - debugTimeMap[sourceUrl]!! - debugTimeMap[sourceUrl] = if (state == "成功") spendingTime else 180000L + debugTimeMap[sourceUrl] = if (state == "校验成功") spendingTime else 180000L val printTime = debugTimeFormat.format(Date(spendingTime)) debugMessageMap[sourceUrl] = "$printTime $state" } From 192346d240042603e0f423e14bbfc02a6e8d95f0 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 13:45:34 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index b2ba8b407..61be7e0ee 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -11,6 +11,12 @@ * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! +**2022/02/07** + +* 校验失效分组具体到搜索发现目录正文 +* txt文件初次解析目录不选择禁用的正则 +* txt单章字数超102400均分txt + **2022/02/03** * 字符串大于1024时禁用代码高亮 From f528d3a550b9c9f7afbd238d4c85709c96e374b8 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 14:35:04 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B9=A6=E6=BA=90?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2=E5=B8=AE=E5=8A=A9=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/help/SourceMBookHelp.md | 2 +- app/src/main/assets/help/SourceMRssHelp.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/assets/help/SourceMBookHelp.md b/app/src/main/assets/help/SourceMBookHelp.md index e14590232..9561ed69f 100644 --- a/app/src/main/assets/help/SourceMBookHelp.md +++ b/app/src/main/assets/help/SourceMBookHelp.md @@ -22,4 +22,4 @@ * 置底所选 * 导出所选 * 校验所选 -* 校验失败的书源分组会加上"失效",选择"失效"分组即可批量操作 \ No newline at end of file +* "校验成功"是指所选的校验项目全部通过,"失败:发现为空"不视为"失效",校验结束后会自动筛选"失效"书源 \ No newline at end of file diff --git a/app/src/main/assets/help/SourceMRssHelp.md b/app/src/main/assets/help/SourceMRssHelp.md index 5f29a5128..b43ff75a0 100644 --- a/app/src/main/assets/help/SourceMRssHelp.md +++ b/app/src/main/assets/help/SourceMRssHelp.md @@ -17,5 +17,4 @@ * 禁用所选 * 置顶所选 * 置底所选 - * 导出所选 -* 校验失败的书源分组会加上"失效",选择"失效"分组即可批量操作 \ No newline at end of file + * 导出所选 \ No newline at end of file