ArgosScan: Fix Unexpected JSON token error (#9193)
* Fix * Change contains value * Fixes
This commit is contained in:
parent
0c3f9f2736
commit
6022ef39be
@ -1,7 +1,7 @@
|
||||
ext {
|
||||
extName = 'Argos Scan'
|
||||
extClass = '.ArgosScan'
|
||||
extVersionCode = 25
|
||||
extVersionCode = 26
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
@ -19,6 +19,7 @@ import org.jsoup.nodes.Element
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class ArgosScan : ParsedHttpSource() {
|
||||
|
||||
@ -31,14 +32,8 @@ class ArgosScan : ParsedHttpSource() {
|
||||
override val supportsLatest = false
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||
.addInterceptor { chain ->
|
||||
val response = chain.proceed(chain.request())
|
||||
if (response.request.url.pathSegments.any { it.equals("login", true) }) {
|
||||
throw IOException("Faça login na WebView")
|
||||
}
|
||||
|
||||
response
|
||||
}
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.build()
|
||||
|
||||
// Website changed custom CMS.
|
||||
@ -52,7 +47,12 @@ class ArgosScan : ParsedHttpSource() {
|
||||
override fun popularMangaNextPageSelector() = null
|
||||
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
val script = response.asJsoup().selectFirst("script:containsData(projects)")!!.data()
|
||||
val document = response.asJsoup()
|
||||
if (document.select("a[href*='auth/discord']").isNotEmpty()) {
|
||||
throw IOException("Faça login na WebView")
|
||||
}
|
||||
|
||||
val script = document.selectFirst("script:containsData(projects)")!!.data()
|
||||
|
||||
val mangas = POPULAR_REGEX.find(script)?.groups?.get(1)?.value?.let {
|
||||
it.parseAs<List<MangaDto>>()
|
||||
@ -90,6 +90,12 @@ class ArgosScan : ParsedHttpSource() {
|
||||
|
||||
// ============================ Details =====================================
|
||||
|
||||
override fun getMangaUrl(manga: SManga) = "$baseUrl/projeto/${manga.getProjectId()}"
|
||||
|
||||
override fun mangaDetailsRequest(manga: SManga): Request = GET(getMangaUrl(manga), headers)
|
||||
|
||||
private fun SManga.getProjectId() = url.replace("/", "").substringAfter(ENTRY_URL_REGEX)
|
||||
|
||||
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
|
||||
with(document) {
|
||||
title = selectFirst(".content h2")!!.text()
|
||||
@ -100,17 +106,25 @@ class ArgosScan : ParsedHttpSource() {
|
||||
}
|
||||
genre = select("h6:contains(Tags) + h6 > span").joinToString { it.text() }
|
||||
}
|
||||
setUrlWithoutDomain(document.location())
|
||||
}
|
||||
|
||||
// ============================ Chapter =====================================
|
||||
|
||||
override fun chapterListRequest(manga: SManga) = mangaDetailsRequest(manga)
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
return super.chapterListParse(response).sortedByDescending(SChapter::chapter_number)
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = ".manga-chapter"
|
||||
|
||||
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
||||
name = element.selectFirst("h5")!!.text()
|
||||
name = element.selectFirst("h5")!!.ownText()
|
||||
element.selectFirst("h6")?.let {
|
||||
date_upload = dateFormat.tryParse(it.text())
|
||||
SIMPLE_NUMBER_REGEX.find(name)?.groups?.get(0)?.value?.toFloat()?.let {
|
||||
chapter_number = it
|
||||
}
|
||||
}
|
||||
setUrlWithoutDomain(element.selectFirst("a")!!.absUrl("href"))
|
||||
}
|
||||
@ -127,8 +141,13 @@ class ArgosScan : ParsedHttpSource() {
|
||||
|
||||
// ============================== Utilities ==================================
|
||||
|
||||
private fun String.substringAfter(regex: Regex): String =
|
||||
regex.find(this)?.value?.let(::substringAfter) ?: this
|
||||
|
||||
companion object {
|
||||
val dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.ROOT)
|
||||
val POPULAR_REGEX = """projects\s?=\s+([^;]+)""".toRegex()
|
||||
private val dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.ROOT)
|
||||
private val POPULAR_REGEX = """projects(?:\s+)?=(?:\s+)?(.+\]);""".toRegex()
|
||||
private val SIMPLE_NUMBER_REGEX = """\d+(\.?\d+)?""".toRegex()
|
||||
private val ENTRY_URL_REGEX = """projetos?""".toRegex()
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,16 @@ class MangaDto(
|
||||
@SerialName("cover_image_url")
|
||||
val thumbnailUrl: String,
|
||||
val id: String,
|
||||
val type: String,
|
||||
) {
|
||||
val type get() = details.type
|
||||
|
||||
fun toSManga(baseUrl: String) = SManga.create().apply {
|
||||
title = details.title.values.first()
|
||||
description = details.description.values.first()
|
||||
genre = details.genres.joinToString()
|
||||
description = details.description.values.firstOrNull()
|
||||
genre = details.genres.get("genre")?.let(List<String>::joinToString)
|
||||
thumbnail_url = "$baseUrl/$thumbnailUrl"
|
||||
status = details.status.toStatus()
|
||||
url = "/projetos/${this@MangaDto.id}"
|
||||
url = this@MangaDto.id
|
||||
initialized = true
|
||||
}
|
||||
}
|
||||
@ -38,5 +39,6 @@ class DetailsDto(
|
||||
val description: Map<String, String> = emptyMap(),
|
||||
val status: String,
|
||||
@SerialName("tags")
|
||||
val genres: List<String> = emptyList(),
|
||||
val genres: Map<String, List<String>> = emptyMap(),
|
||||
val type: String,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user