MangaTaro: fix type tag and count views (#11358)
* remove post type from genres seems to always be manga * count views * lint and bump * add type if others not in tags * set
This commit is contained in:
parent
68b70d54d9
commit
05817f38c2
@ -1,7 +1,7 @@
|
||||
ext {
|
||||
extName = 'MangaTaro'
|
||||
extClass = '.MangaTaro'
|
||||
extVersionCode = 4
|
||||
extVersionCode = 5
|
||||
isNsfw = false
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ class BrowseManga(
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class MangaUrl(
|
||||
data class MangaUrl(
|
||||
val id: String,
|
||||
val slug: String,
|
||||
)
|
||||
@ -79,20 +79,10 @@ class MangaDetails(
|
||||
val slug: String,
|
||||
val title: Rendered,
|
||||
val content: Rendered,
|
||||
@SerialName("class_list")
|
||||
private val classList: List<String>,
|
||||
val type: String,
|
||||
@SerialName("_embedded")
|
||||
val embedded: Embedded,
|
||||
) {
|
||||
fun getFromClassList(type: String): List<String> {
|
||||
return classList.filter { it.startsWith("$type-") }
|
||||
.map {
|
||||
it.substringAfter("$type-")
|
||||
.split("-")
|
||||
.joinToString(" ") { word -> word.replaceFirstChar { it.titlecase() } }
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class Embedded(
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.extension.en.mangataro
|
||||
|
||||
import android.util.Log
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
@ -15,11 +16,14 @@ import keiyoushi.utils.firstInstance
|
||||
import keiyoushi.utils.firstInstanceOrNull
|
||||
import keiyoushi.utils.parseAs
|
||||
import keiyoushi.utils.toJsonString
|
||||
import okhttp3.Callback
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.Response
|
||||
import okhttp3.internal.closeQuietly
|
||||
import okio.IOException
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.parser.Parser
|
||||
import rx.Observable
|
||||
@ -210,7 +214,9 @@ class MangaTaro : HttpSource() {
|
||||
description = Jsoup.parseBodyFragment(data.content.rendered).wholeText()
|
||||
genre = buildSet {
|
||||
addAll(data.embedded.getTerms("post_tag"))
|
||||
addAll(data.getFromClassList("type"))
|
||||
if (listOf("Manhwa", "Manhua", "Manga").none { it -> this.contains(it) }) {
|
||||
add(data.type)
|
||||
}
|
||||
}.joinToString()
|
||||
author = data.embedded.getTerms("manga_author").joinToString()
|
||||
status = response.request.url.fragment!!.toInt()
|
||||
@ -226,10 +232,14 @@ class MangaTaro : HttpSource() {
|
||||
}
|
||||
|
||||
override fun chapterListRequest(manga: SManga): Request {
|
||||
return GET(getMangaUrl(manga), headers)
|
||||
val (id, slug) = manga.url.parseAs<MangaUrl>()
|
||||
|
||||
return GET("$baseUrl/manga/$slug#$id", headers)
|
||||
}
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
countViews(response.request.url.fragment!!)
|
||||
|
||||
val document = response.asJsoup()
|
||||
val placeholders = listOf("", "N/A", "—")
|
||||
var hasScanlator = false
|
||||
@ -303,6 +313,25 @@ class MangaTaro : HttpSource() {
|
||||
|
||||
private val relativeDateRegex = Regex("""(\d+)(h|d|w|mo|y) ago""")
|
||||
|
||||
private fun countViews(postId: String) {
|
||||
val payload = """{"post_id":"$postId"}"""
|
||||
.toRequestBody("application/json".toMediaType())
|
||||
val url = "$baseUrl/wp-json/pviews/v1/increment/"
|
||||
val request = POST(url, headers, payload)
|
||||
|
||||
client.newCall(request)
|
||||
.enqueue(
|
||||
object : Callback {
|
||||
override fun onResponse(call: okhttp3.Call, response: Response) {
|
||||
response.closeQuietly()
|
||||
}
|
||||
override fun onFailure(call: okhttp3.Call, e: IOException) {
|
||||
Log.e(name, "Failed to count views", e)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
override fun imageUrlParse(response: Response): String {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user