Bato.to: expose all mirrors for CI (#9810)

* Bato.to: expose all mirrors for CI

* move CI check to `getMirrorPref()`

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>

* remove proxy variable `mirror`

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>

---------

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
This commit is contained in:
Vetle Ledaal 2025-07-26 20:46:52 +02:00 committed by Draff
parent 0730f24d95
commit e5ab6fbb21
Signed by: Draff
GPG Key ID: E8A89F3211677653
2 changed files with 16 additions and 12 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Bato.to'
extClass = '.BatoToFactory'
extVersionCode = 52
extVersionCode = 53
isNsfw = true
}

View File

@ -53,7 +53,17 @@ open class BatoTo(
private val preferences by getPreferencesLazy { migrateMirrorPref() }
override val name: String = "Bato.to"
override val baseUrl: String get() = mirror
override var baseUrl: String = ""
get() {
val current = field
if (current.isNotEmpty()) {
return current
}
field = getMirrorPref()
return field
}
override val id: Long = when (lang) {
"zh-Hans" -> 2818874445640189582
"zh-Hant" -> 38886079663327225
@ -70,7 +80,7 @@ open class BatoTo(
setDefaultValue(MIRROR_PREF_DEFAULT_VALUE)
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
mirror = newValue as String
baseUrl = newValue as String
true
}
}
@ -94,17 +104,11 @@ open class BatoTo(
screen.addPreference(removeOfficialPref)
}
private var mirror = ""
get() {
val current = field
if (current.isNotEmpty()) {
return current
}
field = getMirrorPref()
return field
private fun getMirrorPref(): String {
if (System.getenv("CI") == "true") {
return (MIRROR_PREF_ENTRY_VALUES.drop(1) + DEPRECATED_MIRRORS).joinToString("#, ")
}
private fun getMirrorPref(): String {
return preferences.getString("${MIRROR_PREF_KEY}_$lang", MIRROR_PREF_DEFAULT_VALUE)
?.takeUnless { it == MIRROR_PREF_DEFAULT_VALUE }
?: let {