diff --git a/app/src/main/assets/defaultData/bookSources.json b/app/src/main/assets/defaultData/bookSources.json index 4aa0bd993..d77f3b1ee 100644 --- a/app/src/main/assets/defaultData/bookSources.json +++ b/app/src/main/assets/defaultData/bookSources.json @@ -5,11 +5,11 @@ "bookSourceName": "消消乐听书", "bookSourceType": 1, "bookSourceUrl": "https://www.kaixin7days.com", - "customOrder": -31077, + "customOrder": 0, "enabled": true, "enabledExplore": true, - "exploreUrl": "@js:var header = source.getLoginHeader()\nvar json = \"\"\nvar j = null\nif (header != null) {\n json = java.connect('https://www.kaixin7days.com/book-service/bookMgt/getBookCategroy,{\"method\":\"POST\",\"body\":{}}', header).body()\n j = JSON.parse(json)\n}\nif (j == null || j.statusCode == 301) {\n json = java.connect('https://www.kaixin7days.com/visitorLogin,{\"method\":\"POST\", \"body\":{} }').body()\n j = JSON.parse(json)\n var accessToken = {\n Authorization: \"Bearer \" + j.content.accessToken\n }\n header = JSON.stringify(accessToken)\n source.putLoginHeader(header)\n json = java.connect('https://www.kaixin7days.com/book-service/bookMgt/getBookCategroy,{\"method\":\"POST\",\"body\":{} }', header).body()\n j = JSON.parse(json)\n}\nvar fls = j.content\nvar fx = []\nfor (var i = 0; i < fls.length; i++) {\n fx.push({\n title: fls[i].categoryName,\n url: '/book-service/bookMgt/getAllBookByCategroyId,{\"method\":\"POST\",\"body\":{\"categoryIds\": \"' + fls[i].associationCategoryIDs + '\",\"pageNum\": {{page}},\"pageSize\": 100}}'\n })\n}\nfx", - "lastUpdateTime": 1630595885516, + "exploreUrl": "@js:var header = source.getLoginHeader()\nvar json = \"\"\nvar j = null\nif (header != null) {\n json = java.connect('https://www.kaixin7days.com/book-service/bookMgt/getBookCategroy,{\"method\":\"POST\",\"body\":{}}', header).body()\n j = JSON.parse(json)\n}\nif (j == null || j.statusCode == 301) {\n json = java.connect('https://www.kaixin7days.com/visitorLogin,{\"method\":\"POST\", \"body\":{} }').body()\n j = JSON.parse(json)\n var accessToken = {\n Authorization: \"Bearer \" + j.content.accessToken\n }\n header = JSON.stringify(accessToken)\n source.putLoginHeader(header)\n json = java.connect('https://www.kaixin7days.com/book-service/bookMgt/getBookCategroy,{\"method\":\"POST\",\"body\":{} }', header).body()\n j = JSON.parse(json)\n}\nvar fls = j.content\nvar fx = []\nfor (var i = 0; i < fls.length; i++) {\n fx.push({\n title: fls[i].categoryName,\n url: '/book-service/bookMgt/getAllBookByCategroyId,{\"method\":\"POST\",\"body\":{\"categoryIds\": \"' + fls[i].associationCategoryIDs + '\",\"pageNum\": {{page}},\"pageSize\": 100}}'\n })\n}\nJSON.stringify(fx)", + "lastUpdateTime": 1630654191906, "loginCheckJs": "var strRes = result\nvar c = JSON.parse(result.body())\nif (c.statusCode == 301) {\n var loginInfo = source.getLoginInfo()\n var dl = null\n if (loginInfo) {\n dl = java.connect('https://www.kaixin7days.com/login,{\"method\":\"POST\",\"body\":' + loginInfo + '}').body()\n } else {\n dl = java.connect('https://www.kaixin7days.com/visitorLogin,{\"method\":\"POST\",\"body\":{}}').body()\n }\n c = JSON.parse(dl)\n var accessToken = {\n Authorization: \"Bearer \" + c.content.accessToken\n }\n var header = JSON.stringify(accessToken)\n source.putLoginHeader(header)\n strRes = java.connect(url, header)\n}\nstrRes", "loginUi": [ { @@ -30,7 +30,7 @@ "ruleExplore": { "author": "$.author", "bookList": "$.content.content", - "bookUrl": "$.id@js:'https://www.kaixin7days.com/book-service/bookMgt/getAllChapterByBookId,{\"bookId\": \"'+result+'\",\"pageNum\": 1,\"pageSize\": 100}'", + "bookUrl": "$.id@js:'https://www.kaixin7days.com/book-service/bookMgt/getAllChapterByBookId,{ \"method\": \"POST\",\"body\": {\"bookId\": \"'+result+'\",\"pageNum\": \"1\",\"pageSize\": \"100\"} }'", "coverUrl": "$.cover@js:var cover = JSON.parse(result);'https://www.shuidi.online:9021/fileMgt/getPicture?filePath='+cover.storeFilePath", "intro": "$.desc", "lastChapter": "$.newestChapter", diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 297690f27..3534161f6 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -453,6 +453,18 @@ class AnalyzeRule( } else -> ruleStr } + if (mode != Mode.Js) { + //非js规则才需要继续处理 + initNonJsRule() + } + } + + /** + * 处理非js规则,js不做处理 + * js里面的{{}}规则可以留到下次处理 + * 一些url需要实时更新参数可以再内嵌套{{}},{{}}会访问时才处理 + */ + private fun initNonJsRule() { //分离put rule = splitPutRule(rule, putMap) //@get,{{ }}, 拆分 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 338ea72d0..efa1b5632 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 @@ -128,7 +128,7 @@ object WebBook { //检测书源是否已登录 bookSource.loginCheckJs?.let { checkJs -> if (checkJs.isNotBlank()) { - res = analyzeUrl.evalJS(checkJs) as StrResponse + res = analyzeUrl.evalJS(checkJs, result = res) as StrResponse } } return BookList.analyzeBookList( @@ -186,7 +186,7 @@ object WebBook { //检测书源是否已登录 bookSource.loginCheckJs?.let { checkJs -> if (checkJs.isNotBlank()) { - res = analyzeUrl.evalJS(checkJs) as StrResponse + res = analyzeUrl.evalJS(checkJs, result = res) as StrResponse } } BookInfo.analyzeBookInfo( @@ -243,7 +243,7 @@ object WebBook { //检测书源是否已登录 bookSource.loginCheckJs?.let { checkJs -> if (checkJs.isNotBlank()) { - res = analyzeUrl.evalJS(checkJs) as StrResponse + res = analyzeUrl.evalJS(checkJs, result = res) as StrResponse } } BookChapterList.analyzeChapterList( @@ -312,7 +312,7 @@ object WebBook { //检测书源是否已登录 bookSource.loginCheckJs?.let { checkJs -> if (checkJs.isNotBlank()) { - res = analyzeUrl.evalJS(checkJs) as StrResponse + res = analyzeUrl.evalJS(checkJs, result = res) as StrResponse } } BookContent.analyzeContent(