Hitomi.la issue fixes (#8554)

* Fix page url requests

* Add keyword search url encoding
This commit is contained in:
Arraiment 2021-08-14 17:45:28 +08:00 committed by GitHub
parent 49834e948b
commit aa2b301ac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Hitomi.la' extName = 'Hitomi.la'
pkgNameSuffix = 'all.hitomi' pkgNameSuffix = 'all.hitomi'
extClass = '.HitomiFactory' extClass = '.HitomiFactory'
extVersionCode = 9 extVersionCode = 10
libVersion = '1.2' libVersion = '1.2'
containsNsfw = true containsNsfw = true
} }

View File

@ -23,6 +23,7 @@ import rx.schedulers.Schedulers
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.net.URLEncoder
import java.util.Locale import java.util.Locale
import androidx.preference.CheckBoxPreference as AndroidXCheckBoxPreference import androidx.preference.CheckBoxPreference as AndroidXCheckBoxPreference
import androidx.preference.PreferenceScreen as AndroidXPreferenceScreen import androidx.preference.PreferenceScreen as AndroidXPreferenceScreen
@ -177,7 +178,7 @@ open class Hitomi(override val lang: String, private val nozomiLang: String) : H
val hn = Single.zip(tagIndexVersion(), galleryIndexVersion()) { tv, gv -> tv to gv } val hn = Single.zip(tagIndexVersion(), galleryIndexVersion()) { tv, gv -> tv to gv }
.map { HitomiNozomi(client, it.first, it.second) } .map { HitomiNozomi(client, it.first, it.second) }
val base = hn.flatMap { n -> val base = hn.flatMap { n ->
n.getGalleryIdsForQuery("$area:$keyword", nozomiLang, popular).map { n to it.toSet() } n.getGalleryIdsForQuery("$area:${URLEncoder.encode(keyword, "utf-8")}", nozomiLang, popular).map { n to it.toSet() }
} }
base.flatMap { (_, ids) -> base.flatMap { (_, ids) ->
val chunks = ids.chunked(PAGE_SIZE) val chunks = ids.chunked(PAGE_SIZE)
@ -368,9 +369,9 @@ open class Hitomi(override val lang: String, private val nozomiLang: String) : H
// Change g's if statement from !isNaN(g) // Change g's if statement from !isNaN(g)
private fun firstSubdomainFromGalleryId(pathSegment: String): Char { private fun firstSubdomainFromGalleryId(pathSegment: String): Char {
var o = 0 var o = 0
var g = pathSegment.toInt(16) val g = pathSegment.toInt(16)
if (g < 0x80) o = 1 if (g < 0x88) o = 1
if (g < 0x40) o = 2 if (g < 0x44) o = 2
return (97 + o).toChar() return (97 + o).toChar()
} }