Oglaf - fix pages (#2836)

Oglaf - fix pages
This commit is contained in:
Mike 2020-04-26 09:49:25 -04:00 committed by GitHub
parent 3ded3086a9
commit be986aa1fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Oglaf'
pkgNameSuffix = 'en.oglaf'
extClass = '.Oglaf'
extVersionCode = 2
extVersionCode = 3
libVersion = '1.2'
}

View File

@ -1,14 +1,15 @@
package eu.kanade.tachiyomi.extension.en.oglaf
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Request
import okhttp3.Response
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import rx.Observable
@ -60,14 +61,16 @@ class Oglaf : ParsedHttpSource() {
override fun pageListParse(document: Document): List<Page> {
val urlRegex = """/.*/\d*/""".toRegex()
val imageUrl = document.select("img#strip").attr("src")
val pages = mutableListOf<Page>()
pages.add(Page(0, "", imageUrl))
val next = document.select("a[rel=next]").attr("href")
if (urlRegex.matches(next)) {
val nextPage = Jsoup.connect(baseUrl + next).get()
pages.addAll(pageListParse(nextPage))
fun addPage(document: Document) {
pages.add(Page(pages.size, "", document.select("img#strip").attr("abs:src")))
val next = document.select("a[rel=next]").attr("href")
if (urlRegex.matches(next)) addPage(client.newCall(GET(baseUrl + next, headers)).execute().asJsoup())
}
addPage(document)
return pages
}