pull/1705/head
kunfei 3 years ago
parent da61e62220
commit 71a37a4057
  1. 11
      app/src/main/java/io/legado/app/data/entities/Book.kt
  2. 11
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  3. 11
      app/src/main/java/io/legado/app/data/entities/RssArticle.kt
  4. 11
      app/src/main/java/io/legado/app/data/entities/RssStar.kt
  5. 6
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  6. 3
      app/src/main/java/io/legado/app/help/DirectLinkUpload.kt
  7. 14
      app/src/main/java/io/legado/app/model/analyzeRule/RuleData.kt
  8. 8
      app/src/main/java/io/legado/app/model/analyzeRule/RuleDataInterface.kt

@ -2,7 +2,6 @@ package io.legado.app.data.entities
import android.os.Parcelable
import androidx.room.*
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import io.legado.app.constant.BookType
import io.legado.app.data.appDb
@ -144,15 +143,7 @@ data class Book(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${name}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

@ -7,7 +7,6 @@ import androidx.room.Ignore
import androidx.room.Index
import com.github.liuyueyi.quick.transfer.ChineseUtils
import io.legado.app.R
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import io.legado.app.help.config.AppConfig
import io.legado.app.model.analyzeRule.AnalyzeUrl
@ -56,15 +55,7 @@ data class BookChapter(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

@ -2,7 +2,6 @@ package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.Ignore
import io.legado.app.constant.AppLog
import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject
@ -42,15 +41,7 @@ data class RssArticle(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

@ -2,7 +2,6 @@ package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.Ignore
import io.legado.app.constant.AppLog
import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject
@ -34,15 +33,7 @@ data class RssStar(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

@ -64,11 +64,7 @@ data class SearchBook(
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
variableMap[key] = value
} else {
variableMap.remove(key)
}
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}

@ -3,7 +3,6 @@ package io.legado.app.help
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.model.analyzeRule.RuleData
import io.legado.app.utils.jsonPath
import io.legado.app.utils.readString
import splitties.init.appCtx
@ -27,7 +26,7 @@ object DirectLinkUpload {
}
val analyzeUrl = AnalyzeUrl(url)
val res = analyzeUrl.upload(fileName, file, contentType)
val analyzeRule = AnalyzeRule(RuleData()).setContent(res.body, res.url)
val analyzeRule = AnalyzeRule().setContent(res.body, res.url)
val downloadUrl = analyzeRule.getString(downloadUrlRule)
if (downloadUrl.isBlank()) {
throw NoStackTraceException("上传失败,${res.body}")

@ -1,23 +1,9 @@
package io.legado.app.model.analyzeRule
import io.legado.app.constant.AppLog
class RuleData : RuleDataInterface {
override val variableMap by lazy {
hashMapOf<String, String>()
}
override fun putVariable(key: String, value: String?) {
if (value != null) {
if (value.length > 1000) {
AppLog.put("设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value
} else {
variableMap.remove(key)
}
}
}

@ -4,7 +4,13 @@ interface RuleDataInterface {
val variableMap: HashMap<String, String>
fun putVariable(key: String, value: String?)
fun putVariable(key: String, value: String?) {
if (value == null) {
variableMap.remove(key)
} else if (value.length < 1000) {
variableMap[key] = value
}
}
fun getVariable(key: String): String? {
return variableMap[key]

Loading…
Cancel
Save