[RU]ComX: Reading order to comics events, expanded description (#16000)

* Crossover-events handle, chapter naming cleanup

* Crossover-events handle, chapter naming cleanup

* Add reading order numbers to all comics events, add a note to the comic description.
This commit is contained in:
Alexander 2023-04-09 16:58:25 +03:00 committed by GitHub
parent a8e85cc125
commit 83f52130db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 19 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Com-X'
pkgNameSuffix = 'ru.comx'
extClass = '.ComX'
extVersionCode = 25
extVersionCode = 26
}
apply from: "$rootDir/common.gradle"

View File

@ -262,7 +262,11 @@ class ComX : ParsedHttpSource() {
manga.genre = category + ", " + rawAgeStop + ", " + infoElement.select(".page__tags a").joinToString { it.text() }
manga.status = parseStatus(infoElement.select(".page__list li:contains(Статус)").text())
manga.description = infoElement.select(".page__header h1").text().replace(" / ", " | ").split(" | ").first() + "\n" + ratingStar + " " + ratingValue + " (голосов: " + ratingVotes + ")\n" + Jsoup.parse(infoElement.select(".page__text ").first()!!.html().replace("<br>", "REPLACbR")).text().replace("REPLACbR", "\n")
manga.description = infoElement.select(".page__header h1").text().replace(" / ", " | ").split(" | ").first() + "\n" +
if (document.select(".page__list li:contains(Тип выпуска)").text().contains("!!! События в комиксах - ХРОНОЛОГИЯ !!!")) { "Cобытие в комиксах - ХРОНОЛОГИЯ\n" } else { "" } +
ratingStar + " " + ratingValue + " (голосов: " + ratingVotes + ")\n" +
Jsoup.parse(infoElement.select(".page__text ").first()!!.html().replace("<br>", "REPLACbR")).text().replace("REPLACbR", "\n")
val src = infoElement.select(".img-wide img").attr("data-src")
if (src.contains("://")) {
manga.thumbnail_url = src
@ -298,20 +302,8 @@ class ComX : ParsedHttpSource() {
val data = json.decodeFromString<JsonObject>(dataStr)
val chaptersList = data["chapters"]?.jsonArray
// If chapter name starts with #number or every chapter starts with same name before #number then it is not crossover-event
fun checkCrossEvent(strTitKey: String): Boolean {
return !(
chaptersList.orEmpty().any {
it.jsonObject[strTitKey]!!.jsonPrimitive.content.startsWith("#")
} || chaptersList.orEmpty().all {
it.jsonObject[strTitKey]!!.jsonPrimitive.content.substringBefore('#') ==
chaptersList!![0].jsonObject[strTitKey]!!.jsonPrimitive.content.substringBefore('#')
}
)
}
val isCrossoverEvent = checkCrossEvent("title_en") || checkCrossEvent("title")
val isEvent = document.select(".page__list li:contains(Тип выпуска)").text()
.contains("!!! События в комиксах - ХРОНОЛОГИЯ !!!")
val chapters: List<SChapter>? = chaptersList?.map {
val chapter = SChapter.create()
@ -321,12 +313,12 @@ class ComX : ParsedHttpSource() {
chapter.name = if (it.jsonObject["title"]!!.jsonPrimitive.content == it.jsonObject["title_en"]!!.jsonPrimitive.content) {
it.jsonObject["title"]!!.jsonPrimitive.content
} else {
it.jsonObject["title"]!!.jsonPrimitive.content + " " + it.jsonObject["title_en"]!!.jsonPrimitive.content
(it.jsonObject["title"]!!.jsonPrimitive.content + " " + it.jsonObject["title_en"]!!.jsonPrimitive.content).trim()
}
chapter.date_upload = simpleDateFormat.parse(it.jsonObject["date"]!!.jsonPrimitive.content)?.time ?: 0L
chapter.chapter_number = it.jsonObject["posi"]!!.jsonPrimitive.float
// when it is Crossover-Event add reading order numbers as prefix
if (isCrossoverEvent) {
// when it is Event add reading order numbers as prefix
if (isEvent) {
chapter.name = chapter.chapter_number.toInt().toString() + " " + chapter.name
}
chapter.setUrlWithoutDomain("/readcomix/" + data["news_id"] + "/" + it.jsonObject["id"]!!.jsonPrimitive.content + ".html")