From ebb5a255ebbbdc6c9fce22ffde33a0a97a48b64b Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Sun, 11 Apr 2021 20:51:06 +0700 Subject: [PATCH] Madara: update manga info (#6431) * Madara: add series type to genre, filter author&artist name add series type(manga/manhwa/manhua/other) thinggy to genre for some source remove author & artist name if the name is "Updating" * change "if else" with "when" * fix some issue after converting to when * add tag to genre push seriesTypeSelector too * add alternative name to manga description * Cleaning, simplifying, fixing Co-Authored-By: Carlos <2092019+CarlosEsco@users.noreply.github.com> * more cleaning Co-Authored-By: Carlos <2092019+CarlosEsco@users.noreply.github.com> * tweaking Co-Authored-By: Carlos <2092019+CarlosEsco@users.noreply.github.com> * remove val * bit tweak * separate ": " to make it more noticeable and is needed Co-authored-by: Carlos <2092019+CarlosEsco@users.noreply.github.com> --- .../tachiyomi/multisrc/madara/Madara.kt | 45 ++++++++++++++++--- .../multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt index fd77cad14..a20d0dfb6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt @@ -329,10 +329,10 @@ abstract class Madara( manga.title = it.ownText() } select("div.author-content").first()?.let { - manga.author = it.text() + if (it.text().notUpdating()) manga.author = it.text() } select("div.artist-content").first()?.let { - manga.artist = it.text() + if (it.text().notUpdating()) manga.artist = it.text() } select("div.description-summary div.summary__content").let { if (it.select("p").text().isNotEmpty()) { @@ -355,17 +355,48 @@ abstract class Madara( else -> SManga.UNKNOWN } } - val genres = mutableListOf() - select("div.genres-content a").forEach { element -> - val genre = element.text() - genres.add(genre) + val genres = select("div.genres-content a") + .map { element -> element.text().toLowerCase() } + .toMutableSet() + + // add tag(s) to genre + select("div.tags-content a").forEach { element -> + if (genres.contains(element.text()).not()) { + genres.add(element.text().toLowerCase()) + } + } + + // add manga/manhwa/manhua thinggy to genre + document.select(seriesTypeSelector).firstOrNull()?.ownText()?.let { + if (it.isEmpty().not() && it.notUpdating() && it != "-" && genres.contains(it).not()) { + genres.add(it.toLowerCase()) + } + } + + manga.genre = genres.toList().map { it.capitalize() }.joinToString(", ") + + // add alternative name to manga description + document.select(altNameSelector).firstOrNull()?.ownText()?.let { + if (it.isEmpty().not() && it.notUpdating()) { + manga.description += when { + manga.description.isNullOrEmpty() -> altName + it + else -> "\n\n$altName" + it + } + } } - manga.genre = genres.joinToString(", ") } return manga } + open val seriesTypeSelector = ".post-content_item:contains(Type) .summary-content" + open val altNameSelector = ".post-content_item:contains(Alt) .summary-content" + open val altName = "Alternative Name" + ": " + + private fun String.notUpdating(): Boolean { + return this.contains("Updating", true).not() + } + protected fun imageFromElement(element: Element): String? { return when { element.hasAttr("data-src") -> element.attr("abs:data-src") diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt index 59eca2d43..9adee2bdd 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt @@ -10,7 +10,7 @@ class MadaraGenerator : ThemeSourceGenerator { override val themeClass = "Madara" - override val baseVersionCode: Int = 2 + override val baseVersionCode: Int = 3 override val sources = listOf( SingleLang("Adonis Fansub", "https://manga.adonisfansub.com", "tr"),