LectorManga: Fix images couldn't be loaded (#19016)
* Fix * Minor change * bruh I delete the ratelimit * Rename
This commit is contained in:
parent
5176d3bdab
commit
92c5748333
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'LectorManga'
|
||||
pkgNameSuffix = 'es.lectormanga'
|
||||
extClass = '.LectorManga'
|
||||
extVersionCode = 30
|
||||
extVersionCode = 31
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -51,15 +51,26 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
|||
}
|
||||
|
||||
private val imageCDNUrls = arrayOf(
|
||||
"https://img1.followmanga.com", "https://img1.biggestchef.com",
|
||||
"https://img1.indalchef.com", "https://img1.recipesandcook.com",
|
||||
"https://img1.cyclingte.com", "https://img1.japanreader.com",
|
||||
"https://img1.followmanga.com",
|
||||
"https://img1.biggestchef.com",
|
||||
"https://img1.indalchef.com",
|
||||
"https://img1.recipesandcook.com",
|
||||
"https://img1.cyclingte.com",
|
||||
"https://img1.japanreader.com",
|
||||
"https://japanreader.com",
|
||||
)
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
private fun OkHttpClient.Builder.rateLimitImageCDNs(hosts: Array<String>, permits: Int, period: Long): OkHttpClient.Builder {
|
||||
hosts.forEach { host ->
|
||||
rateLimitHost(host.toHttpUrlOrNull()!!, permits, period)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
private var loadWebView = true
|
||||
override val client: OkHttpClient = network.client.newBuilder()
|
||||
.rateLimitHost(
|
||||
|
@ -67,40 +78,15 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
|||
preferences.getString(WEB_RATELIMIT_PREF, WEB_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.rateLimitHost(
|
||||
imageCDNUrls[0].toHttpUrlOrNull()!!,
|
||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.rateLimitHost(
|
||||
imageCDNUrls[1].toHttpUrlOrNull()!!,
|
||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.rateLimitHost(
|
||||
imageCDNUrls[2].toHttpUrlOrNull()!!,
|
||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.rateLimitHost(
|
||||
imageCDNUrls[3].toHttpUrlOrNull()!!,
|
||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.rateLimitHost(
|
||||
imageCDNUrls[4].toHttpUrlOrNull()!!,
|
||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.rateLimitHost(
|
||||
imageCDNUrls[5].toHttpUrlOrNull()!!,
|
||||
.rateLimitImageCDNs(
|
||||
imageCDNUrls,
|
||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.addInterceptor { chain ->
|
||||
val request = chain.request()
|
||||
val url = request.url.toString()
|
||||
if (url.startsWith("https://img1.japanreader.com") && loadWebView) {
|
||||
val url = request.url
|
||||
if (url.host.contains("japanreader.com") && loadWebView) {
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val latch = CountDownLatch(1)
|
||||
var webView: WebView? = null
|
||||
|
@ -121,7 +107,7 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
|||
val headers = mutableMapOf<String, String>()
|
||||
headers["Referer"] = baseUrl
|
||||
|
||||
webview.loadUrl(url, headers)
|
||||
webview.loadUrl(url.toString(), headers)
|
||||
}
|
||||
|
||||
latch.await()
|
||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'TuMangaOnline'
|
||||
pkgNameSuffix = 'es.tumangaonline'
|
||||
extClass = '.TuMangaOnline'
|
||||
extVersionCode = 45
|
||||
extVersionCode = 46
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -50,18 +50,28 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() {
|
|||
.add("Referer", "$baseUrl/")
|
||||
}
|
||||
|
||||
private val imageCDNUrl = "https://img1.japanreader.com"
|
||||
private val imageCDNUrls = arrayOf(
|
||||
"https://japanreader.com",
|
||||
"https://img1.japanreader.com",
|
||||
)
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
private fun OkHttpClient.Builder.rateLimitImageCDNs(hosts: Array<String>, permits: Int, period: Long): OkHttpClient.Builder {
|
||||
hosts.forEach { host ->
|
||||
rateLimitHost(host.toHttpUrlOrNull()!!, permits, period)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
private var loadWebView = true
|
||||
override val client: OkHttpClient = network.client.newBuilder()
|
||||
.addInterceptor { chain ->
|
||||
val request = chain.request()
|
||||
val url = request.url.toString()
|
||||
if (url.startsWith(imageCDNUrl) && loadWebView) {
|
||||
val url = request.url
|
||||
if (url.host.contains("japanreader.com") && loadWebView) {
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val latch = CountDownLatch(1)
|
||||
var webView: WebView? = null
|
||||
|
@ -84,7 +94,7 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() {
|
|||
val headers = mutableMapOf<String, String>()
|
||||
headers["Referer"] = baseUrl
|
||||
|
||||
webview.loadUrl(url, headers)
|
||||
webview.loadUrl(url.toString(), headers)
|
||||
}
|
||||
|
||||
latch.await()
|
||||
|
@ -98,8 +108,8 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() {
|
|||
preferences.getString(WEB_RATELIMIT_PREF, WEB_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
.rateLimitHost(
|
||||
imageCDNUrl.toHttpUrlOrNull()!!,
|
||||
.rateLimitImageCDNs(
|
||||
imageCDNUrls,
|
||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||
60,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue