diff --git a/src/zh/bainianmanga/build.gradle b/src/zh/bainianmanga/build.gradle index b71d8728b..44fb337ed 100755 --- a/src/zh/bainianmanga/build.gradle +++ b/src/zh/bainianmanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Bainian Manhua' pkgNameSuffix = 'zh.bainianmanga' extClass = '.Bainian' - extVersionCode = 7 + extVersionCode = 8 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/bainianmanga/src/eu/kanade/tachiyomi/extension/zh/bainianmanga/Bainian.kt b/src/zh/bainianmanga/src/eu/kanade/tachiyomi/extension/zh/bainianmanga/Bainian.kt index 044eb4f7b..356ccc78d 100644 --- a/src/zh/bainianmanga/src/eu/kanade/tachiyomi/extension/zh/bainianmanga/Bainian.kt +++ b/src/zh/bainianmanga/src/eu/kanade/tachiyomi/extension/zh/bainianmanga/Bainian.kt @@ -16,7 +16,6 @@ import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.util.asJsoup -import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response import org.jsoup.nodes.Document @@ -41,7 +40,10 @@ class Bainian : ParsedHttpSource(), ConfigurableSource { private fun String.stripMirror() = if (useMirror) "/comic" + removePrefix("/manhuadaquan") else this private fun String.toMirror() = if (useMirror) baseUrl + "/manhuadaquan" + removePrefix("/comic") else baseUrl + this - override val client: OkHttpClient = network.client.newBuilder().rateLimit(2).build() + override val client = network.client.newBuilder() + .rateLimit(2) + .addInterceptor(MimeInterceptor) + .build() override fun popularMangaRequest(page: Int) = GET("$baseUrl/page/hot/$page.html", headers) override fun popularMangaNextPageSelector() = ".pagination > li:last-child > a" @@ -191,10 +193,6 @@ class Bainian : ParsedHttpSource(), ConfigurableSource { title = "使用镜像网站" summary = "使用“漫画全集”网站,重启生效" setDefaultValue(false) - setOnPreferenceChangeListener { _, newValue -> - preferences.edit().putBoolean(USE_MIRROR_PREF, newValue as Boolean).apply() - true - } }.let { screen.addPreference(it) } } diff --git a/src/zh/bainianmanga/src/eu/kanade/tachiyomi/extension/zh/bainianmanga/MimeInterceptor.kt b/src/zh/bainianmanga/src/eu/kanade/tachiyomi/extension/zh/bainianmanga/MimeInterceptor.kt new file mode 100644 index 000000000..ddddbc480 --- /dev/null +++ b/src/zh/bainianmanga/src/eu/kanade/tachiyomi/extension/zh/bainianmanga/MimeInterceptor.kt @@ -0,0 +1,22 @@ +package eu.kanade.tachiyomi.extension.zh.bainianmanga + +import okhttp3.Interceptor +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Response +import okhttp3.ResponseBody.Companion.asResponseBody + +object MimeInterceptor : Interceptor { + override fun intercept(chain: Interceptor.Chain): Response { + val request = chain.request() + val response = chain.proceed(request) + if (response.header("Content-Type") == "application/octet-stream" && + request.url.toString().contains(".jpg") + ) { + val body = response.body!!.source().asResponseBody(jpegMime) + return response.newBuilder().body(body).build() + } + return response + } + + private val jpegMime = "image/jpeg".toMediaType() +}