mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 04:28:55 +01:00
Fix gallery browsing
This commit is contained in:
@@ -124,4 +124,12 @@ object PreferenceKeys {
|
||||
const val eh_showSyncIntro = "eh_show_sync_intro"
|
||||
|
||||
const val eh_readOnlySync = "eh_sync_read_only"
|
||||
|
||||
const val eh_useOrigImages = "eh_useOrigImages"
|
||||
|
||||
const val eh_ehSettingsProfile = "eh_ehSettingsProfile"
|
||||
|
||||
const val eh_exhSettingsProfile = "eh_exhSettingsProfile"
|
||||
|
||||
const val eh_enableExHentai = "enable_exhentai"
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ class PreferencesHelper(val context: Context) {
|
||||
fun migrateFlags() = rxPrefs.getInteger("migrate_flags", Int.MAX_VALUE)
|
||||
|
||||
// --> EH
|
||||
fun enableExhentai() = rxPrefs.getBoolean("enable_exhentai", false)
|
||||
fun enableExhentai() = rxPrefs.getBoolean(Keys.eh_enableExHentai, false)
|
||||
|
||||
fun secureEXH() = rxPrefs.getBoolean("secure_exh", true)
|
||||
|
||||
@@ -181,6 +181,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun useJapaneseTitle() = rxPrefs.getBoolean("use_jp_title", false)
|
||||
|
||||
fun eh_useOriginalImages() = rxPrefs.getBoolean(Keys.eh_useOrigImages, false)
|
||||
|
||||
fun ehSearchSize() = rxPrefs.getString("ex_search_size", "rc_0")
|
||||
|
||||
fun thumbnailRows() = rxPrefs.getString("ex_thumb_rows", "tr_2")
|
||||
@@ -195,6 +197,8 @@ class PreferencesHelper(val context: Context) {
|
||||
fun memberIdVal() = rxPrefs.getString("eh_ipb_member_id", null)
|
||||
fun passHashVal() = rxPrefs.getString("eh_ipb_pass_hash", null)
|
||||
fun igneousVal() = rxPrefs.getString("eh_igneous", null)
|
||||
fun eh_ehSettingsProfile() = rxPrefs.getInteger(Keys.eh_ehSettingsProfile, -1)
|
||||
fun eh_exhSettingsProfile() = rxPrefs.getInteger(Keys.eh_exhSettingsProfile, -1)
|
||||
|
||||
//Lock
|
||||
fun lockHash() = rxPrefs.getString("lock_hash", null)
|
||||
@@ -205,7 +209,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun lockUseFingerprint() = rxPrefs.getBoolean("lock_finger", false)
|
||||
|
||||
fun eh_useHighQualityThumbs() = rxPrefs.getBoolean(Keys.eh_nh_useHighQualityThumbs, false)
|
||||
fun eh_nh_useHighQualityThumbs() = rxPrefs.getBoolean(Keys.eh_nh_useHighQualityThumbs, false)
|
||||
|
||||
fun eh_showSyncIntro() = rxPrefs.getBoolean(Keys.eh_showSyncIntro, true)
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ import exh.util.UriFilter
|
||||
import exh.util.UriGroup
|
||||
import exh.util.ignore
|
||||
import exh.util.urlImportFetchSearchManga
|
||||
import okhttp3.CacheControl
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.*
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
@@ -42,11 +39,14 @@ class EHentai(override val id: Long,
|
||||
else
|
||||
"http"
|
||||
|
||||
override val baseUrl: String
|
||||
val domain: String
|
||||
get() = if(exh)
|
||||
"$schema://exhentai.org"
|
||||
"exhentai.org"
|
||||
else
|
||||
"$schema://e-hentai.org"
|
||||
"e-hentai.org"
|
||||
|
||||
override val baseUrl: String
|
||||
get() = "$schema://$domain"
|
||||
|
||||
override val lang = "all"
|
||||
override val supportsLatest = true
|
||||
@@ -68,7 +68,7 @@ class EHentai(override val id: Long,
|
||||
//Get title
|
||||
it.select(".itd .it5 a").first()?.apply {
|
||||
title = text()
|
||||
setUrlWithoutDomain(addParam(attr("href"), "nw", "always"))
|
||||
setUrlWithoutDomain(ExGalleryMetadata.normalizeUrl(attr("href")))
|
||||
}
|
||||
//Get image
|
||||
it.select(".itd .it2").first()?.apply {
|
||||
@@ -81,7 +81,6 @@ class EHentai(override val id: Long,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
//Add to page if required
|
||||
val hasNextPage = select("a[onclick=return false]").last()?.let {
|
||||
@@ -330,62 +329,32 @@ class EHentai(override val id: Long,
|
||||
return Pair(result as List<ParsedManga>, favNames!!)
|
||||
}
|
||||
|
||||
val cookiesHeader by lazy {
|
||||
fun spPref() = if(exh)
|
||||
prefs.eh_exhSettingsProfile()
|
||||
else
|
||||
prefs.eh_ehSettingsProfile()
|
||||
|
||||
fun rawCookies(sp: Int): Map<String, String> {
|
||||
val cookies: MutableMap<String, String> = mutableMapOf()
|
||||
if(prefs.enableExhentai().getOrDefault()) {
|
||||
cookies[LoginController.MEMBER_ID_COOKIE] = prefs.memberIdVal().get()!!
|
||||
cookies[LoginController.PASS_HASH_COOKIE] = prefs.passHashVal().get()!!
|
||||
cookies[LoginController.IGNEOUS_COOKIE] = prefs.igneousVal().get()!!
|
||||
cookies["sp"] = sp.toString()
|
||||
}
|
||||
|
||||
//Setup settings
|
||||
val settings = mutableListOf<String?>()
|
||||
//Image quality
|
||||
settings.add(when(prefs.imageQuality()
|
||||
.getOrDefault()
|
||||
.toLowerCase()) {
|
||||
"ovrs_2400" -> "xr_2400"
|
||||
"ovrs_1600" -> "xr_1600"
|
||||
"high" -> "xr_1280"
|
||||
"med" -> "xr_980"
|
||||
"low" -> "xr_780"
|
||||
"auto" -> null
|
||||
else -> null
|
||||
})
|
||||
//Use Hentai@Home
|
||||
settings.add(if(prefs.useHentaiAtHome().getOrDefault())
|
||||
null
|
||||
else
|
||||
"uh_n")
|
||||
//Japanese titles
|
||||
settings.add(if(prefs.useJapaneseTitle().getOrDefault())
|
||||
"tl_j"
|
||||
else
|
||||
null)
|
||||
//Do not show popular right now pane as we can't parse it
|
||||
settings.add("prn_n")
|
||||
//Paging size
|
||||
settings.add(prefs.ehSearchSize().getOrDefault())
|
||||
//Thumbnail rows
|
||||
settings.add(prefs.thumbnailRows().getOrDefault())
|
||||
//Session-less list display mode (for users without ExHentai)
|
||||
cookies["sl"] = "dm_0"
|
||||
|
||||
cookies.put("uconfig", buildSettings(settings))
|
||||
|
||||
buildCookies(cookies)
|
||||
return cookies
|
||||
}
|
||||
|
||||
fun cookiesHeader(sp: Int = spPref().getOrDefault())
|
||||
= buildCookies(rawCookies(sp))
|
||||
|
||||
//Headers
|
||||
override fun headersBuilder()
|
||||
= super.headersBuilder().add("Cookie", cookiesHeader)!!
|
||||
|
||||
fun buildSettings(settings: List<String?>): String {
|
||||
return settings.filterNotNull().joinToString(separator = "-")
|
||||
}
|
||||
|
||||
fun buildCookies(cookies: Map<String, String>)
|
||||
= cookies.entries.joinToString(separator = "; ", postfix = ";") {
|
||||
"${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}"
|
||||
}
|
||||
= super.headersBuilder().add("Cookie", cookiesHeader())!!
|
||||
|
||||
fun addParam(url: String, param: String, value: String)
|
||||
= Uri.parse(url)
|
||||
@@ -394,11 +363,13 @@ class EHentai(override val id: Long,
|
||||
.toString()
|
||||
|
||||
override val client = network.client.newBuilder()
|
||||
.cookieJar(CookieJar.NO_COOKIES)
|
||||
.addInterceptor { chain ->
|
||||
val newReq = chain
|
||||
.request()
|
||||
.newBuilder()
|
||||
.addHeader("Cookie", cookiesHeader)
|
||||
.removeHeader("Cookie")
|
||||
.addHeader("Cookie", cookiesHeader())
|
||||
.build()
|
||||
|
||||
chain.proceed(newReq)
|
||||
@@ -470,5 +441,11 @@ class EHentai(override val id: Long,
|
||||
companion object {
|
||||
val QUERY_PREFIX = "?f_apply=Apply+Filter"
|
||||
val TR_SUFFIX = "TR"
|
||||
|
||||
fun buildCookies(cookies: Map<String, String>)
|
||||
= cookies.entries.joinToString(separator = "; ", postfix = ";") {
|
||||
"${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import android.widget.Toast
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import exh.favorites.FavoritesIntroDialog
|
||||
import exh.favorites.LocalFavoritesStorage
|
||||
import exh.uconfig.ConfiguringDialogController
|
||||
import exh.ui.login.LoginController
|
||||
import exh.util.trans
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
@@ -19,13 +21,22 @@ import rx.schedulers.Schedulers
|
||||
*/
|
||||
|
||||
class SettingsEhController : SettingsController() {
|
||||
private fun Preference<*>.reconfigureOnChange() {
|
||||
asObservable()
|
||||
.skip(1) //Skip first as it is emitted immediately
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeUntilDestroy {
|
||||
ConfiguringDialogController().showDialog(router)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
title = "E-Hentai"
|
||||
|
||||
switchPreference {
|
||||
title = "Enable ExHentai"
|
||||
summaryOff = "Requires login"
|
||||
key = "enable_exhentai"
|
||||
key = PreferenceKeys.eh_enableExHentai
|
||||
isPersistent = false
|
||||
defaultValue = false
|
||||
preferences.enableExhentai()
|
||||
@@ -33,8 +44,8 @@ class SettingsEhController : SettingsController() {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeUntilDestroy {
|
||||
isChecked = it
|
||||
}
|
||||
isChecked = it
|
||||
}
|
||||
|
||||
onChange { newVal ->
|
||||
newVal as Boolean
|
||||
@@ -55,7 +66,9 @@ class SettingsEhController : SettingsController() {
|
||||
summary = "Do you wish to load images through the Hentai@Home Network? Disabling this option will reduce the amount of pages you are able to view"
|
||||
key = "enable_hah"
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
preferences.useHentaiAtHome().reconfigureOnChange()
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
switchPreference {
|
||||
title = "Show Japanese titles in search results"
|
||||
@@ -63,7 +76,19 @@ class SettingsEhController : SettingsController() {
|
||||
summaryOff = "Currently showing English/Romanized titles in search results. Clear the chapter cache after changing this (in the Advanced section)"
|
||||
key = "use_jp_title"
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
preferences.useJapaneseTitle().reconfigureOnChange()
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
switchPreference {
|
||||
title = "Use original images"
|
||||
summaryOn = "Currently using original images"
|
||||
summaryOff = "Currently using resampled images"
|
||||
key = PreferenceKeys.eh_useOrigImages
|
||||
defaultValue = false
|
||||
|
||||
preferences.eh_useOriginalImages().reconfigureOnChange()
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
switchPreference {
|
||||
defaultValue = true
|
||||
@@ -93,45 +118,9 @@ class SettingsEhController : SettingsController() {
|
||||
"med",
|
||||
"low"
|
||||
)
|
||||
}
|
||||
|
||||
listPreference {
|
||||
title = "Search result count per page"
|
||||
summary = "Requires the 'Paging Enlargement' hath perk"
|
||||
defaultValue = "rc_0"
|
||||
key = "ex_search_size"
|
||||
entries = arrayOf(
|
||||
"25 results",
|
||||
"50 results",
|
||||
"100 results",
|
||||
"200 results"
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
"rc_0",
|
||||
"rc_1",
|
||||
"rc_2",
|
||||
"rc_3"
|
||||
)
|
||||
}.dependency = "enable_exhentai"
|
||||
|
||||
listPreference {
|
||||
defaultValue = "tr_2"
|
||||
title = "Thumbnail rows"
|
||||
summary = "Affects loading speeds. It is recommended to set this to the maximum size your hath perks allow"
|
||||
key = "ex_thumb_rows"
|
||||
entries = arrayOf(
|
||||
"4",
|
||||
"10 (requires 'More Thumbs' hath perk)",
|
||||
"20 (requires 'Thumbs Up' hath perk)",
|
||||
"40 (requires 'All Thumbs' hath perk)"
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
"tr_2",
|
||||
"tr_5",
|
||||
"tr_10",
|
||||
"tr_20"
|
||||
)
|
||||
}.dependency = "enable_exhentai"
|
||||
preferences.imageQuality().reconfigureOnChange()
|
||||
}.dependency = PreferenceKeys.eh_enableExHentai
|
||||
|
||||
preferenceCategory {
|
||||
title = "Favorites sync"
|
||||
|
||||
Reference in New Issue
Block a user