|
|
|
@ -12,26 +12,13 @@ import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaParser
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaParser
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
|
|
|
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
|
|
|
import org.koitharu.kotatsu.parsers.model.Manga
|
|
|
|
import org.koitharu.kotatsu.parsers.model.*
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaListFilter
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
|
|
|
|
|
|
|
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.RATING_UNKNOWN
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.SortOrder
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.SuspendLazy
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.domain
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.generateUid
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.getStringOrNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.getStringOrNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.mapJSON
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.mapJSON
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.mapJSONNotNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.mapJSONNotNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.toJSONList
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.toJSONList
|
|
|
|
import org.koitharu.kotatsu.parsers.util.parseJson
|
|
|
|
import java.util.*
|
|
|
|
import org.koitharu.kotatsu.parsers.util.toAbsoluteUrl
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.toTitleCase
|
|
|
|
|
|
|
|
import java.util.UUID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal abstract class MangaPlusParser(
|
|
|
|
internal abstract class MangaPlusParser(
|
|
|
|
context: MangaLoaderContext,
|
|
|
|
context: MangaLoaderContext,
|
|
|
|
@ -39,9 +26,10 @@ internal abstract class MangaPlusParser(
|
|
|
|
private val sourceLang: String,
|
|
|
|
private val sourceLang: String,
|
|
|
|
) : MangaParser(context, source), Interceptor {
|
|
|
|
) : MangaParser(context, source), Interceptor {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val apiUrl = "https://jumpg-webapi.tokyo-cdn.com/api"
|
|
|
|
override val configKeyDomain = ConfigKey.Domain("mangaplus.shueisha.co.jp")
|
|
|
|
override val configKeyDomain = ConfigKey.Domain("mangaplus.shueisha.co.jp")
|
|
|
|
|
|
|
|
|
|
|
|
override val availableSortOrders = setOf(
|
|
|
|
override val availableSortOrders: Set<SortOrder> = EnumSet.of(
|
|
|
|
SortOrder.POPULARITY,
|
|
|
|
SortOrder.POPULARITY,
|
|
|
|
SortOrder.UPDATED,
|
|
|
|
SortOrder.UPDATED,
|
|
|
|
SortOrder.ALPHABETICAL,
|
|
|
|
SortOrder.ALPHABETICAL,
|
|
|
|
@ -106,16 +94,19 @@ internal abstract class MangaPlusParser(
|
|
|
|
return mapNotNull {
|
|
|
|
return mapNotNull {
|
|
|
|
val language = it.getStringOrNull("language") ?: "ENGLISH"
|
|
|
|
val language = it.getStringOrNull("language") ?: "ENGLISH"
|
|
|
|
|
|
|
|
|
|
|
|
if (language != sourceLang)
|
|
|
|
if (language != sourceLang) {
|
|
|
|
return@mapNotNull null
|
|
|
|
return@mapNotNull null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val name = it.getString("name")
|
|
|
|
val name = it.getString("name")
|
|
|
|
val author = it.getString("author")
|
|
|
|
val author = it.getString("author")
|
|
|
|
.split("/").joinToString(transform = String::trim)
|
|
|
|
.split('/')
|
|
|
|
|
|
|
|
.joinToString(transform = String::trim)
|
|
|
|
|
|
|
|
|
|
|
|
// filter out any other title or author which doesn't match search input
|
|
|
|
// filter out any other title or author which doesn't match search input
|
|
|
|
if (query != null && !(name.contains(query, true) || author.contains(query, true)))
|
|
|
|
if (query != null && !(name.contains(query, true) || author.contains(query, true))) {
|
|
|
|
return@mapNotNull null
|
|
|
|
return@mapNotNull null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val titleId = it.getInt("titleId").toString()
|
|
|
|
val titleId = it.getInt("titleId").toString()
|
|
|
|
|
|
|
|
|
|
|
|
@ -164,12 +155,10 @@ internal abstract class MangaPlusParser(
|
|
|
|
json.getJSONArray("chapterListGroup"),
|
|
|
|
json.getJSONArray("chapterListGroup"),
|
|
|
|
title.getStringOrNull("language") ?: "ENGLISH",
|
|
|
|
title.getStringOrNull("language") ?: "ENGLISH",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
state = if (completed) {
|
|
|
|
state = when {
|
|
|
|
MangaState.FINISHED
|
|
|
|
completed -> MangaState.FINISHED
|
|
|
|
} else if (hiatus) {
|
|
|
|
hiatus -> MangaState.PAUSED
|
|
|
|
MangaState.PAUSED
|
|
|
|
else -> MangaState.ONGOING
|
|
|
|
} else {
|
|
|
|
|
|
|
|
MangaState.ONGOING
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -182,10 +171,9 @@ internal abstract class MangaPlusParser(
|
|
|
|
it.optJSONArray("lastChapterList")?.toJSONList().orEmpty()
|
|
|
|
it.optJSONArray("lastChapterList")?.toJSONList().orEmpty()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return chapterList.mapNotNull { chapter ->
|
|
|
|
return chapterList.mapChapters { _, chapter ->
|
|
|
|
val chapterId = chapter.getInt("chapterId").toString()
|
|
|
|
val chapterId = chapter.getInt("chapterId").toString()
|
|
|
|
val subtitle = chapter.getStringOrNull("subTitle")
|
|
|
|
val subtitle = chapter.getStringOrNull("subTitle") ?: return@mapChapters null
|
|
|
|
?: return@mapNotNull null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MangaChapter(
|
|
|
|
MangaChapter(
|
|
|
|
id = generateUid(chapterId),
|
|
|
|
id = generateUid(chapterId),
|
|
|
|
@ -275,10 +263,6 @@ internal abstract class MangaPlusParser(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
|
|
|
private const val apiUrl = "https://jumpg-webapi.tokyo-cdn.com/api"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@MangaSourceParser("MANGAPLUSPARSER_EN", "MANGA Plus English", "en")
|
|
|
|
@MangaSourceParser("MANGAPLUSPARSER_EN", "MANGA Plus English", "en")
|
|
|
|
class English(context: MangaLoaderContext) : MangaPlusParser(
|
|
|
|
class English(context: MangaLoaderContext) : MangaPlusParser(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
|