修复一些url处理问题

pull/478/head
gedoor 4 years ago
parent 9df517ccef
commit cbda1e7f6c
  1. 8
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  2. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  3. 7
      app/src/main/java/io/legado/app/model/webBook/WebBook.kt

@ -5,6 +5,7 @@ import androidx.room.Entity
import androidx.room.ForeignKey import androidx.room.ForeignKey
import androidx.room.Ignore import androidx.room.Ignore
import androidx.room.Index import androidx.room.Index
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.MD5Utils import io.legado.app.utils.MD5Utils
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
@ -61,7 +62,12 @@ data class BookChapter(
} }
fun getAbsoluteURL(): String { fun getAbsoluteURL(): String {
return NetworkUtils.getAbsoluteURL(baseUrl, url)!! val urlArray = url.split(AnalyzeUrl.splitUrlRegex)
var absoluteUrl = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])!!
if (urlArray.size > 1) {
absoluteUrl += urlArray[1]
}
return absoluteUrl
} }
fun getFileName(): String = String.format("%05d-%s.nb", index, MD5Utils.md5Encode16(title)) fun getFileName(): String = String.format("%05d-%s.nb", index, MD5Utils.md5Encode16(title))

@ -45,7 +45,7 @@ class AnalyzeUrl(
headerMapF: Map<String, String>? = null headerMapF: Map<String, String>? = null
) : JsExtensions { ) : JsExtensions {
companion object { companion object {
private val splitUrlRegex = Regex(",\\s*(?=\\{)") val splitUrlRegex = Regex(",\\s*(?=\\{)")
private val pagePattern = Pattern.compile("<(.*?)>") private val pagePattern = Pattern.compile("<(.*?)>")
private val jsonType = MediaType.parse("application/json; charset=utf-8") private val jsonType = MediaType.parse("application/json; charset=utf-8")
} }

@ -144,9 +144,10 @@ class WebBook(val bookSource: BookSource) {
).getResponseAwait(bookSource.bookSourceUrl) ).getResponseAwait(bookSource.bookSourceUrl)
BookChapterList.analyzeChapterList( BookChapterList.analyzeChapterList(
this, this,
book, res.body, book,
res.body,
bookSource, bookSource,
res.url book.tocUrl
) )
} }
@ -211,7 +212,7 @@ class WebBook(val bookSource: BookSource) {
book, book,
bookChapter, bookChapter,
bookSource, bookSource,
res.url, bookChapter.getAbsoluteURL(),
nextChapterUrl nextChapterUrl
) )
} }

Loading…
Cancel
Save