pull/1352/head
gedoor 3 years ago
parent da947511d4
commit 9e1ed46a22
  1. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  2. 13
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  3. 4
      app/src/main/java/io/legado/app/model/rss/Rss.kt
  4. 4
      app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
  5. 4
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt
  6. 12
      app/src/main/java/io/legado/app/model/webBook/WebBook.kt
  7. 4
      app/src/main/java/io/legado/app/service/AudioPlayService.kt

@ -654,7 +654,7 @@ class AnalyzeRule(
override fun ajax(urlStr: String): String? {
return runBlocking {
kotlin.runCatching {
val analyzeUrl = AnalyzeUrl(urlStr, book = book, source = source)
val analyzeUrl = AnalyzeUrl(urlStr, source = source, ruleData = book)
analyzeUrl.getStrResponse().body
}.onFailure {
log("ajax(${urlStr}) error\n${it.stackTraceToString()}")

@ -7,8 +7,8 @@ import com.bumptech.glide.load.model.LazyHeaders
import io.legado.app.constant.AppConst.SCRIPT_ENGINE
import io.legado.app.constant.AppConst.UA_NAME
import io.legado.app.constant.AppPattern.JS_PATTERN
import io.legado.app.data.entities.BaseBook
import io.legado.app.data.entities.BaseSource
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.help.AppConfig
import io.legado.app.help.CacheManager
@ -36,10 +36,9 @@ class AnalyzeUrl(
val speakText: String? = null,
val speakSpeed: Int? = null,
var baseUrl: String = "",
val book: BaseBook? = null,
val chapter: BookChapter? = null,
private val ruleData: RuleDataInterface? = null,
private val source: BaseSource? = null,
private val ruleData: RuleDataInterface? = null,
private val chapter: BookChapter? = null,
headerMapF: Map<String, String>? = null,
) : JsExtensions {
companion object {
@ -239,7 +238,7 @@ class AnalyzeUrl(
bindings["key"] = key
bindings["speakText"] = speakText
bindings["speakSpeed"] = speakSpeed
bindings["book"] = book
bindings["book"] = ruleData as? Book
bindings["source"] = source
bindings["result"] = result
return SCRIPT_ENGINE.eval(jsStr, bindings)
@ -247,14 +246,13 @@ class AnalyzeUrl(
fun put(key: String, value: String): String {
chapter?.putVariable(key, value)
?: book?.putVariable(key, value)
?: ruleData?.putVariable(key, value)
return value
}
fun get(key: String): String {
when (key) {
"bookName" -> book?.let {
"bookName" -> (ruleData as? Book)?.let {
return it.name
}
"title" -> chapter?.let {
@ -262,7 +260,6 @@ class AnalyzeUrl(
}
}
return chapter?.variableMap?.get(key)
?: book?.variableMap?.get(key)
?: ruleData?.variableMap?.get(key)
?: ""
}

@ -38,8 +38,8 @@ object Rss {
val analyzeUrl = AnalyzeUrl(
sortUrl,
page = page,
ruleData = ruleData,
source = rssSource,
ruleData = ruleData,
headerMapF = rssSource.getHeaderMap()
)
val body = analyzeUrl.getStrResponse().body
@ -66,8 +66,8 @@ object Rss {
val analyzeUrl = AnalyzeUrl(
rssArticle.link,
baseUrl = rssArticle.origin,
ruleData = rssArticle,
source = rssSource,
ruleData = rssArticle,
headerMapF = rssSource.getHeaderMap()
)
val body = analyzeUrl.getStrResponse().body

@ -64,8 +64,8 @@ object BookChapterList {
nextUrlList.add(nextUrl)
AnalyzeUrl(
ruleUrl = nextUrl,
book = book,
source = bookSource,
ruleData = book,
headerMapF = bookSource.getHeaderMap()
).getStrResponse().body?.let { nextBody ->
chapterData = analyzeChapterList(
@ -86,8 +86,8 @@ object BookChapterList {
val urlStr = chapterData.second[it]
val analyzeUrl = AnalyzeUrl(
ruleUrl = urlStr,
book = book,
source = bookSource,
ruleData = book,
headerMapF = bookSource.getHeaderMap()
)
val res = analyzeUrl.getStrResponse()

@ -69,8 +69,8 @@ object BookContent {
scope.ensureActive()
val res = AnalyzeUrl(
ruleUrl = nextUrl,
book = book,
source = bookSource,
ruleData = book,
headerMapF = bookSource.getHeaderMap()
).getStrResponse()
res.body?.let { nextBody ->
@ -92,8 +92,8 @@ object BookContent {
val urlStr = contentData.second[it]
val analyzeUrl = AnalyzeUrl(
ruleUrl = urlStr,
book = book,
source = bookSource,
ruleData = book,
headerMapF = bookSource.getHeaderMap()
)
val res = analyzeUrl.getStrResponse()

@ -71,8 +71,8 @@ object WebBook {
page = page,
baseUrl = bookSource.bookSourceUrl,
headerMapF = bookSource.getHeaderMap(true),
book = variableBook,
source = bookSource
source = bookSource,
ruleData = variableBook,
)
var res = analyzeUrl.getStrResponse()
//检测书源是否已登录
@ -120,8 +120,8 @@ object WebBook {
ruleUrl = url,
page = page,
baseUrl = bookSource.bookSourceUrl,
book = variableBook,
source = bookSource,
ruleData = variableBook,
headerMapF = bookSource.getHeaderMap(true)
)
var res = analyzeUrl.getStrResponse()
@ -178,8 +178,8 @@ object WebBook {
val analyzeUrl = AnalyzeUrl(
ruleUrl = book.bookUrl,
baseUrl = bookSource.bookSourceUrl,
book = book,
source = bookSource,
ruleData = book,
headerMapF = bookSource.getHeaderMap(true)
)
var res = analyzeUrl.getStrResponse()
@ -235,8 +235,8 @@ object WebBook {
val analyzeUrl = AnalyzeUrl(
ruleUrl = book.tocUrl,
baseUrl = book.bookUrl,
book = book,
source = bookSource,
ruleData = book,
headerMapF = bookSource.getHeaderMap(true)
)
var res = analyzeUrl.getStrResponse()
@ -299,8 +299,8 @@ object WebBook {
val analyzeUrl = AnalyzeUrl(
ruleUrl = bookChapter.getAbsoluteURL(),
baseUrl = book.tocUrl,
book = book,
source = bookSource,
ruleData = book,
chapter = bookChapter,
headerMapF = bookSource.getHeaderMap(true)
)

@ -130,8 +130,10 @@ class AudioPlayService : BaseService(),
upPlayProgressJob?.cancel()
val analyzeUrl = AnalyzeUrl(
url,
source = AudioPlay.bookSource,
ruleData = AudioPlay.book,
chapter = AudioPlay.durChapter,
headerMapF = AudioPlay.headers(true),
source = AudioPlay.bookSource
)
val uri = Uri.parse(analyzeUrl.url)
val mediaSource = ExoPlayerHelper

Loading…
Cancel
Save