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:
parent
7e55f41ce6
commit
ebb5a255eb
|
@ -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<String>()
|
||||
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")
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Reference in New Issue