Jinmantiantang: fix date parsing and optimize preferences (#12391)
This commit is contained in:
parent
3f57c7f4c8
commit
e399317bf9
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Jinmantiantang'
|
extName = 'Jinmantiantang'
|
||||||
pkgNameSuffix = 'zh.jinmantiantang'
|
pkgNameSuffix = 'zh.jinmantiantang'
|
||||||
extClass = '.Jinmantiantang'
|
extClass = '.Jinmantiantang'
|
||||||
extVersionCode = 28
|
extVersionCode = 29
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
|
||||||
private val preferences: SharedPreferences =
|
private val preferences: SharedPreferences =
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
|
||||||
override val baseUrl: String = "https://" +
|
override val baseUrl: String = "https://" + preferences.getString(USE_MIRROR_URL_PREF, "0")!!
|
||||||
SITE_ENTRIES_ARRAY[preferences.getString(USE_MIRROR_URL_PREF, "0")!!.toInt()]
|
.toInt().coerceAtMost(SITE_ENTRIES_ARRAY.size - 1).let { SITE_ENTRIES_ARRAY[it] }
|
||||||
|
|
||||||
// 处理URL请求
|
// 处理URL请求
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
@ -233,7 +233,7 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
|
||||||
val singleChapter = SChapter.create().apply {
|
val singleChapter = SChapter.create().apply {
|
||||||
name = "单章节"
|
name = "单章节"
|
||||||
url = document.select("a[class=col btn btn-primary dropdown-toggle reading]").attr("href")
|
url = document.select("a[class=col btn btn-primary dropdown-toggle reading]").attr("href")
|
||||||
date_upload = sdf.parse(document.select("div[itemprop='datePublished']").attr("content"))?.time
|
date_upload = sdf.parse(document.select("[itemprop=datePublished]").last().attr("content"))?.time
|
||||||
?: 0
|
?: 0
|
||||||
}
|
}
|
||||||
return listOf(singleChapter)
|
return listOf(singleChapter)
|
||||||
|
@ -397,9 +397,6 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
|
||||||
summary = MAINSITE_RATELIMIT_PREF_SUMMARY
|
summary = MAINSITE_RATELIMIT_PREF_SUMMARY
|
||||||
|
|
||||||
setDefaultValue(MAINSITE_RATELIMIT_PREF_DEFAULT)
|
setDefaultValue(MAINSITE_RATELIMIT_PREF_DEFAULT)
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
preferences.edit().putString(MAINSITE_RATELIMIT_PREF, newValue as String).commit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val mainSiteRateLimitPeriodPreference = ListPreference(screen.context).apply {
|
val mainSiteRateLimitPeriodPreference = ListPreference(screen.context).apply {
|
||||||
|
@ -410,9 +407,6 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
|
||||||
summary = MAINSITE_RATELIMIT_PERIOD_SUMMARY
|
summary = MAINSITE_RATELIMIT_PERIOD_SUMMARY
|
||||||
|
|
||||||
setDefaultValue(MAINSITE_RATELIMIT_PERIOD_DEFAULT)
|
setDefaultValue(MAINSITE_RATELIMIT_PERIOD_DEFAULT)
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
preferences.edit().putString(MAINSITE_RATELIMIT_PERIOD, newValue as String).commit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val mirrorURLPreference = ListPreference(screen.context).apply {
|
val mirrorURLPreference = ListPreference(screen.context).apply {
|
||||||
|
@ -423,9 +417,6 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
|
||||||
summary = USE_MIRROR_URL_PREF_SUMMARY
|
summary = USE_MIRROR_URL_PREF_SUMMARY
|
||||||
|
|
||||||
setDefaultValue("0")
|
setDefaultValue("0")
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
preferences.edit().putString(USE_MIRROR_URL_PREF, newValue as String).commit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val blockGenrePreference = EditTextPreference(screen.context).apply {
|
val blockGenrePreference = EditTextPreference(screen.context).apply {
|
||||||
|
@ -433,9 +424,6 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
|
||||||
title = BLOCK_PREF_TITLE
|
title = BLOCK_PREF_TITLE
|
||||||
setDefaultValue(BLOCK_PREF_DEFAULT)
|
setDefaultValue(BLOCK_PREF_DEFAULT)
|
||||||
dialogTitle = BLOCK_PREF_DIALOGTITLE
|
dialogTitle = BLOCK_PREF_DIALOGTITLE
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
preferences.edit().putString(BLOCK_PREF, newValue as String).commit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
screen.addPreference(mainSiteRateLimitPreference)
|
screen.addPreference(mainSiteRateLimitPreference)
|
||||||
|
@ -472,15 +460,15 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
|
||||||
|
|
||||||
private val SITE_ENTRIES_ARRAY_DESCRIPTION = arrayOf(
|
private val SITE_ENTRIES_ARRAY_DESCRIPTION = arrayOf(
|
||||||
"主站", "海外分流",
|
"主站", "海外分流",
|
||||||
"中国大陆总站", "中国大陆分流1", "中国大陆分流1"
|
"中国大陆总站", "中国大陆分流"
|
||||||
)
|
)
|
||||||
private val SITE_ENTRIES_ARRAY_VALUE = (0..4).map { i -> i.toString() }.toTypedArray()
|
private val SITE_ENTRIES_ARRAY_VALUE = arrayOf("0", "1", "2", "3")
|
||||||
|
|
||||||
// List is based on https://jmcomic.bet/
|
// List is based on https://jmcomic.bet/
|
||||||
// Please also update AndroidManifest
|
// Please also update AndroidManifest
|
||||||
private val SITE_ENTRIES_ARRAY = arrayOf(
|
private val SITE_ENTRIES_ARRAY = arrayOf(
|
||||||
DEFAULT_SITE, "18comic.org",
|
DEFAULT_SITE, "18comic.org",
|
||||||
"jmcomic.asia", "jmcomic.city", "jmcomic.city"
|
"jmcomic.asia", "jmcomic.city"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue