Merge pull request #465 from gedoor/master

update
pull/481/head
Antecer 4 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,提升解析速度
* 自动分段优化 by [tumuyan](https://github.com/tumuyan)
* web支持图片显示
**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;
}</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([
{
"revision": "1f198e66ea99b77b82a1",
"revision": "414c7503fa98c3f2e328",
"url": "css/about.dbe575e1.css"
},
{
"revision": "e82f63018b8756547377",
"revision": "13925596cfa342cbb55d",
"url": "css/app.e4c919b7.css"
},
{
"revision": "3e91096748e0f4d6bb89",
"revision": "d53f06b957b78ddb78b7",
"url": "css/chunk-vendors.ad4ff18f.css"
},
{
"revision": "f2d5bf5a45e7429367f8",
"url": "css/detail.ef664f74.css"
"revision": "0607c99f49945c348397",
"url": "css/detail.b4324411.css"
},
{
"revision": "535877f50039c0cb49a6196a5b7517cd",
@ -40,28 +40,28 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "img/noCover.b5c48bc1.jpeg"
},
{
"revision": "48e76635babe1b6abdaface8af25dd98",
"revision": "8ff165c058a9618dc10065e65133a4e7",
"url": "index.html"
},
{
"revision": "1f198e66ea99b77b82a1",
"url": "js/about.b239b102.js"
"revision": "414c7503fa98c3f2e328",
"url": "js/about.d8b0dc91.js"
},
{
"revision": "2c81bd893f3a92f018d8",
"url": "js/about~detail.1caf6ef5.js"
},
{
"revision": "e82f63018b8756547377",
"url": "js/app.f319fc97.js"
"revision": "13925596cfa342cbb55d",
"url": "js/app.d60dad33.js"
},
{
"revision": "3e91096748e0f4d6bb89",
"url": "js/chunk-vendors.8dd9045a.js"
"revision": "d53f06b957b78ddb78b7",
"url": "js/chunk-vendors.060eee33.js"
},
{
"revision": "f2d5bf5a45e7429367f8",
"url": "js/detail.06210052.js"
"revision": "0607c99f49945c348397",
"url": "js/detail.6a5cc86c.js"
},
{
"revision": "b46d04eb43bc31ca0f9f95121646440d",

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

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

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

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

@ -101,19 +101,18 @@ class WebBook(val bookSource: BookSource) {
): Coroutine<Book> {
return Coroutine.async(scope, context) {
book.type = bookSource.bookSourceType
val body =
if (!book.infoHtml.isNullOrEmpty()) {
book.infoHtml
} else {
val analyzeUrl = AnalyzeUrl(
ruleUrl = book.bookUrl,
baseUrl = sourceUrl,
headerMapF = bookSource.getHeaderMap(),
book = book
)
analyzeUrl.getResponseAwait(bookSource.bookSourceUrl).body
}
BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl, canReName)
if (!book.infoHtml.isNullOrEmpty()) {
book.infoHtml
BookInfo.analyzeBookInfo(book, book.infoHtml, bookSource, book.bookUrl, canReName)
} else {
val res = AnalyzeUrl(
ruleUrl = book.bookUrl,
baseUrl = sourceUrl,
headerMapF = bookSource.getHeaderMap(),
book = book
).getResponseAwait(bookSource.bookSourceUrl)
BookInfo.analyzeBookInfo(book, res.body, bookSource, res.url, canReName)
}
book
}
}
@ -143,7 +142,12 @@ class WebBook(val bookSource: BookSource) {
baseUrl = book.bookUrl,
headerMapF = bookSource.getHeaderMap()
).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}")
return bookChapter.url
}
val body =
if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
book.tocHtml
} else {
val analyzeUrl = AnalyzeUrl(
ruleUrl = bookChapter.getAbsoluteURL(),
baseUrl = book.tocUrl,
headerMapF = bookSource.getHeaderMap(),
book = book,
chapter = bookChapter
)
analyzeUrl.getResponseAwait(
bookSource.bookSourceUrl,
jsStr = bookSource.getContentRule().webJs,
sourceRegex = bookSource.getContentRule().sourceRegex
).body
}
return BookContent.analyzeContent(
scope,
body,
book,
bookChapter,
bookSource,
bookChapter.url,
nextChapterUrl
)
return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
BookContent.analyzeContent(
scope,
book.tocHtml,
book,
bookChapter,
bookSource,
bookChapter.getAbsoluteURL(),
nextChapterUrl
)
} else {
val res = AnalyzeUrl(
ruleUrl = bookChapter.getAbsoluteURL(),
baseUrl = book.tocUrl,
headerMapF = bookSource.getHeaderMap(),
book = book,
chapter = bookChapter
).getResponseAwait(
bookSource.bookSourceUrl,
jsStr = bookSource.getContentRule().webJs,
sourceRegex = bookSource.getContentRule().sourceRegex
)
BookContent.analyzeContent(
scope,
res.body,
book,
bookChapter,
bookSource,
res.url,
nextChapterUrl
)
}
}
}

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

Loading…
Cancel
Save