Increase per-page limit when searching MAL manga list

This commit is contained in:
arkon 2020-12-31 10:58:40 -05:00
parent 591873a185
commit 139a589ad6

View File

@ -167,7 +167,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
return withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) {
val urlBuilder = "$baseApiUrl/users/@me/mangalist".toUri().buildUpon() val urlBuilder = "$baseApiUrl/users/@me/mangalist".toUri().buildUpon()
.appendQueryParameter("fields", "list_status") .appendQueryParameter("fields", "list_status")
.appendQueryParameter("limit", "25") .appendQueryParameter("limit", listPaginationAmount.toString())
if (offset > 0) { if (offset > 0) {
urlBuilder.appendQueryParameter("offset", offset.toString()) urlBuilder.appendQueryParameter("offset", offset.toString())
} }
@ -192,7 +192,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
} }
// Check next page if there's more // Check next page if there's more
!obj["paging"]!!.jsonObject["next"]?.jsonPrimitive?.contentOrNull.isNullOrBlank() -> { !obj["paging"]!!.jsonObject["next"]?.jsonPrimitive?.contentOrNull.isNullOrBlank() -> {
findListItem(track, offset + 25) findListItem(track, offset + listPaginationAmount)
} }
// No more pages to check, item wasn't found // No more pages to check, item wasn't found
else -> { else -> {
@ -220,6 +220,8 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
private const val baseOAuthUrl = "https://myanimelist.net/v1/oauth2" private const val baseOAuthUrl = "https://myanimelist.net/v1/oauth2"
private const val baseApiUrl = "https://api.myanimelist.net/v2" private const val baseApiUrl = "https://api.myanimelist.net/v2"
private const val listPaginationAmount = 250
private var codeVerifier: String = "" private var codeVerifier: String = ""
fun authUrl(): Uri = "$baseOAuthUrl/authorize".toUri().buildUpon() fun authUrl(): Uri = "$baseOAuthUrl/authorize".toUri().buildUpon()