FRScan: Fix pages loading (#3230)

* Fix pages loading

* Change group name

* Remove variable

* Remove parseAs function and add page url
This commit is contained in:
Chopper 2024-05-27 06:05:58 -03:00 committed by GitHub
parent de5d088129
commit 8dde53ea23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.FRScan'
themePkg = 'madara'
baseUrl = 'https://fr-scan.com'
overrideVersionCode = 5
overrideVersionCode = 6
}
apply from: "$rootDir/common.gradle"

View File

@ -2,7 +2,10 @@ package eu.kanade.tachiyomi.extension.fr.frdashscan
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.model.Page
import kotlinx.serialization.decodeFromString
import okhttp3.OkHttpClient
import org.jsoup.nodes.Document
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
@ -16,4 +19,20 @@ class FRScan : Madara("FR-Scan", "https://fr-scan.com", "fr", dateFormat = Simpl
override val useNewChapterEndpoint = true
override val chapterUrlSuffix = ""
override fun pageListParse(document: Document): List<Page> {
val chapterPreloaded = document.selectFirst("#chapter_preloaded_images")
?: return super.pageListParse(document)
val content = CHAPTER_PAGES_REGEX.find(chapterPreloaded.data())?.groups?.get("pages")!!.value
val pages = json.decodeFromString<List<String>>(content)
return pages.mapIndexed { index, imageUrl ->
Page(index, document.location(), imageUrl)
}
}
companion object {
val CHAPTER_PAGES_REGEX = """=\s+(?<pages>\[.+\])""".toRegex()
}
}