第三方书源兼容

pull/21/head
fengyuecanzhu 3 years ago
parent 618afc3249
commit acaed246cc
  1. 3
      .idea/gradle.xml
  2. 12
      app/build.gradle
  3. 1
      app/src/main/java/xyz/fycz/myreader/common/APPCONST.java
  4. 1
      app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java
  5. 1
      app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java
  6. 5
      app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/JsExtensions.java
  7. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/Exceptions.kt
  8. 12
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSonPath.kt
  9. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSoup.kt
  10. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByRegex.kt
  11. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByXPath.kt
  12. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeRule.kt
  13. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt
  14. 67
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt
  15. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/QueryTTF.java
  16. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleAnalyzer.kt
  17. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleData.kt
  18. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleDataInterface.kt
  19. 16
      app/src/main/java/xyz/fycz/myreader/model/third3/http/BackstageWebView.kt
  20. 12
      app/src/main/java/xyz/fycz/myreader/model/third3/http/SSLHelper.kt
  21. 8
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookChapterList.kt
  22. 6
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookContent.kt
  23. 4
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookInfo.kt
  24. 6
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookList.kt
  25. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/SearchModel.kt
  26. 4
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/WebBook.kt

@ -4,7 +4,7 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="testRunner" value="PLATFORM" /> <option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules"> <option name="modules">
@ -15,7 +15,6 @@
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" /> <option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>

@ -124,6 +124,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
kotlinOptions {
jvmTarget = "1.8"
}
productFlavors { productFlavors {
} }
packagingOptions { packagingOptions {
@ -242,6 +246,14 @@ dependencies {
// https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j // https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.9.1' implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.9.1'
//
def coroutines_version = '1.5.1'
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
//apache
implementation('org.apache.commons:commons-text:1.9')
} }
greendao { greendao {

@ -132,4 +132,5 @@ public class APPCONST {
public static final String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4168.3 Safari/537.36"; public static final String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4168.3 Safari/537.36";
public static final String UA_NAME = "User-Agent";
} }

@ -20,7 +20,6 @@ import javax.script.SimpleBindings;
import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.greendao.service.CookieStore; import xyz.fycz.myreader.greendao.service.CookieStore;
import xyz.fycz.myreader.util.help.StringHelper; import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.help.JsExtensions;
import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.StringUtils; import xyz.fycz.myreader.util.utils.StringUtils;

@ -20,7 +20,6 @@ import java.util.regex.Pattern;
import javax.script.SimpleBindings; import javax.script.SimpleBindings;
import xyz.fycz.myreader.util.help.StringHelper; import xyz.fycz.myreader.util.help.StringHelper;
import xyz.fycz.myreader.util.help.JsExtensions;
import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.NetworkUtils;
import xyz.fycz.myreader.util.utils.StringUtils; import xyz.fycz.myreader.util.utils.StringUtils;
import xyz.fycz.myreader.util.utils.UrlEncoderUtils; import xyz.fycz.myreader.util.utils.UrlEncoderUtils;

@ -1,4 +1,4 @@
package xyz.fycz.myreader.util.help; package xyz.fycz.myreader.model.third2.analyzeRule;
import android.text.TextUtils; import android.text.TextUtils;
@ -23,10 +23,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import xyz.fycz.myreader.greendao.service.CookieStore; import xyz.fycz.myreader.greendao.service.CookieStore;
import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl;
import xyz.fycz.myreader.util.ZipUtils; import xyz.fycz.myreader.util.ZipUtils;
import xyz.fycz.myreader.util.help.SSLSocketClient;
import xyz.fycz.myreader.util.utils.EncoderUtils; import xyz.fycz.myreader.util.utils.EncoderUtils;
import xyz.fycz.myreader.util.utils.EncodingDetect;
import xyz.fycz.myreader.util.utils.FileUtils; import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.MD5Utils; import xyz.fycz.myreader.util.utils.MD5Utils;
import xyz.fycz.myreader.util.utils.OkHttpUtils; import xyz.fycz.myreader.util.utils.OkHttpUtils;

@ -1,6 +1,6 @@
@file:Suppress("unused") @file:Suppress("unused")
package io.legado.app.model package xyz.fycz.myreader.model.third3
class AppException(msg: String) : Exception(msg) class AppException(msg: String) : Exception(msg)

@ -1,16 +1,18 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
import android.util.Log
import androidx.annotation.Keep import androidx.annotation.Keep
import com.jayway.jsonpath.JsonPath import com.jayway.jsonpath.JsonPath
import com.jayway.jsonpath.ReadContext import com.jayway.jsonpath.ReadContext
import timber.log.Timber
import java.util.* import java.util.*
@Suppress("RegExpRedundantEscape") @Suppress("RegExpRedundantEscape")
@Keep @Keep
class AnalyzeByJSonPath(json: Any) { class AnalyzeByJSonPath(json: Any) {
private val TAG = AnalyzeByJSonPath::class.simpleName
companion object { companion object {
fun parse(json: Any): ReadContext { fun parse(json: Any): ReadContext {
@ -50,7 +52,7 @@ class AnalyzeByJSonPath(json: Any) {
ob.toString() ob.toString()
} }
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, e.toString())
} }
} }
return result return result
@ -87,7 +89,7 @@ class AnalyzeByJSonPath(json: Any) {
result.add(obj.toString()) result.add(obj.toString())
} }
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, e.toString())
} }
} else { } else {
result.add(st) result.add(st)
@ -137,7 +139,7 @@ class AnalyzeByJSonPath(json: Any) {
try { try {
return it.read<ArrayList<Any>>(rules[0]) return it.read<ArrayList<Any>>(rules[0])
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, e.toString())
} }
} }
} else { } else {

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
import androidx.annotation.Keep import androidx.annotation.Keep
import org.jsoup.Jsoup import org.jsoup.Jsoup

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
import androidx.annotation.Keep import androidx.annotation.Keep
import java.util.* import java.util.*

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
import android.text.TextUtils import android.text.TextUtils
import androidx.annotation.Keep import androidx.annotation.Keep

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
import android.text.TextUtils import android.text.TextUtils
import androidx.annotation.Keep import androidx.annotation.Keep

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
import android.annotation.SuppressLint import android.annotation.SuppressLint
import androidx.annotation.Keep import androidx.annotation.Keep

@ -1,24 +1,20 @@
package io.legado.app.help package xyz.fycz.myreader.model.third3.analyzeRule
import android.net.Uri import android.net.Uri
import android.util.Base64 import android.util.Base64
import android.util.Log
import androidx.annotation.Keep import androidx.annotation.Keep
import io.legado.app.BuildConfig
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppConst.dateFormat
import io.legado.app.data.entities.BaseSource
import io.legado.app.help.http.* import io.legado.app.help.http.*
import io.legado.app.model.Debug
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.model.analyzeRule.QueryTTF
import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import nl.siegmann.epublib.epub.PackageDocumentBase.dateFormat
import org.jsoup.Connection import org.jsoup.Connection
import org.jsoup.Jsoup import org.jsoup.Jsoup
import splitties.init.appCtx import xyz.fycz.myreader.greendao.entity.rule.BookSource
import timber.log.Timber import xyz.fycz.myreader.greendao.service.CookieStore
import xyz.fycz.myreader.util.ZipUtils
import xyz.fycz.myreader.util.utils.*
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
@ -38,7 +34,10 @@ import java.util.zip.ZipInputStream
@Suppress("unused") @Suppress("unused")
interface JsExtensions { interface JsExtensions {
fun getSource(): BaseSource? private val TAG: String?
get() = JsExtensions::class.simpleName
fun getSource(): BookSource?
/** /**
* 访问网络,返回String * 访问网络,返回String
@ -50,9 +49,9 @@ interface JsExtensions {
analyzeUrl.getStrResponseAwait().body analyzeUrl.getStrResponseAwait().body
}.onFailure { }.onFailure {
log("ajax(${urlStr}) error\n${it.stackTraceToString()}") log("ajax(${urlStr}) error\n${it.stackTraceToString()}")
Timber.e(it) Log.e(TAG, it.toString())
}.getOrElse { }.getOrElse {
it.msg it.message
} }
} }
} }
@ -86,7 +85,7 @@ interface JsExtensions {
analyzeUrl.getStrResponseAwait() analyzeUrl.getStrResponseAwait()
}.onFailure { }.onFailure {
log("connect(${urlStr}) error\n${it.stackTraceToString()}") log("connect(${urlStr}) error\n${it.stackTraceToString()}")
Timber.e(it) Log.e(TAG, it.toString())
}.getOrElse { }.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage) StrResponse(analyzeUrl.url, it.localizedMessage)
} }
@ -101,7 +100,7 @@ interface JsExtensions {
analyzeUrl.getStrResponseAwait() analyzeUrl.getStrResponseAwait()
}.onFailure { }.onFailure {
log("ajax($urlStr,$header) error\n${it.stackTraceToString()}") log("ajax($urlStr,$header) error\n${it.stackTraceToString()}")
Timber.e(it) Log.e(TAG, it.toString())
}.getOrElse { }.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage) StrResponse(analyzeUrl.url, it.localizedMessage)
} }
@ -134,11 +133,11 @@ interface JsExtensions {
fun downloadFile(content: String, url: String): String { fun downloadFile(content: String, url: String): String {
val type = AnalyzeUrl(url, source = getSource()).type ?: return "" val type = AnalyzeUrl(url, source = getSource()).type ?: return ""
val zipPath = FileUtils.getPath( val zipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), FileUtils.getFile(FileUtils.getCachePath()),
"${MD5Utils.md5Encode16(url)}.${type}" "${MD5Utils.md5Encode16(url)}.${type}"
) )
FileUtils.deleteFile(zipPath) FileUtils.deleteFile(zipPath)
val zipFile = FileUtils.createFileIfNotExist(zipPath) val zipFile = FileUtils.getFile(zipPath)
StringUtils.hexStringToByte(content).let { StringUtils.hexStringToByte(content).let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
zipFile.writeBytes(it) zipFile.writeBytes(it)
@ -303,7 +302,7 @@ interface JsExtensions {
fun readTxtFile(path: String): String { fun readTxtFile(path: String): String {
val file = getFile(path) val file = getFile(path)
if (file.exists()) { if (file.exists()) {
val charsetName = EncodingDetect.getEncode(file) val charsetName = EncodingDetect.getJavaEncode(file)
return String(file.readBytes(), charset(charsetName)) return String(file.readBytes(), charset(charsetName))
} }
return "" return ""
@ -321,8 +320,7 @@ interface JsExtensions {
* 删除本地文件 * 删除本地文件
*/ */
fun deleteFile(path: String) { fun deleteFile(path: String) {
val file = getFile(path) FileUtils.deleteFile(path)
FileUtils.delete(file, true)
} }
/** /**
@ -332,16 +330,13 @@ interface JsExtensions {
*/ */
fun unzipFile(zipPath: String): String { fun unzipFile(zipPath: String): String {
if (zipPath.isEmpty()) return "" if (zipPath.isEmpty()) return ""
val unzipPath = FileUtils.getPath( val unzipPath = FileUtils.getCachePath() + File.separator + FileUtils.getNameExcludeExtension(zipPath)
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
FileUtils.getNameExcludeExtension(zipPath)
)
FileUtils.deleteFile(unzipPath) FileUtils.deleteFile(unzipPath)
val zipFile = getFile(zipPath) val zipFile = FileUtils.getFile(zipPath)
val unzipFolder = FileUtils.createFolderIfNotExist(unzipPath) val unzipFolder = FileUtils.getFolder(unzipPath)
ZipUtils.unzipFile(zipFile, unzipFolder) ZipUtils.unzipFile(zipFile, unzipFolder)
FileUtils.deleteFile(zipFile.absolutePath) FileUtils.deleteFile(zipPath)
return unzipPath.substring(FileUtils.getCachePath().length) return unzipPath
} }
/** /**
@ -354,7 +349,7 @@ interface JsExtensions {
unzipFolder.listFiles().let { unzipFolder.listFiles().let {
if (it != null) { if (it != null) {
for (f in it) { for (f in it) {
val charsetName = EncodingDetect.getEncode(f) val charsetName = EncodingDetect.getJavaEncode(f)
contents.append(String(f.readBytes(), charset(charsetName))) contents.append(String(f.readBytes(), charset(charsetName)))
.append("\n") .append("\n")
} }
@ -373,7 +368,7 @@ interface JsExtensions {
*/ */
fun getZipStringContent(url: String, path: String): String { fun getZipStringContent(url: String, path: String): String {
val byteArray = getZipByteArrayContent(url, path) ?: return "" val byteArray = getZipByteArrayContent(url, path) ?: return ""
val charsetName = EncodingDetect.getEncode(byteArray) val charsetName = EncodingDetect.getJavaEncode(byteArray)
return String(byteArray, Charset.forName(charsetName)) return String(byteArray, Charset.forName(charsetName))
} }
@ -485,7 +480,7 @@ interface JsExtensions {
Debug.log(it.getKey(), msg) Debug.log(it.getKey(), msg)
} ?: Debug.log(msg) } ?: Debug.log(msg)
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Timber.d(msg) Log.e(TAG, msg)
} }
return msg return msg
} }
@ -515,7 +510,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, e.toString())
log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") log(e.localizedMessage ?: "aesDecodeToByteArrayERROR")
null null
} }
@ -554,7 +549,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, r.toString())
log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") log(e.localizedMessage ?: "aesDecodeToByteArrayERROR")
null null
} }
@ -592,7 +587,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, e.toString())
log(e.localizedMessage ?: "aesEncodeToByteArrayERROR") log(e.localizedMessage ?: "aesEncodeToByteArrayERROR")
null null
} }
@ -629,7 +624,7 @@ interface JsExtensions {
iv.encodeToByteArray() iv.encodeToByteArray()
) )
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, e.toString())
log(e.localizedMessage ?: "aesEncodeToBase64ByteArrayERROR") log(e.localizedMessage ?: "aesEncodeToBase64ByteArrayERROR")
null null
} }

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule; package xyz.fycz.myreader.model.third3.analyzeRule;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple; import org.apache.commons.lang3.tuple.Triple;

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
//通用的规则切分处理 //通用的规则切分处理
class RuleAnalyzer(data: String, code: Boolean = false) { class RuleAnalyzer(data: String, code: Boolean = false) {

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
class RuleData : RuleDataInterface { class RuleData : RuleDataInterface {

@ -1,4 +1,4 @@
package io.legado.app.model.analyzeRule package xyz.fycz.myreader.model.third3.analyzeRule
interface RuleDataInterface { interface RuleDataInterface {

@ -8,12 +8,12 @@ import android.webkit.CookieManager
import android.webkit.WebSettings import android.webkit.WebSettings
import android.webkit.WebView import android.webkit.WebView
import android.webkit.WebViewClient import android.webkit.WebViewClient
import io.legado.app.constant.AppConst
import io.legado.app.model.NoStackTraceException
import io.legado.app.utils.runOnUI
import kotlinx.coroutines.* import kotlinx.coroutines.*
import org.apache.commons.text.StringEscapeUtils import org.apache.commons.text.StringEscapeUtils
import splitties.init.appCtx import xyz.fycz.myreader.application.App
import xyz.fycz.myreader.common.APPCONST
import xyz.fycz.myreader.greendao.service.CookieStore
import xyz.fycz.myreader.model.third3.NoStackTraceException
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import kotlin.coroutines.resume import kotlin.coroutines.resume
@ -36,7 +36,7 @@ class BackstageWebView(
suspend fun getStrResponse(): StrResponse = suspendCancellableCoroutine { block -> suspend fun getStrResponse(): StrResponse = suspendCancellableCoroutine { block ->
block.invokeOnCancellation { block.invokeOnCancellation {
runOnUI { App.getHandler().post {
destroy() destroy()
} }
} }
@ -51,7 +51,7 @@ class BackstageWebView(
block.cancel(error) block.cancel(error)
} }
} }
runOnUI { App.getHandler().post {
try { try {
load() load()
} catch (error: Throwable) { } catch (error: Throwable) {
@ -88,12 +88,12 @@ class BackstageWebView(
@SuppressLint("SetJavaScriptEnabled", "JavascriptInterface") @SuppressLint("SetJavaScriptEnabled", "JavascriptInterface")
private fun createWebView(): WebView { private fun createWebView(): WebView {
val webView = WebView(appCtx) val webView = WebView(App.getmContext())
val settings = webView.settings val settings = webView.settings
settings.javaScriptEnabled = true settings.javaScriptEnabled = true
settings.domStorageEnabled = true settings.domStorageEnabled = true
settings.blockNetworkImage = true settings.blockNetworkImage = true
settings.userAgentString = headerMap?.get(AppConst.UA_NAME) settings.userAgentString = headerMap?.get(APPCONST.UA_NAME)
settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
if (sourceRegex.isNullOrEmpty()) { if (sourceRegex.isNullOrEmpty()) {
webView.webViewClient = HtmlWebViewClient() webView.webViewClient = HtmlWebViewClient()

@ -1,8 +1,8 @@
package io.legado.app.help.http package io.legado.app.help.http
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.util.Log
import timber.log.Timber
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.security.KeyManagementException import java.security.KeyManagementException
@ -16,7 +16,7 @@ import javax.net.ssl.*
@Suppress("unused") @Suppress("unused")
object SSLHelper { object SSLHelper {
private val TAG = SSLHelper::class.simpleName
/** /**
* 为了解决客户端不信任服务器数字证书的问题 * 为了解决客户端不信任服务器数字证书的问题
* 网络上大部分的解决方案都是让客户端不对证书做任何检查 * 网络上大部分的解决方案都是让客户端不对证书做任何检查
@ -127,9 +127,9 @@ object SSLHelper {
sslParams.trustManager = manager sslParams.trustManager = manager
return sslParams return sslParams
} catch (e: NoSuchAlgorithmException) { } catch (e: NoSuchAlgorithmException) {
Timber.e(e) Log.e(TAG, e.toString())
} catch (e: KeyManagementException) { } catch (e: KeyManagementException) {
Timber.e(e) Log.e(TAG, e.toString())
} }
return null return null
} }
@ -143,7 +143,7 @@ object SSLHelper {
kmf.init(clientKeyStore, password.toCharArray()) kmf.init(clientKeyStore, password.toCharArray())
return kmf.keyManagers return kmf.keyManagers
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) Log.e(TAG, e.toString())
} }
return null return null
} }
@ -162,7 +162,7 @@ object SSLHelper {
try { try {
certStream.close() certStream.close()
} catch (e: IOException) { } catch (e: IOException) {
Timber.e(e) Log.e(TAG, e.toString())
} }
} }
//我们创建一个默认类型的TrustManagerFactory //我们创建一个默认类型的TrustManagerFactory

@ -1,16 +1,16 @@
package io.legado.app.model.webBook package xyz.fycz.myreader.model.third3.webBook
import android.text.TextUtils import android.text.TextUtils
import io.legado.app.R import io.legado.app.R
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.TocRule import xyz.fycz.myreader.model.third3.rule.TocRule
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.TocEmptyException import io.legado.app.model.TocEmptyException
import io.legado.app.model.analyzeRule.AnalyzeRule import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async import kotlinx.coroutines.async

@ -1,4 +1,4 @@
package io.legado.app.model.webBook package xyz.fycz.myreader.model.third3.webBook
import io.legado.app.R import io.legado.app.R
import io.legado.app.data.appDb import io.legado.app.data.appDb
@ -10,8 +10,8 @@ import io.legado.app.help.BookHelp
import io.legado.app.model.ContentEmptyException import io.legado.app.model.ContentEmptyException
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl
import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.HtmlFormatter
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope

@ -1,4 +1,4 @@
package io.legado.app.model.webBook package xyz.fycz.myreader.model.third3.webBook
import io.legado.app.R import io.legado.app.R
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
@ -6,7 +6,7 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule
import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.HtmlFormatter
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.StringUtils.wordCountFormat import io.legado.app.utils.StringUtils.wordCountFormat

@ -1,4 +1,4 @@
package io.legado.app.model.webBook package xyz.fycz.myreader.model.third3.webBook
import io.legado.app.R import io.legado.app.R
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
@ -8,8 +8,8 @@ import io.legado.app.data.entities.rule.BookListRule
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeRule import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl
import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.HtmlFormatter
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.StringUtils.wordCountFormat import io.legado.app.utils.StringUtils.wordCountFormat

@ -1,4 +1,4 @@
package io.legado.app.model.webBook package xyz.fycz.myreader.model.third3.webBook
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey

@ -1,4 +1,4 @@
package io.legado.app.model.webBook package xyz.fycz.myreader.model.third3.webBook
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
@ -8,7 +8,7 @@ import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.http.StrResponse import io.legado.app.help.http.StrResponse
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.analyzeRule.AnalyzeUrl import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive

Loading…
Cancel
Save