From 4aa14a2cbdad2e1d3b4719d01eac6292e16744fc Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Fri, 26 Aug 2022 23:23:12 +0600 Subject: [PATCH] ZeroScans: Add rateLimit to chapter endpoint (#13208) Closes #13207 --- src/en/zeroscans/CHANGELOG.md | 4 ++++ src/en/zeroscans/build.gradle | 2 +- .../extension/en/zeroscans/ZeroScans.kt | 18 +++++++----------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/en/zeroscans/CHANGELOG.md b/src/en/zeroscans/CHANGELOG.md index 9782c5f50..2513d1e3a 100644 --- a/src/en/zeroscans/CHANGELOG.md +++ b/src/en/zeroscans/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.6 + +Add explicit rateLimit to api chapter endpoint + ## 1.2.5 Change to Main Domain from Beta one diff --git a/src/en/zeroscans/build.gradle b/src/en/zeroscans/build.gradle index 3f4f1cf88..6b92dd0a1 100644 --- a/src/en/zeroscans/build.gradle +++ b/src/en/zeroscans/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Zero Scans' pkgNameSuffix = 'en.zeroscans' extClass = '.ZeroScans' - extVersionCode = 5 + extVersionCode = 6 } apply from: "$rootDir/common.gradle" diff --git a/src/en/zeroscans/src/eu/kanade/tachiyomi/extension/en/zeroscans/ZeroScans.kt b/src/en/zeroscans/src/eu/kanade/tachiyomi/extension/en/zeroscans/ZeroScans.kt index 09f801341..9a9668036 100644 --- a/src/en/zeroscans/src/eu/kanade/tachiyomi/extension/en/zeroscans/ZeroScans.kt +++ b/src/en/zeroscans/src/eu/kanade/tachiyomi/extension/en/zeroscans/ZeroScans.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.extension.en.zeroscans import android.util.Log import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -152,20 +153,15 @@ class ZeroScans : HttpSource() { } override fun fetchChapterList(manga: SManga): Observable> { + // Paginated fragile endpoint so explicit rateLimit + val chapterListClient = client.newBuilder().rateLimit(1, 2).build() + val zsChapters = mutableListOf() + var page = 0 + var hasMoreResult = true try { - var page = 1 - - val response = client.newCall(zsChapterListRequest(page, manga)).execute() - - val zsChapterPage = zsChapterListParse(response) - - val zsChapters = zsChapterPage.chapters.toMutableList() - - var hasMoreResult = zsChapterPage.hasNextPage - while (hasMoreResult) { page++ - val newResponse = client.newCall(zsChapterListRequest(page, manga)).execute() + val newResponse = chapterListClient.newCall(zsChapterListRequest(page, manga)).execute() val newZSChapterPage = zsChapterListParse(newResponse) zsChapters.addAll(newZSChapterPage.chapters) hasMoreResult = newZSChapterPage.hasNextPage