From dabe87193a0835d5dbb6989cb7cb55f44d72759f Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Thu, 1 Feb 2024 17:03:22 +0000 Subject: [PATCH] Set desktop UA and update URL for some Chinese sources (#880) * Set desktop UA and update URL for some Chinese sources * Update linked websites --- src/zh/mangabz/AndroidManifest.xml | 4 ++++ src/zh/mangabz/build.gradle | 2 +- .../tachiyomi/extension/zh/mangabz/Mangabz.kt | 15 +++++++++++++-- .../extension/zh/mangabz/MangabzTheme.kt | 2 -- .../tachiyomi/extension/zh/mangabz/Preferences.kt | 1 + src/zh/wnacg/build.gradle | 2 +- .../kanade/tachiyomi/extension/zh/wnacg/wnacg.kt | 4 ++-- src/zh/zerobyw/build.gradle | 2 +- .../tachiyomi/extension/zh/zerobyw/UpdateUrl.kt | 4 ++-- .../tachiyomi/extension/zh/zerobyw/Zerobyw.kt | 4 ++++ 10 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/zh/mangabz/AndroidManifest.xml b/src/zh/mangabz/AndroidManifest.xml index 3e4f471f9..74ba0abe2 100644 --- a/src/zh/mangabz/AndroidManifest.xml +++ b/src/zh/mangabz/AndroidManifest.xml @@ -21,6 +21,10 @@ android:host="xmanhua.com" android:pathPattern="/..*" android:scheme="https" /> + diff --git a/src/zh/mangabz/build.gradle b/src/zh/mangabz/build.gradle index 974507e7a..ef719ac8c 100644 --- a/src/zh/mangabz/build.gradle +++ b/src/zh/mangabz/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Mangabz' extClass = '.Mangabz' - extVersionCode = 7 + extVersionCode = 8 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Mangabz.kt b/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Mangabz.kt index 25fa4148f..c890538f7 100644 --- a/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Mangabz.kt +++ b/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Mangabz.kt @@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga +import okhttp3.Headers import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.OkHttpClient import okhttp3.Response @@ -26,7 +27,7 @@ import uy.kohesive.injekt.api.get class Mangabz : MangabzTheme("Mangabz"), ConfigurableSource { - override val baseUrl: String + private val _baseUrl: String override val client: OkHttpClient private val urlSuffix: String @@ -34,7 +35,7 @@ class Mangabz : MangabzTheme("Mangabz"), ConfigurableSource { init { val preferences = Injekt.get().getSharedPreferences("source_$id", 0x0000) val mirror = preferences.mirror - baseUrl = "https://" + mirror.domain + _baseUrl = "https://" + mirror.domain urlSuffix = mirror.urlSuffix val cookieInterceptor = CookieInterceptor(mirror.domain, mirror.langCookie, preferences.lang) @@ -44,6 +45,16 @@ class Mangabz : MangabzTheme("Mangabz"), ConfigurableSource { .build() } + private val isCi = System.getenv("CI") == "true" + override val baseUrl get() = when { + isCi -> MIRRORS.joinToString("#, ") { "https://$it" } + else -> _baseUrl + } + + override fun headersBuilder() = Headers.Builder() + .add("Referer", _baseUrl) + .add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0") + private fun SManga.stripMirror() = apply { val old = url url = buildString(old.length) { diff --git a/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/MangabzTheme.kt b/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/MangabzTheme.kt index 21d1f30cd..66b9b7c35 100644 --- a/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/MangabzTheme.kt +++ b/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/MangabzTheme.kt @@ -24,8 +24,6 @@ abstract class MangabzTheme( override val supportsLatest = true - override fun headersBuilder() = super.headersBuilder().add("Referer", baseUrl) - override fun popularMangaRequest(page: Int) = GET("$baseUrl/manga-list-p$page/", headers) override fun popularMangaParse(response: Response) = searchMangaParse(response) diff --git a/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Preferences.kt b/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Preferences.kt index 3fd10ee7f..72c3ef76e 100644 --- a/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Preferences.kt +++ b/src/zh/mangabz/src/eu/kanade/tachiyomi/extension/zh/mangabz/Preferences.kt @@ -47,6 +47,7 @@ val MIRRORS get() = arrayOf( Mirror("mangabz.com", "bz/", "mangabz_lang"), Mirror("xmanhua.com", "xm/", "xmanhua_lang"), + Mirror("yymanhua.com", "yy/", "yymanhua_lang"), ) class Mirror( diff --git a/src/zh/wnacg/build.gradle b/src/zh/wnacg/build.gradle index 396d579c4..689d6ea60 100644 --- a/src/zh/wnacg/build.gradle +++ b/src/zh/wnacg/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'WNACG' extClass = '.wnacg' - extVersionCode = 14 + extVersionCode = 15 isNsfw = true } diff --git a/src/zh/wnacg/src/eu/kanade/tachiyomi/extension/zh/wnacg/wnacg.kt b/src/zh/wnacg/src/eu/kanade/tachiyomi/extension/zh/wnacg/wnacg.kt index 5a07b00e7..33f83c94f 100644 --- a/src/zh/wnacg/src/eu/kanade/tachiyomi/extension/zh/wnacg/wnacg.kt +++ b/src/zh/wnacg/src/eu/kanade/tachiyomi/extension/zh/wnacg/wnacg.kt @@ -17,7 +17,6 @@ import org.jsoup.nodes.Document import org.jsoup.nodes.Element import rx.Observable -// URL can be found at https://www.wnacglink.top/ class wnacg : ParsedHttpSource(), ConfigurableSource { override val name = "紳士漫畫" override val lang = "zh" @@ -67,7 +66,8 @@ class wnacg : ParsedHttpSource(), ConfigurableSource { return GET(builder.build(), headers) } - override fun headersBuilder(): Headers.Builder = super.headersBuilder() + override fun headersBuilder() = Headers.Builder() + .add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0") .set("referer", baseUrl) .set("sec-fetch-mode", "no-cors") .set("sec-fetch-site", "cross-site") diff --git a/src/zh/zerobyw/build.gradle b/src/zh/zerobyw/build.gradle index 6c243afc0..79a7fc4a8 100644 --- a/src/zh/zerobyw/build.gradle +++ b/src/zh/zerobyw/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Zerobyw' extClass = '.Zerobyw' - extVersionCode = 17 + extVersionCode = 18 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/UpdateUrl.kt b/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/UpdateUrl.kt index d4cde2bfa..88f6fc217 100644 --- a/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/UpdateUrl.kt +++ b/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/UpdateUrl.kt @@ -11,7 +11,7 @@ import okhttp3.OkHttpClient import okhttp3.Response import java.io.IOException -private const val DEFAULT_BASE_URL = "http://www.zerobyw007.com" +private const val DEFAULT_BASE_URL = "http://www.zerobywgbo2.com" private const val BASE_URL_PREF = "ZEROBYW_BASEURL" private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl" @@ -34,7 +34,7 @@ fun getBaseUrlPreference(context: Context) = EditTextPreference(context).apply { key = BASE_URL_PREF title = "网址" summary = "正常情况下会自动更新。" + - "如果出现错误,请在 GitHub 上报告,并且可以在 GitHub 仓库 zerozzz123456/1 找到最新网址手动填写。" + + "如果出现错误,请在 GitHub 上报告,并且可以在 https://zerobyw.github.io/ 找到最新网址手动填写。" + "填写时按照 $DEFAULT_BASE_URL 格式。" setDefaultValue(DEFAULT_BASE_URL) diff --git a/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/Zerobyw.kt b/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/Zerobyw.kt index d9b41c6f4..96d54d1db 100644 --- a/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/Zerobyw.kt +++ b/src/zh/zerobyw/src/eu/kanade/tachiyomi/extension/zh/zerobyw/Zerobyw.kt @@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import okhttp3.Headers import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.Request import okhttp3.Response @@ -38,6 +39,9 @@ class Zerobyw : ParsedHttpSource(), ConfigurableSource { private val isCi = System.getenv("CI") == "true" + override fun headersBuilder() = Headers.Builder() + .add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0") + // Popular // Website does not provide popular manga, this is actually latest manga