KomikCast: Fix duplicate images (#3434)

This commit is contained in:
DOTX 2024-06-06 14:45:13 +07:00 committed by Draff
parent fc316415eb
commit 25c9212526
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 3 additions and 21 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.KomikCast' extClass = '.KomikCast'
themePkg = 'mangathemesia' themePkg = 'mangathemesia'
baseUrl = 'https://komikcast.lol' baseUrl = 'https://komikcast.lol'
overrideVersionCode = 26 overrideVersionCode = 27
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -8,13 +8,10 @@ import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.util.Calendar import java.util.Calendar
@ -141,23 +138,8 @@ class KomikCast : MangaThemesia("Komik Cast", "https://komikcast.lol", "id", "/d
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
var doc = document return document.select("div#chapter_body .main-reading-area img.size-full")
var cssQuery = "div#chapter_body .main-reading-area img" .distinctBy { img -> img.imgAttr() }
val imageListRegex = Regex("chapterImages = (.*) \\|\\|")
val imageListMatchResult = imageListRegex.find(document.toString())
if (imageListMatchResult != null) {
val imageListJson = imageListMatchResult.destructured.toList()[0]
val imageList = json.parseToJsonElement(imageListJson).jsonObject
var imageServer = "cdn"
if (!imageList.containsKey(imageServer)) imageServer = imageList.keys.first()
val imageElement = imageList[imageServer]!!.jsonArray.joinToString("")
doc = Jsoup.parse(imageElement)
cssQuery = "img.size-full"
}
return doc.select(cssQuery)
.mapIndexed { i, img -> Page(i, document.location(), img.imgAttr()) } .mapIndexed { i, img -> Page(i, document.location(), img.imgAttr()) }
} }