pull/737/head
飞鸟队员 4 years ago
parent 1efa6fc162
commit 0a4fbff93e
  1. 5
      app/src/main/java/io/legado/app/constant/AppConst.kt
  2. 8
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  3. 2
      app/src/main/java/io/legado/app/model/webBook/BookInfo.kt
  4. 4
      app/src/main/java/io/legado/app/model/webBook/BookList.kt

@ -36,9 +36,8 @@ object AppConst {
val keyboardToolChars: List<String> by lazy { val keyboardToolChars: List<String> by lazy {
arrayListOf( arrayListOf(
"", "@", "&", "|", "%", "/", "\\", ":", "[", "]", "{", "}", "<", ">", "", "@css:", "<js></js>", "{{}}", "&&", "%%", "||", "//", "$.", "@", "class", "id", "href",
"$", "#", "!", ".", "+", "-", "*", "=", "href", "src", "textNodes", "xpath", "json", "textNodes", "ownText", "all", "html", "[", "]", "<", ">","#", "!", ".", "+", "-", "*", "="
"css", "id", "class", "tag"
) )
} }

@ -57,7 +57,7 @@ interface JsExtensions {
* 实现文件下载,返回路径 * 实现文件下载,返回路径
*/ */
fun downloadFile(content: String, url: String): String { fun downloadFile(content: String, url: String): String {
val type = AnalyzeUrl(url).type ?: return "type为空,未下载" val type = AnalyzeUrl(url).type ?: return ""
val zipPath = FileUtils.getPath( val zipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
"${MD5Utils.md5Encode16(url)}.${type}" "${MD5Utils.md5Encode16(url)}.${type}"
@ -76,6 +76,7 @@ interface JsExtensions {
* js实现压缩文件解压 * js实现压缩文件解压
*/ */
fun unzipFile(zipPath: String): String { fun unzipFile(zipPath: String): String {
if (zipPath.isEmpty()) return ""
val unzipPath = FileUtils.getPath( val unzipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
FileUtils.getNameExcludeExtension(zipPath) FileUtils.getNameExcludeExtension(zipPath)
@ -92,6 +93,7 @@ interface JsExtensions {
* js实现文件夹内所有文件读取 * js实现文件夹内所有文件读取
*/ */
fun getTxtInFolder(unzipPath: String): String { fun getTxtInFolder(unzipPath: String): String {
if (unzipPath.isEmpty()) return ""
val unzipFolder = FileUtils.createFolderIfNotExist(unzipPath) val unzipFolder = FileUtils.createFolderIfNotExist(unzipPath)
val contents = StringBuilder() val contents = StringBuilder()
unzipFolder.listFiles().let { unzipFolder.listFiles().let {
@ -109,7 +111,7 @@ interface JsExtensions {
} }
/** /**
* js实现重定向拦截,不能删 * js实现重定向拦截,网络访问get
*/ */
fun get(urlStr: String, headers: Map<String, String>): Connection.Response { fun get(urlStr: String, headers: Map<String, String>): Connection.Response {
return Jsoup.connect(urlStr) return Jsoup.connect(urlStr)
@ -279,7 +281,7 @@ interface JsExtensions {
val oldCode = s.toInt() val oldCode = s.toInt()
if (font1.InLimit(s)) { if (font1.InLimit(s)) {
val code = font2.GetCodeByGlyf(font1.GetGlyfByCode(oldCode)) val code = font2.GetCodeByGlyf(font1.GetGlyfByCode(oldCode))
if(code != 0) contentArray[index] = code.toChar() if (code != 0) contentArray[index] = code.toChar()
} }
} }
return contentArray.joinToString("") return contentArray.joinToString("")

@ -70,7 +70,7 @@ object BookInfo {
analyzeRule.getString(infoRule.intro).let { analyzeRule.getString(infoRule.intro).let {
if (it.isNotEmpty()) book.intro = it.htmlFormat() if (it.isNotEmpty()) book.intro = it.htmlFormat()
} }
Debug.log(bookSource.bookSourceUrl, "${book.intro}", isHtml = true) Debug.log(bookSource.bookSourceUrl, "${book.intro}")
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接") Debug.log(bookSource.bookSourceUrl, "┌获取封面链接")
analyzeRule.getString(infoRule.coverUrl).let { analyzeRule.getString(infoRule.coverUrl).let {

@ -163,7 +163,7 @@ object BookList {
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取简介") Debug.log(bookSource.bookSourceUrl, "┌获取简介")
searchBook.intro = analyzeRule.getString(intro).htmlFormat() searchBook.intro = analyzeRule.getString(intro).htmlFormat()
Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}", true) Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}")
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接") Debug.log(bookSource.bookSourceUrl, "┌获取封面链接")
searchBook.coverUrl = analyzeRule.getString(coverUrl, true) searchBook.coverUrl = analyzeRule.getString(coverUrl, true)
@ -223,7 +223,7 @@ object BookList {
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取简介", log) Debug.log(bookSource.bookSourceUrl, "┌获取简介", log)
searchBook.intro = analyzeRule.getString(ruleIntro).htmlFormat() searchBook.intro = analyzeRule.getString(ruleIntro).htmlFormat()
Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}", log, true) Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}", log)
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接", log) Debug.log(bookSource.bookSourceUrl, "┌获取封面链接", log)
analyzeRule.getString(ruleCoverUrl).let { analyzeRule.getString(ruleCoverUrl).let {

Loading…
Cancel
Save