MayoTune: Build chapter page using API (#9157)

* Build manga page via API

* Split files

* Query chapters using `id`

* Use both query parameters
This commit is contained in:
Nam Anh 2025-06-13 11:39:31 +07:00 committed by Draff
parent 3f92fc85a0
commit e3b94d0c75
Signed by: Draff
GPG Key ID: E8A89F3211677653
3 changed files with 14 additions and 7 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'MayoTune'
extClass = '.MayoTune'
extVersionCode = 1
extVersionCode = 2
baseUrl = 'https://mayotune.xyz'
isNsfw = false
}

View File

@ -17,7 +17,8 @@ data class ChapterDto(
@Contextual
private val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.US)
fun getChapterURL(): String = "/chapter/${this.id}"
fun getChapterURL(): String =
"/api/chapters?id=$id&number=${this.getNumberStr()}"
fun getNumberStr(): String = if (this.number % 1 == 0f) {
this.number.toInt().toString()
@ -25,7 +26,7 @@ data class ChapterDto(
this.number.toString()
}
fun getChapterTitle(): String = if (!this.title.isEmpty()) {
fun getChapterTitle(): String = if (this.title.isNotBlank()) {
"Chapter ${this.getNumberStr()}: ${this.title}"
} else {
"Chapter ${this.getNumberStr()}"

View File

@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.asJsoup
import keiyoushi.utils.parseAs
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request
import okhttp3.Response
import rx.Observable
@ -73,6 +74,11 @@ class MayoTune() : HttpSource() {
return GET("$baseUrl/api/chapters", headers)
}
override fun getChapterUrl(chapter: SChapter): String {
val id = (baseUrl + chapter.url).toHttpUrl().queryParameter("id")
return "$baseUrl/chapter/$id"
}
// Details
override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply {
val document = response.asJsoup()
@ -111,12 +117,12 @@ class MayoTune() : HttpSource() {
}
}
}
// Pages
// Pages
override fun pageListParse(response: Response): List<Page> {
val document = response.asJsoup()
return document.select("div.w-full > img").mapIndexed { index, img ->
Page(index, imageUrl = img.absUrl("src"))
val chapter = response.parseAs<ChapterDto>()
return List(chapter.pageCount) { index ->
Page(index, imageUrl = "$baseUrl/api/manga/${chapter.id}/${index + 1}")
}
}