Explorar el Código

Merge pull request #1701 from Xwite/master

书源校验添加js失效,图片的书源类型应该为2
kunfei hace 4 años
padre
commit
885a138998

+ 1 - 1
app/src/main/assets/help/SourceMBookHelp.md

@@ -24,6 +24,6 @@
   * 校验所选
   * 校验所选
 * 校验书源可批量校验书源,由于网络等原因结果仅限参考
 * 校验书源可批量校验书源,由于网络等原因结果仅限参考
   * "校验成功"是指所选的校验项目全部通过
   * "校验成功"是指所选的校验项目全部通过
-  * 可正常识别搜索为空、发现为空、搜索(发现)目录为空、搜索(发现)正文为空、校验超时导致的失效,其余原因(网站异常、源码变动)导致的视为规则失效
+  * 可正常识别搜索为空、发现为空、搜索(发现)目录为空、搜索(发现)正文为空、校验超时、js执行错误导致的失效,其余的原因视为网站失效
   * 校验搜索优先使用书源填写的校验关键词,不存在时使用用户输入的关键词
   * 校验搜索优先使用书源填写的校验关键词,不存在时使用用户输入的关键词
   * 校验结束后会自动筛选"失效"书源
   * 校验结束后会自动筛选"失效"书源

+ 2 - 2
app/src/main/assets/web/bookSource/index.html

@@ -4,7 +4,7 @@
 <head>
 <head>
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <title>阅读3.0源编辑器_V4.0</title>
     <title>阅读3.0源编辑器_V4.0</title>
-    <link rel="icon" href="favicon.ico">
+    <link rel="icon" href="../favicon.ico">
     <link rel="stylesheet" type="text/css" href="index.css"/>
     <link rel="stylesheet" type="text/css" href="index.css"/>
 </head>
 </head>
 
 
@@ -25,7 +25,7 @@
             <div>
             <div>
                 <div>源类型 :</div>
                 <div>源类型 :</div>
                 <textarea rows="1" id="bookSourceType" class="base" title="bookSourceType"
                 <textarea rows="1" id="bookSourceType" class="base" title="bookSourceType"
-                          placeholder="&lt;必填&gt;0:文本 1:音频 3:图片"></textarea>
+                          placeholder="&lt;必填&gt;0:文本 1:音频 2:图片"></textarea>
             </div>
             </div>
             <div>
             <div>
                 <div>源名称 :</div>
                 <div>源名称 :</div>

+ 1 - 1
app/src/main/assets/web/rssSource/index.html

@@ -4,7 +4,7 @@
 <head>
 <head>
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <title>阅读3.0订阅源编辑器_V4.0</title>
     <title>阅读3.0订阅源编辑器_V4.0</title>
-    <link rel="icon" href="favicon.ico">
+    <link rel="icon" href="../favicon.ico">
     <link rel="stylesheet" type="text/css" href="index.css"/>
     <link rel="stylesheet" type="text/css" href="index.css"/>
 </head>
 </head>
 
 

+ 1 - 1
app/src/main/java/io/legado/app/constant/BookType.kt

@@ -5,7 +5,7 @@ import androidx.annotation.IntDef
 object BookType {
 object BookType {
     const val default = 0           // 0 文本
     const val default = 0           // 0 文本
     const val audio = 1             // 1 音频
     const val audio = 1             // 1 音频
-    const val image = 3             //图片
+    const val image = 2             //图片
     const val local = "loc_book"
     const val local = "loc_book"
 
 
     @Target(AnnotationTarget.VALUE_PARAMETER)
     @Target(AnnotationTarget.VALUE_PARAMETER)

+ 1 - 1
app/src/main/java/io/legado/app/data/entities/BookSource.kt

@@ -26,7 +26,7 @@ data class BookSource(
     var bookSourceName: String = "",
     var bookSourceName: String = "",
     // 分组
     // 分组
     var bookSourceGroup: String? = null,
     var bookSourceGroup: String? = null,
-    // 类型,0 文本,1 音频, 3 图片
+    // 类型,0 文本,1 音频, 2 图片
     @BookType.Type
     @BookType.Type
     var bookSourceType: Int = 0,
     var bookSourceType: Int = 0,
     // 详情页url正则
     // 详情页url正则

+ 4 - 6
app/src/main/java/io/legado/app/service/CheckSourceService.kt

@@ -24,6 +24,8 @@ import kotlinx.coroutines.asCoroutineDispatcher
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.launch
 import java.util.concurrent.Executors
 import java.util.concurrent.Executors
 import kotlin.math.min
 import kotlin.math.min
+import org.mozilla.javascript.WrappedException
+import javax.script.ScriptException
 
 
 /**
 /**
  * 校验书源
  * 校验书源
@@ -176,18 +178,15 @@ class CheckSourceService : BaseService() {
         }.timeout(CheckSource.timeout)
         }.timeout(CheckSource.timeout)
             .onError(searchCoroutine) {
             .onError(searchCoroutine) {
                 when(it) {
                 when(it) {
-                    //校验超时不能正常实现 不能识别
                     is TimeoutCancellationException -> source.addGroup("校验超时")
                     is TimeoutCancellationException -> source.addGroup("校验超时")
-                    //NoStackTraceException 已经添加了分组,其余的视为规则失效
-                    !is NoStackTraceException -> source.addGroup("规则失效")
+                    is ScriptException, is WrappedException -> source.addGroup("js失效")
+                    !is NoStackTraceException -> source.addGroup("网站失效")
                 }
                 }
                 source.bookSourceComment =
                 source.bookSourceComment =
                     "Error: ${it.localizedMessage}" + if (source.bookSourceComment.isNullOrBlank())
                     "Error: ${it.localizedMessage}" + if (source.bookSourceComment.isNullOrBlank())
                         "" else "\n\n${source.bookSourceComment}"
                         "" else "\n\n${source.bookSourceComment}"
                 Debug.updateFinalMessage(source.bookSourceUrl, "校验失败:${it.localizedMessage}")
                 Debug.updateFinalMessage(source.bookSourceUrl, "校验失败:${it.localizedMessage}")
             }.onSuccess(searchCoroutine) {
             }.onSuccess(searchCoroutine) {
-                source.removeGroup("失效")
-                source.removeGroup("规则失效")
                 source.removeGroup("校验超时")
                 source.removeGroup("校验超时")
                 Debug.updateFinalMessage(source.bookSourceUrl, "校验成功")
                 Debug.updateFinalMessage(source.bookSourceUrl, "校验成功")
             }.onFinally(IO) {
             }.onFinally(IO) {
@@ -230,7 +229,6 @@ class CheckSourceService : BaseService() {
             when (it) {
             when (it) {
                 is ContentEmptyException -> source.addGroup("${bookType}正文失效")
                 is ContentEmptyException -> source.addGroup("${bookType}正文失效")
                 is TocEmptyException -> source.addGroup("${bookType}目录失效")
                 is TocEmptyException -> source.addGroup("${bookType}目录失效")
-                //超时 网站异常 源码改变
                 else -> throw it
                 else -> throw it
             }
             }
         }.onSuccess {
         }.onSuccess {