Wolf.com (ko): add referer (#9187)
* wolf.com: add referer * use util methods
This commit is contained in:
parent
8a81d39865
commit
e54cab639c
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Wolf.com'
|
extName = 'Wolf.com'
|
||||||
extClass = '.WolfFactory'
|
extClass = '.WolfFactory'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
package eu.kanade.tachiyomi.extension.ko.wolfdotcom
|
package eu.kanade.tachiyomi.extension.ko.wolfdotcom
|
||||||
|
|
||||||
const val DEFAULT_DOMAIN_NUMBER = "363"
|
const val DEFAULT_DOMAIN_NUMBER = "393"
|
||||||
|
@ -16,10 +16,10 @@ import eu.kanade.tachiyomi.source.model.SManga
|
|||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import keiyoushi.utils.getPreferencesLazy
|
import keiyoushi.utils.getPreferencesLazy
|
||||||
|
import keiyoushi.utils.parseAs
|
||||||
|
import keiyoushi.utils.toJsonString
|
||||||
|
import keiyoushi.utils.tryParse
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.decodeFromString
|
|
||||||
import kotlinx.serialization.encodeToString
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
@ -27,10 +27,8 @@ import okhttp3.Response
|
|||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.injectLazy
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.text.ParseException
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@ -52,10 +50,9 @@ open class Wolf(
|
|||||||
|
|
||||||
override val client = network.cloudflareClient.newBuilder()
|
override val client = network.cloudflareClient.newBuilder()
|
||||||
.addInterceptor(::domainNumberInterceptor)
|
.addInterceptor(::domainNumberInterceptor)
|
||||||
|
.addNetworkInterceptor(::refererInterceptor)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private val json: Json by injectLazy()
|
|
||||||
|
|
||||||
private val preference: SharedPreferences by getPreferencesLazy()
|
private val preference: SharedPreferences by getPreferencesLazy()
|
||||||
|
|
||||||
override fun fetchPopularManga(page: Int): Observable<MangasPage> {
|
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 ->
|
return document.select(".webtoon-bbs-list a.view_open").map { el ->
|
||||||
val chapUrl = el.absUrl("href").toHttpUrl()
|
val chapUrl = el.absUrl("href").toHttpUrl()
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
url = json.encodeToString(
|
url = ChapterUrl(
|
||||||
ChapterUrl(
|
|
||||||
chapUrl.queryParameter("toon")!!,
|
chapUrl.queryParameter("toon")!!,
|
||||||
chapUrl.queryParameter("num")!!,
|
chapUrl.queryParameter("num")!!,
|
||||||
),
|
).toJsonString()
|
||||||
)
|
|
||||||
name = el.selectFirst(".subject")!!.ownText()
|
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 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 {
|
override fun getChapterUrl(chapter: SChapter): String {
|
||||||
val chapUrl = json.decodeFromString<ChapterUrl>(chapter.url)
|
val chapUrl = chapter.url.parseAs<ChapterUrl>()
|
||||||
|
|
||||||
return baseUrl.toHttpUrl().newBuilder()
|
return baseUrl.toHttpUrl().newBuilder()
|
||||||
.addPathSegment(readerPath)
|
.addPathSegment(readerPath)
|
||||||
@ -389,6 +374,14 @@ open class Wolf(
|
|||||||
|
|
||||||
private val domainRegex = Regex("""^https?://wfwf(\d+)\.com""")
|
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 {
|
override fun imageUrlParse(response: Response): String {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user