Merge pull request #465 from gedoor/master

update
pull/481/head
Antecer 5 years ago committed by GitHub
commit c23917e360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/src/main/assets/updateLog.md
  2. 2
      app/src/main/assets/web/new/css/detail.b4324411.css
  3. 4
      app/src/main/assets/web/new/index.html
  4. 2
      app/src/main/assets/web/new/js/about.d8b0dc91.js
  5. 1
      app/src/main/assets/web/new/js/app.d60dad33.js
  6. 1
      app/src/main/assets/web/new/js/app.f319fc97.js
  7. 8
      app/src/main/assets/web/new/js/chunk-vendors.060eee33.js
  8. 1
      app/src/main/assets/web/new/js/detail.06210052.js
  9. 1
      app/src/main/assets/web/new/js/detail.6a5cc86c.js
  10. 28
      app/src/main/assets/web/new/precache-manifest.00f143f3962d167b482bfdc0fc9c4e77.js
  11. 2
      app/src/main/assets/web/new/service-worker.js
  12. 13
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  13. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  14. 2
      app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
  15. 90
      app/src/main/java/io/legado/app/model/webBook/WebBook.kt
  16. 2
      app/src/main/java/io/legado/app/utils/StringUtils.kt

@ -10,6 +10,7 @@
* 替换编辑界面添加正则学习教程 * 替换编辑界面添加正则学习教程
* 去除解析目录时拼接相对url,提升解析速度 * 去除解析目录时拼接相对url,提升解析速度
* 自动分段优化 by [tumuyan](https://github.com/tumuyan) * 自动分段优化 by [tumuyan](https://github.com/tumuyan)
* web支持图片显示
**2020/11/01** **2020/11/01**
* 导入本地添加智能扫描,菜单-智能扫描,扫描当前文件夹包括子文件夹下所有文件 * 导入本地添加智能扫描,菜单-智能扫描,扫描当前文件夹包括子文件夹下所有文件

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang=en style="padding: 0;height:100%"><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="favicon.ico" /><![endif]--><title>Legado Bookshelf</title><link href=css/about.dbe575e1.css rel=prefetch><link href=css/detail.ef664f74.css rel=prefetch><link href=js/about.b239b102.js rel=prefetch><link href=js/about~detail.1caf6ef5.js rel=prefetch><link href=js/detail.06210052.js rel=prefetch><link href=css/app.e4c919b7.css rel=preload as=style><link href=css/chunk-vendors.ad4ff18f.css rel=preload as=style><link href=js/app.f319fc97.js rel=preload as=script><link href=js/chunk-vendors.8dd9045a.js rel=preload as=script><link href=css/chunk-vendors.ad4ff18f.css rel=stylesheet><link href=css/app.e4c919b7.css rel=stylesheet><link rel=icon type=image/png sizes=32x32 href=img/icons/favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=img/icons/favicon-16x16.png><link rel=manifest href=manifest.json><meta name=theme-color content=#4DBA87><meta name=apple-mobile-web-app-capable content=no><meta name=apple-mobile-web-app-status-bar-style content=default><meta name=apple-mobile-web-app-title content=yd-web-tool><link rel=apple-touch-icon href=img/icons/apple-touch-icon-152x152.png><link rel=mask-icon href=img/icons/safari-pinned-tab.svg color=#4DBA87><meta name=msapplication-TileImage content=img/icons/msapplication-icon-144x144.png><meta name=msapplication-TileColor content=#000000></head><style>body::-webkit-scrollbar { <!DOCTYPE html><html lang="en" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="favicon.ico" /><![endif]--><title>Legado Bookshelf</title><link href="css/about.dbe575e1.css" rel="prefetch"><link href="css/detail.b4324411.css" rel="prefetch"><link href="js/about.d8b0dc91.js" rel="prefetch"><link href="js/about~detail.1caf6ef5.js" rel="prefetch"><link href="js/detail.6a5cc86c.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.ad4ff18f.css" rel="preload" as="style"><link href="js/app.d60dad33.js" rel="preload" as="script"><link href="js/chunk-vendors.060eee33.js" rel="preload" as="script"><link href="css/chunk-vendors.ad4ff18f.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="img/icons/favicon-16x16.png"><link rel="manifest" href="manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="yd-web-tool"><link rel="apple-touch-icon" href="img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><style>body::-webkit-scrollbar {
display: none; display: none;
}</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.8dd9045a.js></script><script src=js/app.f319fc97.js></script></body></html> }</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.060eee33.js"></script><script src="js/app.d60dad33.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,19 +1,19 @@
self.__precacheManifest = (self.__precacheManifest || []).concat([ self.__precacheManifest = (self.__precacheManifest || []).concat([
{ {
"revision": "1f198e66ea99b77b82a1", "revision": "414c7503fa98c3f2e328",
"url": "css/about.dbe575e1.css" "url": "css/about.dbe575e1.css"
}, },
{ {
"revision": "e82f63018b8756547377", "revision": "13925596cfa342cbb55d",
"url": "css/app.e4c919b7.css" "url": "css/app.e4c919b7.css"
}, },
{ {
"revision": "3e91096748e0f4d6bb89", "revision": "d53f06b957b78ddb78b7",
"url": "css/chunk-vendors.ad4ff18f.css" "url": "css/chunk-vendors.ad4ff18f.css"
}, },
{ {
"revision": "f2d5bf5a45e7429367f8", "revision": "0607c99f49945c348397",
"url": "css/detail.ef664f74.css" "url": "css/detail.b4324411.css"
}, },
{ {
"revision": "535877f50039c0cb49a6196a5b7517cd", "revision": "535877f50039c0cb49a6196a5b7517cd",
@ -40,28 +40,28 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "img/noCover.b5c48bc1.jpeg" "url": "img/noCover.b5c48bc1.jpeg"
}, },
{ {
"revision": "48e76635babe1b6abdaface8af25dd98", "revision": "8ff165c058a9618dc10065e65133a4e7",
"url": "index.html" "url": "index.html"
}, },
{ {
"revision": "1f198e66ea99b77b82a1", "revision": "414c7503fa98c3f2e328",
"url": "js/about.b239b102.js" "url": "js/about.d8b0dc91.js"
}, },
{ {
"revision": "2c81bd893f3a92f018d8", "revision": "2c81bd893f3a92f018d8",
"url": "js/about~detail.1caf6ef5.js" "url": "js/about~detail.1caf6ef5.js"
}, },
{ {
"revision": "e82f63018b8756547377", "revision": "13925596cfa342cbb55d",
"url": "js/app.f319fc97.js" "url": "js/app.d60dad33.js"
}, },
{ {
"revision": "3e91096748e0f4d6bb89", "revision": "d53f06b957b78ddb78b7",
"url": "js/chunk-vendors.8dd9045a.js" "url": "js/chunk-vendors.060eee33.js"
}, },
{ {
"revision": "f2d5bf5a45e7429367f8", "revision": "0607c99f49945c348397",
"url": "js/detail.06210052.js" "url": "js/detail.6a5cc86c.js"
}, },
{ {
"revision": "b46d04eb43bc31ca0f9f95121646440d", "revision": "b46d04eb43bc31ca0f9f95121646440d",

@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"); importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
importScripts( importScripts(
"precache-manifest.64ecbb9cbd290bcd22476b715a2e6c05.js" "precache-manifest.00f143f3962d167b482bfdc0fc9c4e77.js"
); );
workbox.core.setCacheNameDetails({prefix: "yd-web-tool"}); workbox.core.setCacheNameDetails({prefix: "yd-web-tool"});

@ -46,9 +46,10 @@ interface JsExtensions {
* js实现文件下载 * js实现文件下载
*/ */
fun downloadFile(content: String, url: String): String { fun downloadFile(content: String, url: String): String {
val type = AnalyzeUrl(url).type ?: return "type为空,未下载"
val zipPath = FileUtils.getPath( val zipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
"${MD5Utils.md5Encode16(url)}.zip" "${MD5Utils.md5Encode16(url)}.${type}"
) )
FileUtils.deleteFile(zipPath) FileUtils.deleteFile(zipPath)
val zipFile = FileUtils.createFileIfNotExist(zipPath) val zipFile = FileUtils.createFileIfNotExist(zipPath)
@ -137,14 +138,18 @@ interface JsExtensions {
* js实现解码,不能删 * js实现解码,不能删
*/ */
fun base64Decode(str: String): String { fun base64Decode(str: String): String {
return EncoderUtils.base64Decode(str) return EncoderUtils.base64Decode(str, Base64.NO_WRAP)
}
fun base64Decode(str: String, flags: Int): String {
return EncoderUtils.base64Decode(str, flags)
} }
fun base64Encode(str: String): String? { fun base64Encode(str: String): String? {
return EncoderUtils.base64Encode(str) return EncoderUtils.base64Encode(str, Base64.NO_WRAP)
} }
fun base64Encode(str: String, flags: Int = Base64.NO_WRAP): String? { fun base64Encode(str: String, flags: Int): String? {
return EncoderUtils.base64Encode(str, flags) return EncoderUtils.base64Encode(str, flags)
} }

@ -52,6 +52,7 @@ class AnalyzeUrl(
var url: String = "" var url: String = ""
val headerMap = HashMap<String, String>() val headerMap = HashMap<String, String>()
var body: String? = null var body: String? = null
var type: String? = null
private lateinit var urlHasQuery: String private lateinit var urlHasQuery: String
private var queryStr: String? = null private var queryStr: String? = null
private val fieldMap = LinkedHashMap<String, String>() private val fieldMap = LinkedHashMap<String, String>()
@ -60,7 +61,6 @@ class AnalyzeUrl(
private var method = RequestMethod.GET private var method = RequestMethod.GET
private val splitUrlRegex = Regex(",\\s*(?=\\{)") private val splitUrlRegex = Regex(",\\s*(?=\\{)")
private var proxy: String? = null private var proxy: String? = null
private var type: String? = null
init { init {
baseUrl = baseUrl.split(splitUrlRegex, 1)[0] baseUrl = baseUrl.split(splitUrlRegex, 1)[0]

@ -233,7 +233,6 @@ object BookChapterList {
val elements = analyzeRule.getElements(listRule) val elements = analyzeRule.getElements(listRule)
Debug.log(bookSource.bookSourceUrl, "└列表大小:${elements.size}", log) Debug.log(bookSource.bookSourceUrl, "└列表大小:${elements.size}", log)
if (elements.isNotEmpty()) { if (elements.isNotEmpty()) {
Debug.log(bookSource.bookSourceUrl, "┌获取首章名称", log)
val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName) val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName)
val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl) val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl)
val vipRule = analyzeRule.splitSourceRule(tocRule.isVip) val vipRule = analyzeRule.splitSourceRule(tocRule.isVip)
@ -257,6 +256,7 @@ object BookChapterList {
chapterList.add(bookChapter) chapterList.add(bookChapter)
} }
} }
Debug.log(bookSource.bookSourceUrl, "┌获取首章名称", log)
Debug.log(bookSource.bookSourceUrl, "${chapterList[0].title}", log) Debug.log(bookSource.bookSourceUrl, "${chapterList[0].title}", log)
Debug.log(bookSource.bookSourceUrl, "┌获取首章链接", log) Debug.log(bookSource.bookSourceUrl, "┌获取首章链接", log)
Debug.log(bookSource.bookSourceUrl, "${chapterList[0].url}", log) Debug.log(bookSource.bookSourceUrl, "${chapterList[0].url}", log)

@ -101,19 +101,18 @@ class WebBook(val bookSource: BookSource) {
): Coroutine<Book> { ): Coroutine<Book> {
return Coroutine.async(scope, context) { return Coroutine.async(scope, context) {
book.type = bookSource.bookSourceType book.type = bookSource.bookSourceType
val body = if (!book.infoHtml.isNullOrEmpty()) {
if (!book.infoHtml.isNullOrEmpty()) { book.infoHtml
book.infoHtml BookInfo.analyzeBookInfo(book, book.infoHtml, bookSource, book.bookUrl, canReName)
} else { } else {
val analyzeUrl = AnalyzeUrl( val res = AnalyzeUrl(
ruleUrl = book.bookUrl, ruleUrl = book.bookUrl,
baseUrl = sourceUrl, baseUrl = sourceUrl,
headerMapF = bookSource.getHeaderMap(), headerMapF = bookSource.getHeaderMap(),
book = book book = book
) ).getResponseAwait(bookSource.bookSourceUrl)
analyzeUrl.getResponseAwait(bookSource.bookSourceUrl).body BookInfo.analyzeBookInfo(book, res.body, bookSource, res.url, canReName)
} }
BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl, canReName)
book book
} }
} }
@ -143,7 +142,12 @@ class WebBook(val bookSource: BookSource) {
baseUrl = book.bookUrl, baseUrl = book.bookUrl,
headerMapF = bookSource.getHeaderMap() headerMapF = bookSource.getHeaderMap()
).getResponseAwait(bookSource.bookSourceUrl) ).getResponseAwait(bookSource.bookSourceUrl)
BookChapterList.analyzeChapterList(this, book, res.body, bookSource, res.url) BookChapterList.analyzeChapterList(
this,
book, res.body,
bookSource,
res.url
)
} }
} }
@ -179,31 +183,37 @@ class WebBook(val bookSource: BookSource) {
Debug.log(sourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}") Debug.log(sourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}")
return bookChapter.url return bookChapter.url
} }
val body = return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { BookContent.analyzeContent(
book.tocHtml scope,
} else { book.tocHtml,
val analyzeUrl = AnalyzeUrl( book,
ruleUrl = bookChapter.getAbsoluteURL(), bookChapter,
baseUrl = book.tocUrl, bookSource,
headerMapF = bookSource.getHeaderMap(), bookChapter.getAbsoluteURL(),
book = book, nextChapterUrl
chapter = bookChapter )
) } else {
analyzeUrl.getResponseAwait( val res = AnalyzeUrl(
bookSource.bookSourceUrl, ruleUrl = bookChapter.getAbsoluteURL(),
jsStr = bookSource.getContentRule().webJs, baseUrl = book.tocUrl,
sourceRegex = bookSource.getContentRule().sourceRegex headerMapF = bookSource.getHeaderMap(),
).body book = book,
} chapter = bookChapter
return BookContent.analyzeContent( ).getResponseAwait(
scope, bookSource.bookSourceUrl,
body, jsStr = bookSource.getContentRule().webJs,
book, sourceRegex = bookSource.getContentRule().sourceRegex
bookChapter, )
bookSource, BookContent.analyzeContent(
bookChapter.url, scope,
nextChapterUrl res.body,
) book,
bookChapter,
bookSource,
res.url,
nextChapterUrl
)
}
} }
} }

@ -305,7 +305,7 @@ object StringUtils {
} }
return sb.toString() return sb.toString()
} }
fun hexStringToByte(hexString: String): ByteArray? { fun hexStringToByte(hexString: String): ByteArray? {
val hexStr = hexString.replace(" ", "") val hexStr = hexString.replace(" ", "")
val len = hexStr.length val len = hexStr.length

Loading…
Cancel
Save