LectorManga: Fix images not loading (#18911)
* Fix ssl * Only in img1.japanreader
This commit is contained in:
parent
75dee193ff
commit
80ae2879fd
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'LectorManga'
|
extName = 'LectorManga'
|
||||||
pkgNameSuffix = 'es.lectormanga'
|
pkgNameSuffix = 'es.lectormanga'
|
||||||
extClass = '.LectorManga'
|
extClass = '.LectorManga'
|
||||||
extVersionCode = 29
|
extVersionCode = 30
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,11 @@ package eu.kanade.tachiyomi.extension.es.lectormanga
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import android.view.View
|
||||||
|
import android.webkit.WebView
|
||||||
|
import android.webkit.WebViewClient
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
@ -28,6 +33,7 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
||||||
|
|
||||||
@ -44,12 +50,17 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
|||||||
.add("Referer", "$baseUrl/")
|
.add("Referer", "$baseUrl/")
|
||||||
}
|
}
|
||||||
|
|
||||||
private val imageCDNUrls = arrayOf("https://img1.followmanga.com", "https://img1.biggestchef.com", "https://img1.indalchef.com", "https://img1.recipesandcook.com")
|
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",
|
||||||
|
)
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
private val preferences: SharedPreferences by lazy {
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var loadWebView = true
|
||||||
override val client: OkHttpClient = network.client.newBuilder()
|
override val client: OkHttpClient = network.client.newBuilder()
|
||||||
.rateLimitHost(
|
.rateLimitHost(
|
||||||
baseUrl.toHttpUrlOrNull()!!,
|
baseUrl.toHttpUrlOrNull()!!,
|
||||||
@ -76,6 +87,49 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
|||||||
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||||
60,
|
60,
|
||||||
)
|
)
|
||||||
|
.rateLimitHost(
|
||||||
|
imageCDNUrls[4].toHttpUrlOrNull()!!,
|
||||||
|
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(),
|
||||||
|
60,
|
||||||
|
)
|
||||||
|
.rateLimitHost(
|
||||||
|
imageCDNUrls[5].toHttpUrlOrNull()!!,
|
||||||
|
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 handler = Handler(Looper.getMainLooper())
|
||||||
|
val latch = CountDownLatch(1)
|
||||||
|
var webView: WebView? = null
|
||||||
|
handler.post {
|
||||||
|
val webview = WebView(Injekt.get<Application>())
|
||||||
|
webView = webview
|
||||||
|
webview.settings.domStorageEnabled = true
|
||||||
|
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
|
||||||
|
webview.settings.useWideViewPort = false
|
||||||
|
webview.settings.loadWithOverviewMode = false
|
||||||
|
|
||||||
|
webview.webViewClient = object : WebViewClient() {
|
||||||
|
override fun onPageFinished(view: WebView?, url: String?) {
|
||||||
|
latch.countDown()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val headers = mutableMapOf<String, String>()
|
||||||
|
headers["Referer"] = baseUrl
|
||||||
|
|
||||||
|
webview.loadUrl(url, headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
latch.await()
|
||||||
|
loadWebView = false
|
||||||
|
handler.post { webView?.destroy() }
|
||||||
|
}
|
||||||
|
chain.proceed(request)
|
||||||
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int) = GET("$baseUrl/library?order_item=likes_count&order_dir=desc&type=&filter_by=title&page=$page", headers)
|
override fun popularMangaRequest(page: Int) = GET("$baseUrl/library?order_item=likes_count&order_dir=desc&type=&filter_by=title&page=$page", headers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user