Move Decadence Scans to Madara (#2822)
This commit is contained in:
parent
7b8e61b72f
commit
7235c83998
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: Madara (multiple sources)'
|
||||
pkgNameSuffix = "all.madara"
|
||||
extClass = '.MadaraFactory'
|
||||
extVersionCode = 75
|
||||
extVersionCode = 76
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,8 @@ class MadaraFactory : SourceFactory {
|
|||
ZinManga(),
|
||||
ZManga(),
|
||||
MangaGecesi(),
|
||||
MangaWT()
|
||||
MangaWT(),
|
||||
DecadenceScans()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -573,3 +574,5 @@ class MangaGecesi : Madara("Manga Gecesi", "https://mangagecesi.com", "tr") {
|
|||
}
|
||||
|
||||
class MangaWT : Madara("MangaWT", "https://mangawt.com", "tr")
|
||||
|
||||
class DecadenceScans : Madara("Decadence Scans", "https://reader.decadencescans.com", "en")
|
||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: MangAdventure'
|
||||
pkgNameSuffix = 'all.mangadventure'
|
||||
extClass = '.MangAdventureFactory'
|
||||
extVersionCode = 6
|
||||
extVersionCode = 7
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ abstract class MangAdventure(
|
|||
is CategoryList -> cat.addAll(it.state.mapNotNull { c ->
|
||||
Uri.encode(c.optString())
|
||||
})
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
return GET("$uri&categories=${cat.joinToString(",")}", headers)
|
||||
|
@ -133,9 +134,7 @@ abstract class MangAdventure(
|
|||
override fun pageListParse(response: Response) =
|
||||
JSONObject(response.asString()).run {
|
||||
val url = getString("url")
|
||||
// Workaround for a bug in MangAdventure < 0.6.3
|
||||
val root = getString("pages_root")
|
||||
.replace("://media/series", "://reader")
|
||||
val arr = getJSONArray("pages_list")
|
||||
(0 until arr.length()).map {
|
||||
Page(it, "$url${it + 1}", "$root${arr.getString(it)}")
|
||||
|
@ -237,7 +236,7 @@ abstract class MangAdventure(
|
|||
*/
|
||||
inner class Status : Filter.Select<String>("Status", STATUSES) {
|
||||
/** Returns the [state] as a string. */
|
||||
fun string() = values[state].toLowerCase()
|
||||
fun string() = values[state].toLowerCase(Locale(lang))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -249,8 +248,8 @@ abstract class MangAdventure(
|
|||
inner class Category(name: String) : Filter.TriState(name) {
|
||||
/** Returns the [state] as a string, or null if [isIgnored]. */
|
||||
fun optString() = when (state) {
|
||||
STATE_INCLUDE -> name.toLowerCase()
|
||||
STATE_EXCLUDE -> "-" + name.toLowerCase()
|
||||
STATE_INCLUDE -> name.toLowerCase(Locale(lang))
|
||||
STATE_EXCLUDE -> "-" + name.toLowerCase(Locale(lang))
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import kotlin.system.exitProcess
|
|||
* intents and redirects them to the main Tachiyomi process.
|
||||
*/
|
||||
class MangAdventureActivity : Activity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
intent?.data?.pathSegments?.takeIf { it.size > 1 }?.let {
|
||||
|
|
|
@ -11,29 +11,40 @@ import org.json.JSONObject
|
|||
/** Returns the body of a response as a `String`. */
|
||||
fun Response.asString(): String = body()!!.string()
|
||||
|
||||
/**
|
||||
* Formats the number according to [fmt].
|
||||
*
|
||||
* @param fmt A [DecimalFormat] string.
|
||||
* @return A string representation of the number.
|
||||
*/
|
||||
fun Number.format(fmt: String): String = DecimalFormat(fmt).format(this)
|
||||
|
||||
/**
|
||||
* Joins each value of a given [field] of the array using [sep].
|
||||
*
|
||||
* @param field
|
||||
* When its type is [Int], it is treated as the index of a [JSONArray].
|
||||
* @param field The index of a [JSONArray].
|
||||
* When its type is [String], it is treated as the key of a [JSONObject].
|
||||
* @param sep The separator used to join the array.
|
||||
* @param T Must be either [Int] or [String].
|
||||
* @return The joined string, or null if the array is empty.
|
||||
* @throws IllegalArgumentException when [field] is of an invalid type.
|
||||
* @return The joined string, or `null` if the array is empty.
|
||||
*/
|
||||
fun <T> JSONArray.joinField(field: T, sep: String = ", "): String? {
|
||||
require(field is Int || field is String) {
|
||||
"field must be a String or Int"
|
||||
}
|
||||
return length().takeIf { it != 0 }?.let { len ->
|
||||
(0 until len).joinToString(sep) {
|
||||
when (field) {
|
||||
is Int -> getJSONArray(it).getString(field)
|
||||
is String -> getJSONObject(it).getString(field)
|
||||
else -> "" // this is here to appease the compiler
|
||||
fun JSONArray.joinField(field: Int, sep: String = ", ") =
|
||||
length().takeIf { it != 0 }?.run {
|
||||
(0 until this).joinToString(sep) {
|
||||
getJSONArray(it).getString(field)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins each value of a given [field] of the array using [sep].
|
||||
*
|
||||
* @param field The key of a [JSONObject].
|
||||
* @param sep The separator used to join the array.
|
||||
* @return The joined string, or `null` if the array is empty.
|
||||
*/
|
||||
fun JSONArray.joinField(field: String, sep: String = ", ") =
|
||||
length().takeIf { it != 0 }?.run {
|
||||
(0 until this).joinToString(sep) {
|
||||
getJSONObject(it).getString(field)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +85,7 @@ fun SChapter.fromJSON(obj: JSONObject) = apply {
|
|||
scanlator = obj.getJSONArray("groups")?.joinField("name", " & ")
|
||||
name = obj.optString("full_title", buildString {
|
||||
obj.optInt("volume").let { if (it != 0) append("Vol. $it, ") }
|
||||
append("Ch. ${DecimalFormat("#.#").format(chapter_number)}: ")
|
||||
append("Ch. ${chapter_number.format("#.#")}: ")
|
||||
append(obj.getString("title"))
|
||||
})
|
||||
if (obj.getBoolean("final")) name += " [END]"
|
||||
|
|
|
@ -2,10 +2,10 @@ package eu.kanade.tachiyomi.extension.all.mangadventure
|
|||
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
|
||||
/** [MangAdventure] source factory. */
|
||||
class MangAdventureFactory : SourceFactory {
|
||||
override fun createSources() = listOf(
|
||||
ArcRelight(),
|
||||
DecadenceScans()
|
||||
ArcRelight()
|
||||
)
|
||||
|
||||
/** Arc-Relight source. */
|
||||
|
@ -29,9 +29,4 @@ class MangAdventureFactory : SourceFactory {
|
|||
"Tragedy"
|
||||
)
|
||||
)
|
||||
|
||||
/** Decadence Scans source. */
|
||||
class DecadenceScans : MangAdventure(
|
||||
"Decadence Scans", "https://reader.decadencescans.com"
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue