Fixed images not loading
This commit is contained in:
@@ -26,7 +26,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
@@ -36,11 +35,6 @@ import com.google.android.gms.common.GooglePlayServicesNotAvailableException
|
||||
import com.google.android.gms.common.GooglePlayServicesRepairableException
|
||||
import com.google.android.gms.security.ProviderInstaller
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.hippo.quickjs.android.QuickJS
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.Dispatcher
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
@@ -48,9 +42,7 @@ import okhttp3.Response
|
||||
import xyz.quaver.io.FileX
|
||||
import xyz.quaver.pupil.types.Tag
|
||||
import xyz.quaver.pupil.util.*
|
||||
import xyz.quaver.readText
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -17,16 +17,12 @@
|
||||
package xyz.quaver.pupil.hitomi
|
||||
|
||||
import android.util.Log
|
||||
import com.hippo.quickjs.android.QuickJS
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import app.cash.zipline.QuickJs
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import xyz.quaver.json
|
||||
import xyz.quaver.readText
|
||||
import java.net.URL
|
||||
import java.nio.charset.Charset
|
||||
|
||||
const val protocol = "https:"
|
||||
|
||||
@@ -54,33 +50,18 @@ interface gg {
|
||||
fun getInstance(): gg =
|
||||
instance ?: synchronized(this) {
|
||||
instance ?: object: gg {
|
||||
private val ggjs by lazy { URL("https://ltn.hitomi.la/gg.js").readText() }
|
||||
private val quickJS = QuickJS.Builder().build()
|
||||
private val engine = QuickJs.create().also {
|
||||
it.evaluate(URL("https://ltn.hitomi.la/gg.js").readText(Charset.defaultCharset()).also {
|
||||
Log.d("PUPILD", it)
|
||||
})
|
||||
}
|
||||
|
||||
override fun m(g: Int): Int =
|
||||
quickJS.createJSRuntime().use { runtime ->
|
||||
runtime.createJSContext().use { context ->
|
||||
context.evaluate(ggjs, "gg.js")
|
||||
context.evaluate("gg.m($g)", "gg.js", Int::class.java)
|
||||
}
|
||||
}
|
||||
override fun m(g: Int): Int = engine.evaluate("gg.m($g)") as Int
|
||||
|
||||
override val b: String
|
||||
get() =
|
||||
quickJS.createJSRuntime().use { runtime ->
|
||||
runtime.createJSContext().use { context ->
|
||||
context.evaluate(ggjs, "gg.js")
|
||||
context.evaluate("gg.b", "gg.js", String::class.java)
|
||||
}
|
||||
}
|
||||
get() = engine.evaluate("gg.b") as String
|
||||
|
||||
override fun s(h: String): String =
|
||||
quickJS.createJSRuntime().use { runtime ->
|
||||
runtime.createJSContext().use { context ->
|
||||
context.evaluate(ggjs, "gg.js")
|
||||
context.evaluate("gg.s('$h')", "gg.js", String::class.java)
|
||||
}
|
||||
}
|
||||
override fun s(h: String): String = engine.evaluate("gg.s('$h')") as String
|
||||
}.also { instance = it }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ class DownloadService : Service() {
|
||||
|
||||
override fun source(): BufferedSource {
|
||||
if (bufferedSource == null)
|
||||
bufferedSource = Okio.buffer(source(responseBody.source()))
|
||||
bufferedSource = source(responseBody.source()).buffer()
|
||||
|
||||
return bufferedSource!!
|
||||
}
|
||||
@@ -174,9 +174,13 @@ class DownloadService : Service() {
|
||||
private val interceptor: PupilInterceptor = { chain ->
|
||||
val request = chain.request()
|
||||
|
||||
Log.d("PUPILD", "REQ")
|
||||
|
||||
if (rateLimitHost.matches(request.url().host()))
|
||||
rateLimiter.acquire()
|
||||
|
||||
Log.d("PUPILD", "ACQ ${request.url()}")
|
||||
|
||||
var response = chain.proceed(request)
|
||||
var limit = 5
|
||||
|
||||
|
||||
Reference in New Issue
Block a user