From 471a45ba959e90498db4ef27b8f6f066efe28576 Mon Sep 17 00:00:00 2001 From: Vetle Ledaal Date: Mon, 22 Aug 2022 17:31:19 +0200 Subject: [PATCH] NHentai: set User-Agent to get past Cloudflare (#13130) --- src/all/nhentai/build.gradle | 2 +- .../eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/all/nhentai/build.gradle b/src/all/nhentai/build.gradle index 78bc4d6dc..1ca806d4a 100644 --- a/src/all/nhentai/build.gradle +++ b/src/all/nhentai/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'NHentai' pkgNameSuffix = 'all.nhentai' extClass = '.NHFactory' - extVersionCode = 35 + extVersionCode = 36 isNsfw = true } diff --git a/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt b/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt index 5a00b5530..21becec20 100644 --- a/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt +++ b/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt @@ -20,6 +20,7 @@ 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.Headers import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.OkHttpClient import okhttp3.Request @@ -47,6 +48,10 @@ open class NHentai( .rateLimit(4) .build() + override fun headersBuilder(): Headers.Builder = + super.headersBuilder() + .set("User-Agent", USER_AGENT) + private val preferences: SharedPreferences by lazy { Injekt.get().getSharedPreferences("source_$id", 0x0000) } @@ -305,5 +310,6 @@ open class NHentai( companion object { const val PREFIX_ID_SEARCH = "id:" private const val TITLE_PREF = "Display manga title as:" + private const val USER_AGENT = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Mobile Safari/537.36" } }