pull/487/head^2
gedoor 4 years ago
parent 7df56e4151
commit e50d7a4847
  1. 10
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt
  2. 2
      app/src/main/java/io/legado/app/model/webBook/WebBook.kt

@ -10,8 +10,10 @@ import io.legado.app.help.BookHelp
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.model.analyzeRule.QueryTTF
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.htmlFormat import io.legado.app.utils.htmlFormat
import io.legado.app.utils.toStringArray
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -34,11 +36,13 @@ object BookContent {
val content = StringBuilder() val content = StringBuilder()
val nextUrlList = arrayListOf(baseUrl) val nextUrlList = arrayListOf(baseUrl)
val contentRule = bookSource.getContentRule() val contentRule = bookSource.getContentRule()
var queryTTF: QueryTTF? = null
contentRule.font?.let { contentRule.font?.let {
//todo 获取字体 //todo 获取字体
val analyzeRule = AnalyzeRule(book) val analyzeRule = AnalyzeRule(book)
analyzeRule.setContent(body).setBaseUrl(baseUrl) analyzeRule.setContent(body).setBaseUrl(baseUrl)
analyzeRule.getByteArray(it)?.let { font -> analyzeRule.getByteArray(it)?.let { font ->
queryTTF = QueryTTF(font)
BookHelp.saveFont(book, bookChapter, font) BookHelp.saveFont(book, bookChapter, font)
} }
} }
@ -110,6 +114,12 @@ object BookContent {
Debug.log(bookSource.bookSourceUrl, "${bookChapter.title}") Debug.log(bookSource.bookSourceUrl, "${bookChapter.title}")
Debug.log(bookSource.bookSourceUrl, "┌获取正文内容") Debug.log(bookSource.bookSourceUrl, "┌获取正文内容")
Debug.log(bookSource.bookSourceUrl, "\n$contentStr") Debug.log(bookSource.bookSourceUrl, "\n$contentStr")
queryTTF?.let {
contentStr.toStringArray().forEach { str ->
val fontData = it.getGlyf(str.toInt())
}
}
if (contentStr.isNotBlank()) { if (contentStr.isNotBlank()) {
BookHelp.saveContent(book, bookChapter, contentStr) BookHelp.saveContent(book, bookChapter, contentStr)
} }

@ -111,7 +111,7 @@ class WebBook(val bookSource: BookSource) {
headerMapF = bookSource.getHeaderMap(), headerMapF = bookSource.getHeaderMap(),
book = book book = book
).getResponseAwait(bookSource.bookSourceUrl) ).getResponseAwait(bookSource.bookSourceUrl)
BookInfo.analyzeBookInfo(book, res.body, bookSource, res.url, canReName) BookInfo.analyzeBookInfo(book, res.body, bookSource, book.bookUrl, canReName)
} }
book book
} }

Loading…
Cancel
Save