diff --git a/src/all/mangaplus/build.gradle b/src/all/mangaplus/build.gradle index 54ccf1785..3df450203 100644 --- a/src/all/mangaplus/build.gradle +++ b/src/all/mangaplus/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'MANGA Plus by SHUEISHA' pkgNameSuffix = 'all.mangaplus' extClass = '.MangaPlusFactory' - extVersionCode = 48 + extVersionCode = 49 } dependencies { diff --git a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt index cbac52e66..378f1951a 100644 --- a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt +++ b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt @@ -81,6 +81,7 @@ class MangaPlus( override fun popularMangaRequest(page: Int): Request { val newHeaders = headersBuilder() .set("Referer", "$baseUrl/manga_list/hot") + .set("X-Page", page.toString()) .build() return GET("$API_URL/title_list/ranking?format=json", newHeaders) @@ -98,7 +99,13 @@ class MangaPlus( titleCache = titleList.associateBy(Title::titleId) - return MangasPage(titleList.map(Title::toSManga), hasNextPage = false) + val page = response.request.headers["X-Page"]!!.toInt() + val pageList = titleList + .drop((page - 1) * LISTING_ITEMS_PER_PAGE) + .take(LISTING_ITEMS_PER_PAGE) + val hasNextPage = (page + 1) * LISTING_ITEMS_PER_PAGE <= titleList.size + + return MangasPage(pageList.map(Title::toSManga), hasNextPage) } override fun latestUpdatesRequest(page: Int): Request { @@ -146,6 +153,7 @@ class MangaPlus( val newHeaders = headersBuilder() .set("Referer", "$baseUrl/manga_list/all") + .set("X-Page", page.toString()) .build() val apiUrl = "$API_URL/title_list/allV2".toHttpUrl().newBuilder() @@ -205,7 +213,13 @@ class MangaPlus( title.author.orEmpty().contains(filter, ignoreCase = true) } - return MangasPage(searchResults.map(Title::toSManga), hasNextPage = false) + val page = response.request.headers["X-Page"]!!.toInt() + val pageList = searchResults + .drop((page - 1) * LISTING_ITEMS_PER_PAGE) + .take(LISTING_ITEMS_PER_PAGE) + val hasNextPage = (page + 1) * LISTING_ITEMS_PER_PAGE <= searchResults.size + + return MangasPage(pageList.map(Title::toSManga), hasNextPage) } // Remove the '#' and map to the new url format used in website. @@ -413,7 +427,9 @@ class MangaPlus( companion object { private const val API_URL = "https://jumpg-webapi.tokyo-cdn.com/api" private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + - "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" + + private const val LISTING_ITEMS_PER_PAGE = 20 private const val QUALITY_PREF_KEY = "imageResolution" private val QUALITY_PREF_ENTRY_VALUES = arrayOf("low", "high", "super_high")