From bbcae007e83b208df718f6b32c8d33c398a6dd51 Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Sun, 30 Jul 2023 00:52:43 +0800 Subject: [PATCH] vomic: update override URL (#17309) --- src/zh/vomic/build.gradle | 2 +- .../tachiyomi/extension/zh/vomic/Vomic.kt | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/zh/vomic/build.gradle b/src/zh/vomic/build.gradle index cde51a660..4ba950d95 100644 --- a/src/zh/vomic/build.gradle +++ b/src/zh/vomic/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'vomic' pkgNameSuffix = 'zh.vomic' extClass = '.Vomic' - extVersionCode = 3 + extVersionCode = 4 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/vomic/src/eu/kanade/tachiyomi/extension/zh/vomic/Vomic.kt b/src/zh/vomic/src/eu/kanade/tachiyomi/extension/zh/vomic/Vomic.kt index 39b59f080..a1bb24a2d 100644 --- a/src/zh/vomic/src/eu/kanade/tachiyomi/extension/zh/vomic/Vomic.kt +++ b/src/zh/vomic/src/eu/kanade/tachiyomi/extension/zh/vomic/Vomic.kt @@ -36,9 +36,22 @@ class Vomic : HttpSource(), ConfigurableSource { override val supportsLatest = false - override val baseUrl = "http://" + Injekt.get().getSharedPreferences("source_$id", 0x0000).getString(DOMAIN_PREF, DEFAULT_DOMAIN) + override val baseUrl: String - private val apiUrl = baseUrl + private val apiUrl: String + + init { + val domain = Injekt.get().getSharedPreferences("source_$id", 0x0000).getString(DOMAIN_PREF, DEFAULT_DOMAIN)!! + if (domain.startsWith("www.") || domain.startsWith("api.")) { + val tld = domain.substring(4) + baseUrl = "http://www.$tld" + apiUrl = "http://api.$tld" + } else { + val url = "http://$domain" + baseUrl = url + apiUrl = url + } + } override val client = network.client.newBuilder().addInterceptor { chain -> try { @@ -158,7 +171,7 @@ class Vomic : HttpSource(), ConfigurableSource { EditTextPreference(screen.context).apply { key = DOMAIN_PREF title = "网址" - summary = "不带 http:// 前缀,重启生效\n备选网址:119.23.243.52" + summary = "不带 http:// 前缀,重启生效\n备选网址:$DEFAULT_DOMAIN 或 119.23.243.52" setDefaultValue(DEFAULT_DOMAIN) }.let(screen::addPreference) }