use webp by default

This commit is contained in:
tom5079
2022-02-01 19:10:54 +09:00
parent 0ed59bb8a9
commit c1de45abce
5 changed files with 68 additions and 62 deletions

View File

@@ -38,7 +38,7 @@ android {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 31 targetSdkVersion 31
versionCode 69 versionCode 69
versionName "5.3.3" versionName "5.3.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }

View File

@@ -12,7 +12,7 @@
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 69, "versionCode": 69,
"versionName": "5.3.3", "versionName": "5.3.4",
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }
], ],

View File

@@ -102,19 +102,19 @@ class ExampleInstrumentedTest {
Log.d("PUPILD", r.take(10).toString()) Log.d("PUPILD", r.take(10).toString())
} }
@Test // @Test
fun test_getBlock() { // fun test_getBlock() {
val galleryBlock = getGalleryBlock(2097576) // val galleryBlock = getGalleryBlock(2097576)
//
print(galleryBlock) // print(galleryBlock)
} // }
//
@Test // @Test
fun test_getGallery() { // fun test_getGallery() {
val gallery = getGallery(2097751) // val gallery = getGallery(2097751)
//
print(gallery) // print(gallery)
} // }
@Test @Test
fun test_getGalleryInfo() { fun test_getGalleryInfo() {
@@ -125,42 +125,44 @@ class ExampleInstrumentedTest {
@Test @Test
fun test_getReader() { fun test_getReader() {
val reader = getGalleryInfo(1722144) val reader = getGalleryInfo(2128654)
print(reader) Log.d("PUPILD", reader.toString())
} }
@Test @Test
fun test_getImages() { fun test_getImages() { runBlocking {
val galleryID = 2099306 val galleryID = 2128654
val images = getGalleryInfo(galleryID).files.map { val images = getGalleryInfo(galleryID).files.map {
imageUrlFromImage(galleryID, it,false) imageUrlFromImage(galleryID, it,false)
} }
images.forEachIndexed { index, image -> Log.d("PUPILD", images.toString())
println("Testing $index/${images.size}: $image")
val response = client.newCall(
Request.Builder()
.url(image)
.header("Referer", "https://hitomi.la/")
.build()
).execute()
assertEquals(200, response.code()) // images.forEachIndexed { index, image ->
// println("Testing $index/${images.size}: $image")
// val response = client.newCall(
// Request.Builder()
// .url(image)
// .header("Referer", "https://hitomi.la/")
// .build()
// ).execute()
//
// assertEquals(200, response.code())
//
// println("$index/${images.size} Passed")
// }
} }
println("$index/${images.size} Passed") // @Test
} // fun test_urlFromUrlFromHash() {
} // val url = urlFromUrlFromHash(1531795, GalleryFiles(
// 212, "719d46a7556be0d0021c5105878507129b5b3308b02cf67f18901b69dbb3b5ef", 1, "00.jpg", 300
@Test // ), "webp")
fun test_urlFromUrlFromHash() { //
val url = urlFromUrlFromHash(1531795, GalleryFiles( // print(url)
212, "719d46a7556be0d0021c5105878507129b5b3308b02cf67f18901b69dbb3b5ef", 1, "00.jpg", 300 // }
), "webp")
print(url)
}
// @Test // @Test
// suspend fun test_doSearch_extreme() { // suspend fun test_doSearch_extreme() {
@@ -173,9 +175,9 @@ class ExampleInstrumentedTest {
// print(doSearch("-male:yaoi -female:yaoi -female:loli").size) // print(doSearch("-male:yaoi -female:yaoi -female:loli").size)
// } // }
@Test // @Test
fun test_subdomainFromUrl() { // fun test_subdomainFromUrl() {
val galleryInfo = getGalleryInfo(1929109).files[2] // val galleryInfo = getGalleryInfo(1929109).files[2]
print(urlFromUrlFromHash(1929109, galleryInfo, "webp", null, "a")) // print(urlFromUrlFromHash(1929109, galleryInfo, "webp", null, "a"))
} // }
} }

View File

@@ -81,7 +81,6 @@ private var version = ""
var runtimeReady = false var runtimeReady = false
private set private set
lateinit var runtime: QuickJs lateinit var runtime: QuickJs
private set
class Pupil : Application() { class Pupil : Application() {
companion object { companion object {
@@ -91,7 +90,7 @@ class Pupil : Application() {
init { init {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
withContext(evaluationContext) { withContext(Dispatchers.Main) {
runtime = QuickJs.create() runtime = QuickJs.create()
} }
while (true) { while (true) {
@@ -100,11 +99,15 @@ class Pupil : Application() {
if (version != newVersion) { if (version != newVersion) {
runtimeReady = false runtimeReady = false
version = newVersion
evaluationContext.cancelChildren() evaluationContext.cancelChildren()
withContext(evaluationContext) { kotlin.runCatching {
runtime.evaluate(URL("https://tom5079.github.io/PupilSources/assets/js/gg.js").readText()) URL("https://tom5079.github.io/PupilSources/assets/js/gg.js").readText()
runtimeReady = true }.getOrNull()?.also { gg ->
withContext(Dispatchers.Main) {
runtime.evaluate(gg)
version = newVersion
runtimeReady = true
}
} }
} }
} }

View File

@@ -128,7 +128,7 @@ const val galleryblockextension = ".html"
const val galleryblockdir = "galleryblock" const val galleryblockdir = "galleryblock"
const val nozomiextension = ".nozomi" const val nozomiextension = ".nozomi"
val evaluationContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher() + Job() val evaluationContext = Dispatchers.Main + Job()
object gg { object gg {
@@ -198,14 +198,15 @@ suspend fun rewriteTnPaths(html: String) {
} }
suspend fun imageUrlFromImage(galleryID: Int, image: GalleryFiles, noWebp: Boolean) : String { suspend fun imageUrlFromImage(galleryID: Int, image: GalleryFiles, noWebp: Boolean) : String {
return when { return urlFromUrlFromHash(galleryID, image, "webp", null, "a")
noWebp -> // return when {
urlFromUrlFromHash(galleryID, image) // noWebp ->
// image.hasavif != 0 -> // urlFromUrlFromHash(galleryID, image)
// urlFromUrlFromHash(galleryID, image, "avif", null, "a") //// image.hasavif != 0 ->
image.haswebp != 0 -> //// urlFromUrlFromHash(galleryID, image, "avif", null, "a")
urlFromUrlFromHash(galleryID, image, "webp", null, "a") // image.haswebp != 0 ->
else -> // urlFromUrlFromHash(galleryID, image, "webp", null, "a")
urlFromUrlFromHash(galleryID, image) // else ->
} // urlFromUrlFromHash(galleryID, image)
// }
} }