ZeroScans: Add rateLimit to chapter endpoint (#13208)

Closes #13207
This commit is contained in:
AntsyLich 2022-08-26 23:23:12 +06:00 committed by GitHub
parent 0d852ad121
commit 4aa14a2cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View File

@ -1,3 +1,7 @@
## 1.3.6
Add explicit rateLimit to api chapter endpoint
## 1.2.5
Change to Main Domain from Beta one

View File

@ -6,7 +6,7 @@ ext {
extName = 'Zero Scans'
pkgNameSuffix = 'en.zeroscans'
extClass = '.ZeroScans'
extVersionCode = 5
extVersionCode = 6
}
apply from: "$rootDir/common.gradle"

View File

@ -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<List<SChapter>> {
// Paginated fragile endpoint so explicit rateLimit
val chapterListClient = client.newBuilder().rateLimit(1, 2).build()
val zsChapters = mutableListOf<ZeroScansChapterDto>()
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