Read Mangas: Fix description (#7249)

fix: description
This commit is contained in:
Hellkaros 2025-01-23 15:00:13 -03:00 committed by Draff
parent a25c0555d8
commit 20b51fa15e
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 7 additions and 4 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Read Mangas' extName = 'Read Mangas'
extClass = '.ReadMangas' extClass = '.ReadMangas'
extVersionCode = 35 extVersionCode = 36
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -20,6 +20,7 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Request import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response import okhttp3.Response
import org.json.JSONObject
import rx.Observable import rx.Observable
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -153,13 +154,16 @@ class ReadMangas() : HttpSource() {
val document = response.asJsoup() val document = response.asJsoup()
return SManga.create().apply { return SManga.create().apply {
title = document.selectFirst("h1")!!.text() title = document.selectFirst("h1")!!.text()
thumbnail_url = document.selectFirst("img.w-full")?.absUrl("src") thumbnail_url = document.selectFirst("img.w-full")?.absUrl("src")
genre = document.select("div > label + div > div").joinToString { it.text() } genre = document.select("div > label + div > div").joinToString { it.text() }
description = document.select("script").map { it.data() } description = document.select("script").map { it.data() }
.firstOrNull { MANGA_DETAILS_DESCRIPTION_REGEX.containsMatchIn(it) } .firstOrNull { it.contains("description", ignoreCase = true) }
?.let { ?.let {
MANGA_DETAILS_DESCRIPTION_REGEX.find(it)?.groups?.get("description")?.value val jsonObject = JSONObject(it)
jsonObject.optString("description", "")
} }
document.selectFirst("div.flex > div.inline-flex.items-center:last-child")?.text()?.let { document.selectFirst("div.flex > div.inline-flex.items-center:last-child")?.text()?.let {
@ -290,7 +294,6 @@ class ReadMangas() : HttpSource() {
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
companion object { companion object {
val MANGA_DETAILS_DESCRIPTION_REGEX = """description":(?<description>"[^"]+)""".toRegex()
val IMAGE_URL_REGEX = """url\\":\\"(?<imageUrl>[^(\\")]+)""".toRegex() val IMAGE_URL_REGEX = """url\\":\\"(?<imageUrl>[^(\\")]+)""".toRegex()
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")