Tappytoon: unblock page list (#9668)
This commit is contained in:
parent
55b2eac827
commit
e6a9517a44
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Tappytoon'
|
extName = 'Tappytoon'
|
||||||
pkgNameSuffix = 'all.tappytoon'
|
pkgNameSuffix = 'all.tappytoon'
|
||||||
extClass = '.TappytoonFactory'
|
extClass = '.TappytoonFactory'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,20 +32,14 @@ class Tappytoon(override val lang: String) : HttpSource() {
|
||||||
override val client = network.client.newBuilder().addInterceptor { chain ->
|
override val client = network.client.newBuilder().addInterceptor { chain ->
|
||||||
val res = chain.proceed(chain.request())
|
val res = chain.proceed(chain.request())
|
||||||
if (res.isSuccessful) return@addInterceptor res
|
if (res.isSuccessful) return@addInterceptor res
|
||||||
// Log JSON error if available
|
// Throw JSON error if available
|
||||||
if (res.headers["Content-Type"] == "application/json") {
|
if (res.headers["Content-Type"] == "application/json") {
|
||||||
res.body?.string()?.let(json::parseToJsonElement)?.run {
|
res.body?.string()?.let(json::parseToJsonElement)?.run {
|
||||||
val type = jsonObject["type"]?.jsonPrimitive?.content
|
throw Error(jsonObject["message"]!!.jsonPrimitive.content)
|
||||||
val msg = jsonObject["message"]!!.jsonPrimitive.content
|
|
||||||
Log.e("Tappytoon", "${type ?: "Error"} - $msg")
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
res.close()
|
|
||||||
}
|
|
||||||
when (val code = res.code) {
|
|
||||||
403 -> throw Error("You are not authorized to view this")
|
|
||||||
else -> throw Error("HTTP error $code")
|
|
||||||
}
|
}
|
||||||
|
res.close()
|
||||||
|
throw Error("HTTP error ${res.code}")
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
private val json by injectLazy<Json>()
|
private val json by injectLazy<Json>()
|
||||||
|
@ -60,7 +54,6 @@ class Tappytoon(override val lang: String) : HttpSource() {
|
||||||
val uuid = obj["X-Device-Uuid"]!!.jsonPrimitive.content
|
val uuid = obj["X-Device-Uuid"]!!.jsonPrimitive.content
|
||||||
headers.newBuilder()
|
headers.newBuilder()
|
||||||
.set("Origin", "https://www.tappytoon.com")
|
.set("Origin", "https://www.tappytoon.com")
|
||||||
.set("Referer", "https://www.tappytoon.com/")
|
|
||||||
.set("Accept-Language", lang)
|
.set("Accept-Language", lang)
|
||||||
.set("Authorization", auth)
|
.set("Authorization", auth)
|
||||||
.set("X-Device-Uuid", uuid)
|
.set("X-Device-Uuid", uuid)
|
||||||
|
@ -69,8 +62,9 @@ class Tappytoon(override val lang: String) : HttpSource() {
|
||||||
|
|
||||||
private var nextUrl: String? = null
|
private var nextUrl: String? = null
|
||||||
|
|
||||||
override fun headersBuilder() =
|
override fun headersBuilder() = super.headersBuilder()
|
||||||
super.headersBuilder().set("Referer", "https://www.tappytoon.com/")
|
.set("User-Agent", System.getProperty("http.agent")!!)
|
||||||
|
.set("Referer", "https://www.tappytoon.com/")
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int) =
|
override fun latestUpdatesRequest(page: Int) =
|
||||||
apiUrl.newBuilder().run {
|
apiUrl.newBuilder().run {
|
||||||
|
@ -118,8 +112,9 @@ class Tappytoon(override val lang: String) : HttpSource() {
|
||||||
|
|
||||||
override fun pageListRequest(chapter: SChapter) =
|
override fun pageListRequest(chapter: SChapter) =
|
||||||
apiUrl.newBuilder().run {
|
apiUrl.newBuilder().run {
|
||||||
addEncodedPathSegments("chapters/${chapter.url}")
|
addEncodedPathSegments("content-delivery/contents")
|
||||||
addEncodedQueryParameter("includes", "images")
|
addEncodedQueryParameter("chapterId", chapter.url)
|
||||||
|
addEncodedQueryParameter("variant", "high")
|
||||||
addEncodedQueryParameter("locale", lang)
|
addEncodedQueryParameter("locale", lang)
|
||||||
GET(toString(), apiHeaders)
|
GET(toString(), apiHeaders)
|
||||||
}
|
}
|
||||||
|
@ -165,7 +160,7 @@ class Tappytoon(override val lang: String) : HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response) =
|
override fun pageListParse(response: Response) =
|
||||||
response.parse<Images>().mapIndexed { idx, img ->
|
response.parse<Media>().mapIndexed { idx, img ->
|
||||||
Page(idx, "", img.toString())
|
Page(idx, "", img.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class Chapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class Images(private val images: List<URL>) : List<URL> by images
|
class Media(private val media: List<URL>) : List<URL> by media
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class URL(private val url: String) {
|
class URL(private val url: String) {
|
||||||
|
|
Loading…
Reference in New Issue