Hitomi: refresh expiring page URLs (#7440)
This commit is contained in:
parent
83145f221f
commit
7c7553dec1
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
extName = 'Hitomi'
|
||||
extClass = '.HitomiFactory'
|
||||
extVersionCode = 35
|
||||
extVersionCode = 36
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -64,8 +64,11 @@ class Hitomi(
|
|||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private val REGEX_IMAGE_URL = """https://.*?a\.$domain/(jxl|avif|webp)/\d+?/\d+/([0-9a-f]{64})\.\1""".toRegex()
|
||||
|
||||
override val client = network.cloudflareClient.newBuilder()
|
||||
.addInterceptor(::jxlContentTypeInterceptor)
|
||||
.addInterceptor(::updateImageUrlInterceptor)
|
||||
.apply {
|
||||
interceptors().add(0, ::streamResetRetry)
|
||||
}
|
||||
|
@ -748,6 +751,25 @@ class Hitomi(
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateImageUrlInterceptor(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
|
||||
val cleanUrl = request.url.run { "$scheme://$host$encodedPath" }
|
||||
REGEX_IMAGE_URL.matchEntire(cleanUrl)?.let { match ->
|
||||
val (ext, hash) = match.destructured
|
||||
|
||||
val commonId = runBlocking { commonImageId() }
|
||||
val imageId = imageIdFromHash(hash)
|
||||
val subDomain = 'a' + runBlocking { subdomainOffset(imageId) }
|
||||
|
||||
val newUrl = "https://${subDomain}a.$domain/$ext/$commonId$imageId/$hash.$ext"
|
||||
val newRequest = request.newBuilder().url(newUrl).build()
|
||||
return chain.proceed(newRequest)
|
||||
}
|
||||
|
||||
return chain.proceed(request)
|
||||
}
|
||||
|
||||
override fun popularMangaParse(response: Response) = throw UnsupportedOperationException()
|
||||
override fun popularMangaRequest(page: Int) = throw UnsupportedOperationException()
|
||||
override fun latestUpdatesRequest(page: Int) = throw UnsupportedOperationException()
|
||||
|
|
Loading…
Reference in New Issue