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>
This commit is contained in:
Riztard Lanthorn 2021-04-11 20:51:06 +07:00 committed by GitHub
parent 7e55f41ce6
commit ebb5a255eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 8 deletions

View File

@ -329,10 +329,10 @@ abstract class Madara(
manga.title = it.ownText() manga.title = it.ownText()
} }
select("div.author-content").first()?.let { select("div.author-content").first()?.let {
manga.author = it.text() if (it.text().notUpdating()) manga.author = it.text()
} }
select("div.artist-content").first()?.let { 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 { select("div.description-summary div.summary__content").let {
if (it.select("p").text().isNotEmpty()) { if (it.select("p").text().isNotEmpty()) {
@ -355,17 +355,48 @@ abstract class Madara(
else -> SManga.UNKNOWN else -> SManga.UNKNOWN
} }
} }
val genres = mutableListOf<String>() val genres = select("div.genres-content a")
select("div.genres-content a").forEach { element -> .map { element -> element.text().toLowerCase() }
val genre = element.text() .toMutableSet()
genres.add(genre)
// 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 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? { protected fun imageFromElement(element: Element): String? {
return when { return when {
element.hasAttr("data-src") -> element.attr("abs:data-src") element.hasAttr("data-src") -> element.attr("abs:data-src")

View File

@ -10,7 +10,7 @@ class MadaraGenerator : ThemeSourceGenerator {
override val themeClass = "Madara" override val themeClass = "Madara"
override val baseVersionCode: Int = 2 override val baseVersionCode: Int = 3
override val sources = listOf( override val sources = listOf(
SingleLang("Adonis Fansub", "https://manga.adonisfansub.com", "tr"), SingleLang("Adonis Fansub", "https://manga.adonisfansub.com", "tr"),