Zoro: Add alternative domains (#1629)
* Add alternative domains * small refractor
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'zoro.to (experimental)'
|
extName = 'zoro.to (experimental)'
|
||||||
pkgNameSuffix = 'en.zoro'
|
pkgNameSuffix = 'en.zoro'
|
||||||
extClass = '.Zoro'
|
extClass = '.Zoro'
|
||||||
extVersionCode = 26
|
extVersionCode = 27
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override val name = "zoro.to (experimental)"
|
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"
|
override val lang = "en"
|
||||||
|
|
||||||
@ -325,6 +325,21 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
// ============================== Settings ==============================
|
// ============================== Settings ==============================
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
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 {
|
val videoQualityPref = ListPreference(screen.context).apply {
|
||||||
key = PREF_QUALITY_KEY
|
key = PREF_QUALITY_KEY
|
||||||
title = PREF_QUALITY_TITLE
|
title = PREF_QUALITY_TITLE
|
||||||
@ -372,6 +387,7 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
preferences.edit().putString(key, entry).commit()
|
preferences.edit().putString(key, entry).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
screen.addPreference(domainPref)
|
||||||
screen.addPreference(videoQualityPref)
|
screen.addPreference(videoQualityPref)
|
||||||
screen.addPreference(epTypePref)
|
screen.addPreference(epTypePref)
|
||||||
screen.addPreference(subLangPref)
|
screen.addPreference(subLangPref)
|
||||||
@ -424,6 +440,12 @@ class Zoro : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
private const val PREF_TYPE_TITLE = "Preferred episode type/mode"
|
private const val PREF_TYPE_TITLE = "Preferred episode type/mode"
|
||||||
private val PREF_TYPE_ENTRIES = arrayOf("sub", "dub")
|
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_KEY = "preferred_subLang"
|
||||||
private const val PREF_SUB_TITLE = "Preferred sub language"
|
private const val PREF_SUB_TITLE = "Preferred sub language"
|
||||||
private val PREF_SUB_ENTRIES = arrayOf(
|
private val PREF_SUB_ENTRIES = arrayOf(
|
||||||
|
Reference in New Issue
Block a user