Fix page previews after E-H update
(cherry picked from commit d45563e58d7f5f8f50046e0dbb8dc2e147ac0789)
This commit is contained in:
parent
230aec370c
commit
7565e51f95
@ -1143,17 +1143,22 @@ class EHentai(
|
||||
.toString(),
|
||||
),
|
||||
).awaitSuccess().asJsoup()
|
||||
val previews = if (doc.selectFirst("div#gdo4 .ths")!!.attr("onClick").contains("inline_set=ts_l")) {
|
||||
doc.body()
|
||||
.select("#gdt div a")
|
||||
|
||||
val body = doc.body()
|
||||
val previews = body
|
||||
.select("#gdt div div")
|
||||
.map {
|
||||
PagePreviewInfo(it.text().toInt(), imageUrl = it.select("img").attr("src"))
|
||||
}
|
||||
} else {
|
||||
parseNormalPreviewSet(doc)
|
||||
.map { preview ->
|
||||
val preview = parseNormalPreview(it)
|
||||
PagePreviewInfo(preview.index, imageUrl = preview.toUrl())
|
||||
}
|
||||
.ifEmpty {
|
||||
body.select("#gdt div a img")
|
||||
.map {
|
||||
PagePreviewInfo(
|
||||
it.attr("alt").toInt(),
|
||||
imageUrl = it.attr("src")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return PagePreviewPage(
|
||||
@ -1175,12 +1180,9 @@ class EHentai(
|
||||
/**
|
||||
* Parse normal previews with regular expressions
|
||||
*/
|
||||
private fun parseNormalPreviewSet(doc: Document): List<EHentaiThumbnailPreview> {
|
||||
return doc.body()
|
||||
.select("#gdt div div")
|
||||
.map { it.selectFirst("img")!!.attr("alt").toInt() to it.attr("style") }
|
||||
.map { (index, style) ->
|
||||
val styles = style.split(";").mapNotNull { it.trimOrNull() }
|
||||
private fun parseNormalPreview(element: Element): EHentaiThumbnailPreview {
|
||||
val index = element.selectFirst("img")!!.attr("alt").toInt()
|
||||
val styles = element.attr("style").split(";").mapNotNull { it.trimOrNull() }
|
||||
val width = styles.first { it.startsWith("width:") }
|
||||
.removePrefix("width:")
|
||||
.removeSuffix("px")
|
||||
@ -1204,8 +1206,7 @@ class EHentai(
|
||||
.removeSuffix("px")
|
||||
.toInt()
|
||||
|
||||
EHentaiThumbnailPreview(url, width, height, widthOffset, index)
|
||||
}
|
||||
return EHentaiThumbnailPreview(url, width, height, widthOffset, index).also(::println)
|
||||
}
|
||||
data class EHentaiThumbnailPreview(
|
||||
val imageUrl: String,
|
||||
|
Loading…
x
Reference in New Issue
Block a user