IkigaiMangas: Update chapterlist endpoint (#1771)

* Smh

* Update chapter list endpoint (paginated T-T)
This commit is contained in:
bapeey 2024-03-09 06:07:44 -05:00 committed by Draff
parent 2f4f7001ea
commit dcf9230a21
3 changed files with 29 additions and 9 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Ikigai Mangas' extName = 'Ikigai Mangas'
extClass = '.IkigaiMangas' extClass = '.IkigaiMangas'
extVersionCode = 2 extVersionCode = 3
isNsfw = true isNsfw = true
} }

View File

@ -24,7 +24,6 @@ class IkigaiMangas : HttpSource() {
override val baseUrl: String = "https://ikigaimangas.com" override val baseUrl: String = "https://ikigaimangas.com"
private val apiBaseUrl: String = "https://panel.ikigaimangas.com" private val apiBaseUrl: String = "https://panel.ikigaimangas.com"
private val pageViewerUrl: String = "https://ikigaitoon.com"
override val lang: String = "es" override val lang: String = "es"
override val name: String = "Ikigai Mangas" override val name: String = "Ikigai Mangas"
@ -114,21 +113,33 @@ class IkigaiMangas : HttpSource() {
return result.series.toSMangaDetails() return result.series.toSMangaDetails()
} }
override fun getChapterUrl(chapter: SChapter): String = pageViewerUrl + chapter.url override fun getChapterUrl(chapter: SChapter) = baseUrl + chapter.url
override fun chapterListRequest(manga: SManga): Request { override fun chapterListRequest(manga: SManga): Request {
val id = manga.url.substringAfterLast("#") val slug = manga.url.substringAfter("/series/comic-").substringBefore("#")
return GET("$apiBaseUrl/api/swf/series/$id/chapter-list") return GET("$apiBaseUrl/api/swf/series/$slug/chapters?page=1", headers)
} }
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
val result = json.decodeFromString<PayloadChaptersDto>(response.body.string()) val slug = response.request.url.toString()
return result.data.map { it.toSChapter(dateFormat) }.reversed() .substringAfter("/series/")
.substringBefore("/chapters")
var result = json.decodeFromString<PayloadChaptersDto>(response.body.string())
val mangas = mutableListOf<SChapter>()
mangas.addAll(result.data.map { it.toSChapter(dateFormat) })
var page = 2
while (result.meta.hasNextPage()) {
val newResponse = client.newCall(GET("$apiBaseUrl/api/swf/series/$slug/chapters?page=$page", headers)).execute()
result = json.decodeFromString<PayloadChaptersDto>(newResponse.body.string())
mangas.addAll(result.data.map { it.toSChapter(dateFormat) })
page++
}
return mangas
} }
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
val id = chapter.url.substringAfter("/capitulo/") val id = chapter.url.substringAfter("/capitulo/")
return GET("$apiBaseUrl/api/swf/chapters/$id") return GET("$apiBaseUrl/api/swf/chapters/$id", headers)
} }
override fun pageListParse(response: Response): List<Page> { override fun pageListParse(response: Response): List<Page> {

View File

@ -80,7 +80,8 @@ class PayloadSeriesDetailsDto(
@Serializable @Serializable
class PayloadChaptersDto( class PayloadChaptersDto(
var data: List<ChapterDto>, val data: List<ChapterDto>,
val meta: ChapterMetaDto,
) )
@Serializable @Serializable
@ -100,6 +101,14 @@ class ChapterDto(
} }
} }
@Serializable
class ChapterMetaDto(
@SerialName("current_page") private val currentPage: Int,
@SerialName("last_page") private val lastPage: Int,
) {
fun hasNextPage() = currentPage < lastPage
}
@Serializable @Serializable
class PayloadPagesDto( class PayloadPagesDto(
val chapter: PageDto, val chapter: PageDto,