WNACG: update URL and allow overrides (#15832)
This commit is contained in:
parent
3fa3f5eb9d
commit
50fe3eae7f
@ -5,7 +5,7 @@ ext {
|
||||
extName = 'WNACG'
|
||||
pkgNameSuffix = 'zh.wnacg'
|
||||
extClass = '.wnacg'
|
||||
extVersionCode = 11
|
||||
extVersionCode = 12
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
package eu.kanade.tachiyomi.extension.zh.wnacg
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.preference.EditTextPreference
|
||||
|
||||
private const val BASE_URL = "http://www.htmanga3.top"
|
||||
|
||||
fun getPreferencesInternal(context: Context, preferences: SharedPreferences) = arrayOf(
|
||||
EditTextPreference(context).apply {
|
||||
key = OVERRIDE_BASE_URL_PREF
|
||||
title = "网址"
|
||||
summary = "默认网址为:$BASE_URL\n" +
|
||||
"可以尝试的网址有:\n" +
|
||||
" http://www.htmanga4.top\n" +
|
||||
" http://www.htmanga5.top\n" +
|
||||
"可以到 www.wnacglink.top 查看最新网址。\n" +
|
||||
"如果默认网址失效,可以在此填写新的网址。重启生效。"
|
||||
|
||||
setOnPreferenceChangeListener { _, _ ->
|
||||
preferences.edit().putString(DEFAULT_BASE_URL_PREF, BASE_URL).apply()
|
||||
true
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
val SharedPreferences.baseUrl: String
|
||||
get() {
|
||||
val overrideBaseUrl = getString(OVERRIDE_BASE_URL_PREF, "")!!
|
||||
if (overrideBaseUrl.isNotEmpty()) {
|
||||
val defaultBaseUrl = getString(DEFAULT_BASE_URL_PREF, "")!!
|
||||
if (defaultBaseUrl == BASE_URL) return overrideBaseUrl
|
||||
// Outdated
|
||||
edit()
|
||||
.remove(OVERRIDE_BASE_URL_PREF)
|
||||
.remove(DEFAULT_BASE_URL_PREF)
|
||||
.apply()
|
||||
}
|
||||
return BASE_URL
|
||||
}
|
||||
|
||||
private const val OVERRIDE_BASE_URL_PREF = "overrideBaseUrl"
|
||||
private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl"
|
@ -1,6 +1,9 @@
|
||||
package eu.kanade.tachiyomi.extension.zh.wnacg
|
||||
|
||||
import android.app.Application
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
@ -14,14 +17,18 @@ import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
// URL can be found at https://www.wnacglink.top/
|
||||
class wnacg : ParsedHttpSource() {
|
||||
class wnacg : ParsedHttpSource(), ConfigurableSource {
|
||||
override val name = "紳士漫畫"
|
||||
override val baseUrl = "https://www.htcomic.top"
|
||||
override val lang = "zh"
|
||||
override val supportsLatest = false
|
||||
|
||||
private val preferences = Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)!!
|
||||
override val baseUrl = preferences.baseUrl
|
||||
|
||||
override fun popularMangaSelector() = ".gallary_item"
|
||||
override fun latestUpdatesSelector() = throw Exception("Not used")
|
||||
override fun searchMangaSelector() = popularMangaSelector()
|
||||
@ -146,4 +153,8 @@ class wnacg : ParsedHttpSource() {
|
||||
}
|
||||
|
||||
// <<< Filters <<<
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
getPreferencesInternal(screen.context, preferences).forEach(screen::addPreference)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user