pull/1395/head
gedoor 3 years ago
parent fcf3d949f8
commit 3be6838d3d
  1. 13
      app/src/main/assets/defaultData/httpTTS.json
  2. 7
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  3. 28
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -13,8 +13,17 @@
"id": -29, "id": -29,
"name": "3.阿里云语音", "name": "3.阿里云语音",
"url": "https://nls-gateway.cn-shanghai.aliyuncs.com/stream/v1/tts,{\"method\": \"POST\",\"body\", {\"appkey\":\"31f932fb\",\"text\":\"{{speakText}}\",\"format\":\"mp3\"}}", "url": "https://nls-gateway.cn-shanghai.aliyuncs.com/stream/v1/tts,{\"method\": \"POST\",\"body\", {\"appkey\":\"31f932fb\",\"text\":\"{{speakText}}\",\"format\":\"mp3\"}}",
"loginUrl": "", "loginUrl": "var query = 'AccessKeyId=' + source.loginInfoMap().get('AccessKeyId') + '&Action=CreateToken&Version=2019-02-28&Format=JSON&RegionId=cn-shanghai&SignatureMethod=HMAC-SHA1&SignatureVersion=1.0&SignatureNonce=' + java.UUID",
"loginUi": "", "loginUi": [
{
"name": "AccessKeyId",
"type": "text"
},
{
"name": "AccessKeySecret",
"type": "text"
}
],
"loginCheckJs": "" "loginCheckJs": ""
} }
] ]

@ -473,6 +473,13 @@ interface JsExtensions {
return msg return msg
} }
/**
* 生成UUID
*/
fun randomUUID(): String {
return UUID.randomUUID().toString()
}
/** /**
* AES 解码为 ByteArray * AES 解码为 ByteArray
* @param str 传入的AES加密的数据 * @param str 传入的AES加密的数据

@ -27,11 +27,11 @@ import kotlin.collections.HashMap
* Created by GKF on 2018/1/24. * Created by GKF on 2018/1/24.
* 搜索URL规则解析 * 搜索URL规则解析
*/ */
@Suppress("unused") @Suppress("unused", "MemberVisibilityCanBePrivate")
@Keep @Keep
@SuppressLint("DefaultLocale") @SuppressLint("DefaultLocale")
class AnalyzeUrl( class AnalyzeUrl(
var ruleUrl: String, val mUrl: String,
val key: String? = null, val key: String? = null,
val page: Int? = null, val page: Int? = null,
val speakText: String? = null, val speakText: String? = null,
@ -48,13 +48,15 @@ class AnalyzeUrl(
private val accessTime = hashMapOf<String, FetchRecord>() private val accessTime = hashMapOf<String, FetchRecord>()
} }
val headerMap = HashMap<String, String>() var ruleUrl = ""
private set
var url: String = "" var url: String = ""
private set private set
var body: String? = null var body: String? = null
private set private set
var type: String? = null var type: String? = null
private set private set
val headerMap = HashMap<String, String>()
private var urlNoQuery: String = "" private var urlNoQuery: String = ""
private var queryStr: String? = null private var queryStr: String? = null
private val fieldMap = LinkedHashMap<String, String>() private val fieldMap = LinkedHashMap<String, String>()
@ -75,12 +77,20 @@ class AnalyzeUrl(
headerMap.remove("proxy") headerMap.remove("proxy")
} }
} }
initUrl()
}
/**
* 处理url
*/
fun initUrl() {
ruleUrl = mUrl
//执行@js,<js></js> //执行@js,<js></js>
analyzeJs() analyzeJs()
//替换参数 //替换参数
replaceKeyPageJs() replaceKeyPageJs()
//处理URL //处理URL
initUrl() analyzeUrl()
} }
/** /**
@ -142,9 +152,9 @@ class AnalyzeUrl(
} }
/** /**
* 处理URL * 解析Url
*/ */
private fun initUrl() { private fun analyzeUrl() {
//replaceKeyPageJs已经替换掉额外内容,此处url是基础形式,可以直接切首个‘,’之前字符串。 //replaceKeyPageJs已经替换掉额外内容,此处url是基础形式,可以直接切首个‘,’之前字符串。
val urlMatcher = paramPattern.matcher(ruleUrl) val urlMatcher = paramPattern.matcher(ruleUrl)
val urlNoOption = val urlNoOption =
@ -245,12 +255,6 @@ class AnalyzeUrl(
return SCRIPT_ENGINE.eval(jsStr, bindings) return SCRIPT_ENGINE.eval(jsStr, bindings)
} }
fun upHeader() {
source?.getHeaderMap(true)?.let {
headerMap.putAll(it)
}
}
fun put(key: String, value: String): String { fun put(key: String, value: String): String {
chapter?.putVariable(key, value) chapter?.putVariable(key, value)
?: ruleData?.putVariable(key, value) ?: ruleData?.putVariable(key, value)

Loading…
Cancel
Save