53 lines
2.2 KiB
Kotlin
53 lines
2.2 KiB
Kotlin
package eu.kanade.tachiyomi.extension.fr.sushiscan
|
|
|
|
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
|
|
import eu.kanade.tachiyomi.source.model.Page
|
|
import eu.kanade.tachiyomi.source.model.SManga
|
|
import kotlinx.serialization.json.jsonArray
|
|
import kotlinx.serialization.json.jsonPrimitive
|
|
import org.jsoup.nodes.Document
|
|
import java.text.SimpleDateFormat
|
|
import java.util.Locale
|
|
|
|
class SushiScan : MangaThemesia("Sushi-Scan", "https://sushiscan.net", "fr", mangaUrlDirectory = "/catalogue", dateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale.FRENCH)) {
|
|
override val altNamePrefix = "Nom alternatif : "
|
|
override val seriesAuthorSelector = ".imptdt:contains(Auteur) i, .fmed b:contains(Auteur)+span"
|
|
override val seriesStatusSelector = ".imptdt:contains(Statut) i"
|
|
override fun String?.parseStatus(): Int = when {
|
|
this == null -> SManga.UNKNOWN
|
|
this.contains("En Cours", ignoreCase = true) -> SManga.ONGOING
|
|
this.contains("Terminé", ignoreCase = true) -> SManga.COMPLETED
|
|
else -> SManga.UNKNOWN
|
|
}
|
|
|
|
override fun mangaDetailsParse(document: Document): SManga =
|
|
super.mangaDetailsParse(document).apply {
|
|
status = document.select(seriesStatusSelector).text().parseStatus()
|
|
}
|
|
|
|
// Overriding to fix http -> https when needed
|
|
override fun pageListParse(document: Document): List<Page> {
|
|
val htmlPages = document.select(pageSelector)
|
|
.filterNot { it.imgAttr().isEmpty() }
|
|
.mapIndexed { i, img -> Page(i, "", if (img.imgAttr().contains("https")) img.imgAttr() else img.imgAttr().replace("http", "https")) }
|
|
|
|
countViews(document)
|
|
|
|
// Some sites also loads pages via javascript
|
|
if (htmlPages.isNotEmpty()) { return htmlPages }
|
|
|
|
val docString = document.toString()
|
|
val imageListJson = JSON_IMAGE_LIST_REGEX.find(docString)?.destructured?.toList()?.get(0).orEmpty()
|
|
val imageList = try {
|
|
json.parseToJsonElement(imageListJson).jsonArray
|
|
} catch (_: IllegalArgumentException) {
|
|
emptyList()
|
|
}
|
|
val scriptPages = imageList.mapIndexed { i, jsonEl ->
|
|
Page(i, "", jsonEl.jsonPrimitive.content)
|
|
}
|
|
|
|
return scriptPages
|
|
}
|
|
}
|