Jinman Tiantang: don't update mirrors on Cloudflare errors (#17184)

This commit is contained in:
stevenyomi 2023-07-21 10:05:54 +08:00 committed by GitHub
parent 832ace3eff
commit d6b88c5ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Jinman Tiantang'
pkgNameSuffix = 'zh.jinmantiantang'
extClass = '.Jinmantiantang'
extVersionCode = 37
extVersionCode = 38
isNsfw = true
}

View File

@ -48,7 +48,7 @@ class Jinmantiantang : ParsedHttpSource(), ConfigurableSource {
preferences.getString(MAINSITE_RATELIMIT_PREF, MAINSITE_RATELIMIT_PREF_DEFAULT)!!.toInt(),
preferences.getString(MAINSITE_RATELIMIT_PERIOD, MAINSITE_RATELIMIT_PERIOD_DEFAULT)!!.toLong(),
)
.addInterceptor(updateUrlInterceptor)
.apply { interceptors().add(0, updateUrlInterceptor) }
.addInterceptor(ScrambledImageInterceptor).build()
// 点击量排序(人气)

View File

@ -93,7 +93,7 @@ private val SITE_ENTRIES_ARRAY get() = arrayOf(
"jmcomic1.me",
)
private const val DEFAULT_LIST = "jm-comic2.org,jm-comic3.org,jm-comic1.org"
private const val DEFAULT_LIST = "jm-comic3.art,jm-comic1.art,jm-comic2.ark"
private const val DEFAULT_LIST_PREF = "defaultBaseUrlList"
private const val URL_LIST_PREF = "baseUrlList"
@ -132,12 +132,12 @@ class UpdateUrlInterceptor(private val preferences: SharedPreferences) : Interce
response.close()
Result.success(response)
} catch (e: Throwable) {
if (chain.call().isCanceled()) throw e
if (chain.call().isCanceled() || e.message?.contains("Cloudflare") == true) throw e
Result.failure(e)
}
if (isUpdated || updateUrl(chain)) {
throw IOException("镜像网址已自动更新,请在插件设置中选择合适的镜像网址并重启应用")
throw IOException("镜像网址已自动更新,请在插件设置中选择合适的镜像网址并重启应用(如果反复提示,可能是服务器故障)")
}
return failedResponse.getOrThrow()
}