[Ru]Mangapoisk. Fix pagination on page list (#6921)

This commit is contained in:
Pavka 2021-05-09 21:48:01 +03:00 committed by GitHub
parent 8980f5382f
commit 996fe078e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaPoisk'
pkgNameSuffix = 'ru.mangapoisk'
extClass = '.MangaPoisk'
extVersionCode = 2
extVersionCode = 3
libVersion = '1.2'
}

View File

@ -129,11 +129,20 @@ class MangaPoisk : ParsedHttpSource() {
else -> SManga.UNKNOWN
}
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
return client.newCall(chapterListRequest(manga))
.asObservableSuccess()
.map { response ->
chapterListParse(response, manga)
val pageItems = client.newCall(chapterListRequest(manga)).execute().asJsoup().select("li.page-item")
val pages = mutableListOf(1)
if (pageItems.lastIndex > 1) {
val lastPage = pageItems[pageItems.lastIndex - 1].text().toInt()
for (i in 2.rangeTo(lastPage)) {
pages.add(i)
}
}
return Observable.just(
pages.flatMap { page ->
chapterListParse(client.newCall(chapterPageListRequest(manga, page)).execute(), manga)
}
)
}
private fun chapterListParse(response: Response, manga: SManga): List<SChapter> {
val document = response.asJsoup()
@ -142,6 +151,11 @@ class MangaPoisk : ParsedHttpSource() {
override fun chapterListRequest(manga: SManga): Request {
return GET("$baseUrl${manga.url}/chaptersList", headers)
}
private fun chapterPageListRequest(manga: SManga, page: Int): Request {
return GET("$baseUrl${manga.url}/chaptersList?page=$page", headers)
}
override fun chapterListSelector() = ".chapter-item"
private fun chapterFromElement(element: Element, manga: SManga): SChapter {