Add more content to hentai2read ext manga description (#5418)
* Add more content to hentai2read ext manga description * Amend outdated comment
This commit is contained in:
parent
4e3f93c431
commit
7aa7eac5fe
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Hentai2Read'
|
extName = 'Hentai2Read'
|
||||||
pkgNameSuffix = 'en.hentai2read'
|
pkgNameSuffix = 'en.hentai2read'
|
||||||
extClass = '.Hentai2Read'
|
extClass = '.Hentai2Read'
|
||||||
extVersionCode = 10
|
extVersionCode = 11
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,12 +166,41 @@ class Hentai2Read : ParsedHttpSource() {
|
||||||
manga.author = infoElement.select("li:contains(Author) > a")?.text()
|
manga.author = infoElement.select("li:contains(Author) > a")?.text()
|
||||||
manga.artist = infoElement.select("li:contains(Artist) > a")?.text()
|
manga.artist = infoElement.select("li:contains(Artist) > a")?.text()
|
||||||
manga.genre = infoElement.select("li:contains(Category) > a, li:contains(Content) > a").joinToString(", ") { it.text() }
|
manga.genre = infoElement.select("li:contains(Category) > a, li:contains(Content) > a").joinToString(", ") { it.text() }
|
||||||
manga.description = infoElement.select("li:contains(Storyline) > p")?.text()
|
manga.description = buildDescription(infoElement)
|
||||||
manga.status = infoElement.select("li:contains(Status) > a")?.text().orEmpty().let { parseStatus(it) }
|
manga.status = infoElement.select("li:contains(Status) > a")?.text().orEmpty().let { parseStatus(it) }
|
||||||
manga.thumbnail_url = document.select("a#js-linkNext > img")?.attr("src")
|
manga.thumbnail_url = document.select("a#js-linkNext > img")?.attr("src")
|
||||||
return manga
|
return manga
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun buildDescription(infoElement: Element): String {
|
||||||
|
|
||||||
|
val topDescriptions = listOf(
|
||||||
|
Pair(
|
||||||
|
"Alternative Title",
|
||||||
|
infoElement.select("li").first().text().let {
|
||||||
|
if (it.trim() == "-") emptyList()
|
||||||
|
else it.split(", ")
|
||||||
|
}
|
||||||
|
),
|
||||||
|
Pair(
|
||||||
|
"Storyline",
|
||||||
|
listOf(infoElement.select("li:contains(Storyline) > p")?.text())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val descriptions = listOf(
|
||||||
|
"Parody",
|
||||||
|
"Page",
|
||||||
|
"Character",
|
||||||
|
"Language"
|
||||||
|
).map { it to infoElement.select("li:contains($it) a").map { v -> v.text() } }
|
||||||
|
.let { topDescriptions + it } // start with topDescriptions
|
||||||
|
.filter { !it.second.isNullOrEmpty() && it.second[0] != "-" }
|
||||||
|
.map { "${it.first}:\n${it.second.joinToString()}" }
|
||||||
|
|
||||||
|
return descriptions.joinToString("\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
private fun parseStatus(status: String) = when {
|
private fun parseStatus(status: String) = when {
|
||||||
status.contains("Ongoing") -> SManga.ONGOING
|
status.contains("Ongoing") -> SManga.ONGOING
|
||||||
status.contains("Completed") -> SManga.COMPLETED
|
status.contains("Completed") -> SManga.COMPLETED
|
||||||
|
@ -181,18 +210,18 @@ class Hentai2Read : ParsedHttpSource() {
|
||||||
override fun chapterListSelector() = "ul.nav-chapters > li > div.media > a"
|
override fun chapterListSelector() = "ul.nav-chapters > li > div.media > a"
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
override fun chapterFromElement(element: Element): SChapter {
|
||||||
val chapter = SChapter.create()
|
return SChapter.create().apply {
|
||||||
chapter.setUrlWithoutDomain(element.attr("href"))
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
chapter.name = element.ownText().trim()
|
name = element.ownText().trim()
|
||||||
chapter.date_upload = element.select("div > small").text()?.let {
|
date_upload = element.select("div > small").text()?.let {
|
||||||
val matcher = chapterDatePattern.matcher(it)
|
val matcher = chapterDatePattern.matcher(it)
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
parseChapterDate(matcher.group(1)!!)
|
parseChapterDate(matcher.group(1)!!)
|
||||||
} else {
|
} else {
|
||||||
0L
|
0L
|
||||||
}
|
}
|
||||||
} ?: 0L
|
} ?: 0L
|
||||||
return chapter
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseChapterDate(date: String): Long {
|
private fun parseChapterDate(date: String): Long {
|
||||||
|
|
Loading…
Reference in New Issue