Fixed imageloading (#5020)

Fixed imageloading
This commit is contained in:
Blatzar 2020-12-05 00:09:32 +00:00 committed by GitHub
parent fadeb3bf9a
commit fb1092dd29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 16 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'HentaiNexus' extName = 'HentaiNexus'
pkgNameSuffix = 'en.hentainexus' pkgNameSuffix = 'en.hentainexus'
extClass = '.HentaiNexus' extClass = '.HentaiNexus'
extVersionCode = 4 extVersionCode = 5
libVersion = '1.2' libVersion = '1.2'
containsNsfw = true containsNsfw = true
} }

View File

@ -1,5 +1,7 @@
package eu.kanade.tachiyomi.extension.en.hentainexus package eu.kanade.tachiyomi.extension.en.hentainexus
import android.util.Base64
import com.google.gson.JsonParser
import eu.kanade.tachiyomi.annotations.Nsfw import eu.kanade.tachiyomi.annotations.Nsfw
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.asObservableSuccess
@ -16,12 +18,7 @@ import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import rx.Observable import rx.Observable
import java.net.URLEncoder import java.net.URLEncoder
import android.util.Base64
import kotlin.experimental.xor import kotlin.experimental.xor
import com.google.gson.Gson
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import com.google.gson.JsonParser
@Nsfw @Nsfw
class HentaiNexus : ParsedHttpSource() { class HentaiNexus : ParsedHttpSource() {
@ -207,18 +204,29 @@ class HentaiNexus : ParsedHttpSource() {
} }
private fun decodePages(code: String): List<String> { private fun decodePages(code: String): List<String> {
val hidden: ByteArray = Base64.decode(code, Base64.DEFAULT) val bin: ByteArray = Base64.decode(code, Base64.DEFAULT)
var key: ByteArray = hidden.sliceArray(0..63) val head: ByteArray = bin.sliceArray(0..63)
var body: ByteArray = hidden.sliceArray(64..hidden.size-1) val arr = ByteArray(256) { it.toByte() }
var num: Int = 0
var tmp: Byte
for (i in 0..255) {
num = (num + arr[i] + head[i % head.size] + 256) % 256
tmp = arr[i]
arr[i] = arr[num]
arr[num] = tmp
}
var i = 0
num = 0
val buf = StringBuilder() val buf = StringBuilder()
for (begin in 0 until body.size step 64) { for (j in 0..bin.size - 65) {
var chunk: ByteArray = body.sliceArray(begin..begin+63) i = (i + 1) % 256
for (x in 0 until 64) { num = (num + arr[i] + 256) % 256
buf.append((chunk[x] xor key[x]).toChar()) tmp = arr[i]
} arr[i] = arr[num]
key = chunk arr[num] = tmp
buf.append((bin[j + 64] xor arr[(arr[i] + arr[num] + 256) % 256]).toChar())
} }
val json = JsonParser().parse(buf.toString()).asJsonObject val json = JsonParser().parse(buf.toString()).asJsonObject
@ -228,7 +236,7 @@ class HentaiNexus : ParsedHttpSource() {
val id = json.get("i").asString val id = json.get("i").asString
return json.get("f").asJsonArray.map { it -> return json.get("f").asJsonArray.map { it ->
val page = it.asJsonObject val page = it.asJsonObject
"${base}${folder}${page.get("h").asString}/${id}/${page.get("p").asString}" "${base}${folder}${page.get("h").asString}/$id/${page.get("p").asString}"
} }
} }