HentaiSlayer: translate "alternative name" (#1843)

* HentaiSlayer: translate "alternative name"

* Fix “alternative name”

* Fix non-nullable & optimize code

* revert format changes caused by AndroidStudio’s ktlint plugin

* Update HentaiSlayer.kt

---------

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
This commit is contained in:
Cuong M. Tran 2024-03-16 00:28:23 +07:00 committed by Draff
parent e67d78f435
commit b21ab37da9
2 changed files with 12 additions and 16 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Hentai Slayer' extName = 'Hentai Slayer'
extClass = '.HentaiSlayer' extClass = '.HentaiSlayer'
extVersionCode = 1 extVersionCode = 2
isNsfw = true isNsfw = true
} }

View File

@ -48,10 +48,10 @@ class HentaiSlayer : ParsedHttpSource(), ConfigurableSource {
override fun popularMangaSelector() = "div > div:has(div#card-real)" override fun popularMangaSelector() = "div > div:has(div#card-real)"
override fun popularMangaFromElement(element: Element) = SManga.create().apply { override fun popularMangaFromElement(element: Element) = SManga.create().apply {
element.selectFirst("div#card-real a")?.run { with(element.selectFirst("div#card-real a")!!) {
setUrlWithoutDomain(absUrl("href")) setUrlWithoutDomain(absUrl("href"))
selectFirst("figure")?.run { with(selectFirst("figure")!!) {
selectFirst("img.object-cover")?.run { with(selectFirst("img.object-cover")!!) {
thumbnail_url = imgAttr() thumbnail_url = imgAttr()
title = attr("alt") title = attr("alt")
} }
@ -98,21 +98,17 @@ class HentaiSlayer : ParsedHttpSource(), ConfigurableSource {
// =========================== Manga Details ============================ // =========================== Manga Details ============================
override fun mangaDetailsParse(document: Document) = SManga.create().apply { override fun mangaDetailsParse(document: Document) = SManga.create().apply {
document.selectFirst("main section")?.run { with(document.selectFirst("main section")!!) {
selectFirst("img#manga-cover")?.run { thumbnail_url = selectFirst("img#manga-cover")!!.imgAttr()
thumbnail_url = imgAttr() with(selectFirst("section > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2)")!!) {
title = attr("alt")
}
selectFirst("section > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2)")?.run {
status = parseStatus(select("a[href*='?status=']").text()) status = parseStatus(select("a[href*='?status=']").text())
genre = select("a[href*='?type=']").text() genre = select("a[href*='?type=']").text()
author = select("p:has(span:contains(المؤلف)) span:nth-child(2)").text() author = select("p:has(span:contains(المؤلف)) span:nth-child(2)").text()
artist = select("p:has(span:contains(الرسام)) span:nth-child(2)").text() artist = select("p:has(span:contains(الرسام)) span:nth-child(2)").text()
} }
selectFirst("section > div:nth-child(1) > div:nth-child(2)")?.run { var desc = "\u061C"
select("h1").text().takeIf { it.isNotEmpty() }?.let { with(selectFirst("section > div:nth-child(1) > div:nth-child(2)")!!) {
title = it title = selectFirst("h1")!!.text()
}
genre = select("a[href*='?genre=']") genre = select("a[href*='?genre=']")
.map { it.text() } .map { it.text() }
.let { .let {
@ -120,10 +116,10 @@ class HentaiSlayer : ParsedHttpSource(), ConfigurableSource {
} }
.joinToString() .joinToString()
select("h2").text().takeIf { it.isNotEmpty() }?.let { select("h2").text().takeIf { it.isNotEmpty() }?.let {
description = "Alternative name: $it\n" desc += "أسماء أُخرى: $it\n"
} }
} }
description += select("#description").text() description = desc + select("#description").text()
} }
} }