From dcf9230a21436379abc302427b0163d345a9e229 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Sat, 9 Mar 2024 06:07:44 -0500 Subject: [PATCH] IkigaiMangas: Update chapterlist endpoint (#1771) * Smh * Update chapter list endpoint (paginated T-T) --- src/es/ikigaimangas/build.gradle | 2 +- .../extension/es/ikigaimangas/IkigaiMangas.kt | 25 +++++++++++++------ .../es/ikigaimangas/IkigaiMangasDto.kt | 11 +++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/es/ikigaimangas/build.gradle b/src/es/ikigaimangas/build.gradle index c2b395106..dc3c9cb4b 100644 --- a/src/es/ikigaimangas/build.gradle +++ b/src/es/ikigaimangas/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Ikigai Mangas' extClass = '.IkigaiMangas' - extVersionCode = 2 + extVersionCode = 3 isNsfw = true } diff --git a/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangas.kt b/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangas.kt index 3f94f73b1..c630d512b 100644 --- a/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangas.kt +++ b/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangas.kt @@ -24,7 +24,6 @@ class IkigaiMangas : HttpSource() { override val baseUrl: String = "https://ikigaimangas.com" private val apiBaseUrl: String = "https://panel.ikigaimangas.com" - private val pageViewerUrl: String = "https://ikigaitoon.com" override val lang: String = "es" override val name: String = "Ikigai Mangas" @@ -114,21 +113,33 @@ class IkigaiMangas : HttpSource() { 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 { - val id = manga.url.substringAfterLast("#") - return GET("$apiBaseUrl/api/swf/series/$id/chapter-list") + val slug = manga.url.substringAfter("/series/comic-").substringBefore("#") + return GET("$apiBaseUrl/api/swf/series/$slug/chapters?page=1", headers) } override fun chapterListParse(response: Response): List { - val result = json.decodeFromString(response.body.string()) - return result.data.map { it.toSChapter(dateFormat) }.reversed() + val slug = response.request.url.toString() + .substringAfter("/series/") + .substringBefore("/chapters") + var result = json.decodeFromString(response.body.string()) + val mangas = mutableListOf() + 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(newResponse.body.string()) + mangas.addAll(result.data.map { it.toSChapter(dateFormat) }) + page++ + } + return mangas } override fun pageListRequest(chapter: SChapter): Request { 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 { diff --git a/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangasDto.kt b/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangasDto.kt index 57edc0e0f..5451490f0 100644 --- a/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangasDto.kt +++ b/src/es/ikigaimangas/src/eu/kanade/tachiyomi/extension/es/ikigaimangas/IkigaiMangasDto.kt @@ -80,7 +80,8 @@ class PayloadSeriesDetailsDto( @Serializable class PayloadChaptersDto( - var data: List, + val data: List, + val meta: ChapterMetaDto, ) @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 class PayloadPagesDto( val chapter: PageDto,