Paginate popular and search responses in MangaPlus (#18719)
* Paginate popular and search responses in MangaPlus. * Remove Log debugging info.
This commit is contained in:
parent
ae81ee5ded
commit
afba087eb4
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'MANGA Plus by SHUEISHA'
|
extName = 'MANGA Plus by SHUEISHA'
|
||||||
pkgNameSuffix = 'all.mangaplus'
|
pkgNameSuffix = 'all.mangaplus'
|
||||||
extClass = '.MangaPlusFactory'
|
extClass = '.MangaPlusFactory'
|
||||||
extVersionCode = 48
|
extVersionCode = 49
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -81,6 +81,7 @@ class MangaPlus(
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
val newHeaders = headersBuilder()
|
val newHeaders = headersBuilder()
|
||||||
.set("Referer", "$baseUrl/manga_list/hot")
|
.set("Referer", "$baseUrl/manga_list/hot")
|
||||||
|
.set("X-Page", page.toString())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return GET("$API_URL/title_list/ranking?format=json", newHeaders)
|
return GET("$API_URL/title_list/ranking?format=json", newHeaders)
|
||||||
|
@ -98,7 +99,13 @@ class MangaPlus(
|
||||||
|
|
||||||
titleCache = titleList.associateBy(Title::titleId)
|
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 {
|
override fun latestUpdatesRequest(page: Int): Request {
|
||||||
|
@ -146,6 +153,7 @@ class MangaPlus(
|
||||||
|
|
||||||
val newHeaders = headersBuilder()
|
val newHeaders = headersBuilder()
|
||||||
.set("Referer", "$baseUrl/manga_list/all")
|
.set("Referer", "$baseUrl/manga_list/all")
|
||||||
|
.set("X-Page", page.toString())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val apiUrl = "$API_URL/title_list/allV2".toHttpUrl().newBuilder()
|
val apiUrl = "$API_URL/title_list/allV2".toHttpUrl().newBuilder()
|
||||||
|
@ -205,7 +213,13 @@ class MangaPlus(
|
||||||
title.author.orEmpty().contains(filter, ignoreCase = true)
|
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.
|
// Remove the '#' and map to the new url format used in website.
|
||||||
|
@ -413,7 +427,9 @@ class MangaPlus(
|
||||||
companion object {
|
companion object {
|
||||||
private const val API_URL = "https://jumpg-webapi.tokyo-cdn.com/api"
|
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) " +
|
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 const val QUALITY_PREF_KEY = "imageResolution"
|
||||||
private val QUALITY_PREF_ENTRY_VALUES = arrayOf("low", "high", "super_high")
|
private val QUALITY_PREF_ENTRY_VALUES = arrayOf("low", "high", "super_high")
|
||||||
|
|
Loading…
Reference in New Issue