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:
parent
3f92fc85a0
commit
e3b94d0c75
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'MayoTune'
|
extName = 'MayoTune'
|
||||||
extClass = '.MayoTune'
|
extClass = '.MayoTune'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
baseUrl = 'https://mayotune.xyz'
|
baseUrl = 'https://mayotune.xyz'
|
||||||
isNsfw = false
|
isNsfw = false
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ data class ChapterDto(
|
|||||||
@Contextual
|
@Contextual
|
||||||
private val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
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) {
|
fun getNumberStr(): String = if (this.number % 1 == 0f) {
|
||||||
this.number.toInt().toString()
|
this.number.toInt().toString()
|
||||||
@ -25,7 +26,7 @@ data class ChapterDto(
|
|||||||
this.number.toString()
|
this.number.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getChapterTitle(): String = if (!this.title.isEmpty()) {
|
fun getChapterTitle(): String = if (this.title.isNotBlank()) {
|
||||||
"Chapter ${this.getNumberStr()}: ${this.title}"
|
"Chapter ${this.getNumberStr()}: ${this.title}"
|
||||||
} else {
|
} else {
|
||||||
"Chapter ${this.getNumberStr()}"
|
"Chapter ${this.getNumberStr()}"
|
||||||
|
@ -9,6 +9,7 @@ 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.parseAs
|
import keiyoushi.utils.parseAs
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
@ -73,6 +74,11 @@ class MayoTune() : HttpSource() {
|
|||||||
return GET("$baseUrl/api/chapters", headers)
|
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
|
// Details
|
||||||
override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply {
|
override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
@ -111,12 +117,12 @@ class MayoTune() : HttpSource() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Pages
|
|
||||||
|
|
||||||
|
// Pages
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val document = response.asJsoup()
|
val chapter = response.parseAs<ChapterDto>()
|
||||||
return document.select("div.w-full > img").mapIndexed { index, img ->
|
return List(chapter.pageCount) { index ->
|
||||||
Page(index, imageUrl = img.absUrl("src"))
|
Page(index, imageUrl = "$baseUrl/api/manga/${chapter.id}/${index + 1}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user