Zoro: Add alternative domains (#1629)

* Add alternative domains

* small refractor
This commit is contained in:
Secozzi 2023-05-20 19:06:06 +02:00 committed by GitHub
parent 3b11e5ad43
commit 8e64343b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'zoro.to (experimental)'
pkgNameSuffix = 'en.zoro'
extClass = '.Zoro'
extVersionCode = 26
extVersionCode = 27
libVersion = '13'
}

View File

@ -47,7 +47,7 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override val name = "zoro.to (experimental)"
override val baseUrl = "https://zoro.to"
override val baseUrl by lazy { preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT)!! }
override val lang = "en"
@ -325,6 +325,21 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
// ============================== Settings ==============================
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val domainPref = ListPreference(screen.context).apply {
key = PREF_DOMAIN_KEY
title = PREF_DOMAIN_TITLE
entries = PREF_DOMAIN_ENTRIES
entryValues = PREF_DOMAIN_ENTRY_VALUES
setDefaultValue(PREF_DOMAIN_DEFAULT)
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}
val videoQualityPref = ListPreference(screen.context).apply {
key = PREF_QUALITY_KEY
title = PREF_QUALITY_TITLE
@ -372,6 +387,7 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
preferences.edit().putString(key, entry).commit()
}
}
screen.addPreference(domainPref)
screen.addPreference(videoQualityPref)
screen.addPreference(epTypePref)
screen.addPreference(subLangPref)
@ -424,6 +440,12 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private const val PREF_TYPE_TITLE = "Preferred episode type/mode"
private val PREF_TYPE_ENTRIES = arrayOf("sub", "dub")
private const val PREF_DOMAIN_KEY = "preferred_domain"
private const val PREF_DOMAIN_TITLE = "Preferred domain (requires app restart)"
private const val PREF_DOMAIN_DEFAULT = "https://zoro.to"
private val PREF_DOMAIN_ENTRIES = arrayOf("zoro.to", "zoro.moe", "zoro.sx", "zoro.pm", "sanji.to")
private val PREF_DOMAIN_ENTRY_VALUES = arrayOf("https://zoro.to", "https://zoro.moe", "https://zoro.sx", "https://zoro.pm", "https://sanji.to")
private const val PREF_SUB_KEY = "preferred_subLang"
private const val PREF_SUB_TITLE = "Preferred sub language"
private val PREF_SUB_ENTRIES = arrayOf(