Wolf.com (ko): add referer (#9187)

* wolf.com: add referer

* use util methods
This commit is contained in:
AwkwardPeak7 2025-06-13 09:40:12 +05:00 committed by Draff
parent 8a81d39865
commit e54cab639c
Signed by: Draff
GPG Key ID: E8A89F3211677653
3 changed files with 20 additions and 27 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Wolf.com'
extClass = '.WolfFactory'
extVersionCode = 2
extVersionCode = 3
isNsfw = true
}

View File

@ -1,3 +1,3 @@
package eu.kanade.tachiyomi.extension.ko.wolfdotcom
const val DEFAULT_DOMAIN_NUMBER = "363"
const val DEFAULT_DOMAIN_NUMBER = "393"

View File

@ -16,10 +16,10 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.asJsoup
import keiyoushi.utils.getPreferencesLazy
import keiyoushi.utils.parseAs
import keiyoushi.utils.toJsonString
import keiyoushi.utils.tryParse
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Interceptor
import okhttp3.Request
@ -27,10 +27,8 @@ import okhttp3.Response
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import rx.Observable
import uy.kohesive.injekt.injectLazy
import java.io.IOException
import java.net.URLEncoder
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.Locale
@ -52,10 +50,9 @@ open class Wolf(
override val client = network.cloudflareClient.newBuilder()
.addInterceptor(::domainNumberInterceptor)
.addNetworkInterceptor(::refererInterceptor)
.build()
private val json: Json by injectLazy()
private val preference: SharedPreferences by getPreferencesLazy()
override fun fetchPopularManga(page: Int): Observable<MangasPage> {
@ -262,32 +259,20 @@ open class Wolf(
return document.select(".webtoon-bbs-list a.view_open").map { el ->
val chapUrl = el.absUrl("href").toHttpUrl()
SChapter.create().apply {
url = json.encodeToString(
ChapterUrl(
chapUrl.queryParameter("toon")!!,
chapUrl.queryParameter("num")!!,
),
)
url = ChapterUrl(
chapUrl.queryParameter("toon")!!,
chapUrl.queryParameter("num")!!,
).toJsonString()
name = el.selectFirst(".subject")!!.ownText()
date_upload = el.selectFirst(".date")?.text().parseDate()
date_upload = dateFormat.tryParse(el.selectFirst(".date")?.text())
}
}
}
private val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH)
private fun String?.parseDate(): Long {
this ?: return 0L
return try {
dateFormat.parse(this)!!.time
} catch (_: ParseException) {
0L
}
}
override fun getChapterUrl(chapter: SChapter): String {
val chapUrl = json.decodeFromString<ChapterUrl>(chapter.url)
val chapUrl = chapter.url.parseAs<ChapterUrl>()
return baseUrl.toHttpUrl().newBuilder()
.addPathSegment(readerPath)
@ -389,6 +374,14 @@ open class Wolf(
private val domainRegex = Regex("""^https?://wfwf(\d+)\.com""")
private fun refererInterceptor(chain: Interceptor.Chain): Response {
val request = chain.request().newBuilder()
.header("Referer", "$baseUrl/")
.build()
return chain.proceed(request)
}
override fun imageUrlParse(response: Response): String {
throw UnsupportedOperationException()
}