[Madara] Migrate to ScatterSet and add UserAgent config option
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.koitharu.kotatsu.parsers.site.madara
|
||||
|
||||
import androidx.collection.scatterSetOf
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import org.json.JSONObject
|
||||
@@ -22,6 +23,7 @@ internal abstract class MadaraParser(
|
||||
) : PagedMangaParser(context, source, pageSize) {
|
||||
|
||||
override val configKeyDomain = ConfigKey.Domain(domain)
|
||||
private val userAgentKey = ConfigKey.UserAgent(context.getDefaultUserAgent())
|
||||
|
||||
override val isMultipleTagsSupported = false
|
||||
|
||||
@@ -58,7 +60,7 @@ internal abstract class MadaraParser(
|
||||
}
|
||||
|
||||
@JvmField
|
||||
protected val ongoing: Set<String> = hashSetOf(
|
||||
protected val ongoing = scatterSetOf(
|
||||
"مستمرة",
|
||||
"En curso",
|
||||
"En Curso",
|
||||
@@ -100,7 +102,7 @@ internal abstract class MadaraParser(
|
||||
)
|
||||
|
||||
@JvmField
|
||||
protected val finished: Set<String> = hashSetOf(
|
||||
protected val finished = scatterSetOf(
|
||||
"Completed",
|
||||
"Complete",
|
||||
"Completo",
|
||||
@@ -131,7 +133,7 @@ internal abstract class MadaraParser(
|
||||
)
|
||||
|
||||
@JvmField
|
||||
protected val abandoned: Set<String> = hashSetOf(
|
||||
protected val abandoned = scatterSetOf(
|
||||
"Canceled",
|
||||
"Cancelled",
|
||||
"Cancelado",
|
||||
@@ -144,7 +146,7 @@ internal abstract class MadaraParser(
|
||||
)
|
||||
|
||||
@JvmField
|
||||
protected val paused: Set<String> = hashSetOf(
|
||||
protected val paused = scatterSetOf(
|
||||
"Hiatus",
|
||||
"On Hold",
|
||||
"Pausado",
|
||||
@@ -154,7 +156,7 @@ internal abstract class MadaraParser(
|
||||
)
|
||||
|
||||
@JvmField
|
||||
protected val upcoming: Set<String> = hashSetOf(
|
||||
protected val upcoming = scatterSetOf(
|
||||
"Upcoming",
|
||||
"upcoming",
|
||||
"لم تُنشَر بعد",
|
||||
@@ -342,7 +344,12 @@ internal abstract class MadaraParser(
|
||||
)
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()) {
|
||||
state = when (
|
||||
summary?.selectFirst(".mg_status")
|
||||
?.selectFirst(".summary-content")
|
||||
?.ownText()
|
||||
.orEmpty()
|
||||
) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
in abandoned -> MangaState.ABANDONED
|
||||
@@ -642,6 +649,11 @@ internal abstract class MadaraParser(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) {
|
||||
super.onCreateConfig(keys)
|
||||
keys.add(userAgentKey)
|
||||
}
|
||||
|
||||
// Parses dates in this form:
|
||||
// 21 hours ago
|
||||
private fun parseRelativeDate(date: String): Long {
|
||||
|
||||
@@ -35,7 +35,12 @@ internal class FireScans(context: MangaLoaderContext) :
|
||||
)
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()) {
|
||||
state = when (
|
||||
summary?.selectFirst(".mg_status")
|
||||
?.selectFirst(".summary-content")
|
||||
?.ownText()
|
||||
.orEmpty()
|
||||
) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
in abandoned -> MangaState.ABANDONED
|
||||
|
||||
@@ -3,14 +3,7 @@ package org.koitharu.kotatsu.parsers.site.madara.en
|
||||
|
||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
||||
import org.koitharu.kotatsu.parsers.model.ContentRating
|
||||
import org.koitharu.kotatsu.parsers.model.ContentType
|
||||
import org.koitharu.kotatsu.parsers.model.Manga
|
||||
import org.koitharu.kotatsu.parsers.model.MangaListFilter
|
||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||
import org.koitharu.kotatsu.parsers.model.MangaState
|
||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||
import org.koitharu.kotatsu.parsers.model.SortOrder
|
||||
import org.koitharu.kotatsu.parsers.model.*
|
||||
import org.koitharu.kotatsu.parsers.site.madara.MadaraParser
|
||||
import org.koitharu.kotatsu.parsers.util.*
|
||||
|
||||
@@ -135,7 +128,7 @@ internal class Hentai4Free(context: MangaLoaderContext) :
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()
|
||||
?.lowercase()) {
|
||||
?.lowercase().orEmpty()) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
else -> null
|
||||
|
||||
@@ -121,7 +121,7 @@ internal class IsekaiScanEuParser(context: MangaLoaderContext) :
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()
|
||||
?.lowercase()) {
|
||||
?.lowercase().orEmpty()) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
else -> null
|
||||
|
||||
@@ -99,7 +99,7 @@ internal class MangaDass(context: MangaLoaderContext) :
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()
|
||||
?.lowercase()) {
|
||||
?.lowercase().orEmpty()) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
else -> null
|
||||
|
||||
@@ -89,7 +89,7 @@ internal class MangaDna(context: MangaLoaderContext) :
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()
|
||||
?.lowercase()) {
|
||||
?.lowercase().orEmpty()) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
else -> null
|
||||
|
||||
@@ -102,7 +102,7 @@ internal class Manhwaz(context: MangaLoaderContext) :
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()
|
||||
?.lowercase()) {
|
||||
?.lowercase().orEmpty()) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
else -> null
|
||||
|
||||
@@ -86,7 +86,7 @@ internal class ManhwaHub(context: MangaLoaderContext) :
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()
|
||||
?.lowercase()) {
|
||||
?.lowercase().orEmpty()) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
else -> null
|
||||
|
||||
@@ -12,14 +12,7 @@ import java.util.*
|
||||
internal class Shinigami(context: MangaLoaderContext) :
|
||||
MadaraParser(context, MangaSource.SHINIGAMI, "shinigamitoon.com", 10) {
|
||||
|
||||
private val userAgentKey = ConfigKey.UserAgent(context.getDefaultUserAgent())
|
||||
override val tagPrefix = "genre/"
|
||||
override val listUrl = "series/"
|
||||
override val sourceLocale: Locale = Locale.ENGLISH
|
||||
|
||||
override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) {
|
||||
super.onCreateConfig(keys)
|
||||
keys.add(userAgentKey)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ internal class Saytruyenhay(context: MangaLoaderContext) :
|
||||
}.orEmpty(),
|
||||
author = summary?.selectFirst(".mg_author")?.selectFirst("a")?.ownText(),
|
||||
state = when (summary?.selectFirst(".mg_status")?.selectFirst(".summary-content")?.ownText()
|
||||
?.lowercase()) {
|
||||
?.lowercase().orEmpty()) {
|
||||
in ongoing -> MangaState.ONGOING
|
||||
in finished -> MangaState.FINISHED
|
||||
else -> null
|
||||
|
||||
@@ -3,5 +3,5 @@ package org.koitharu.kotatsu.parsers
|
||||
import org.junit.jupiter.params.provider.EnumSource
|
||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||
|
||||
@EnumSource(MangaSource::class, names = ["MANGADEX"], mode = EnumSource.Mode.INCLUDE)
|
||||
@EnumSource(MangaSource::class, names = ["LOCAL", "DUMMY"], mode = EnumSource.Mode.EXCLUDE)
|
||||
internal annotation class MangaSources
|
||||
|
||||
Reference in New Issue
Block a user