|
|
|
@ -37,6 +37,18 @@ internal abstract class LibSocialParser(
|
|
|
|
5, MangaState.ABANDONED,
|
|
|
|
5, MangaState.ABANDONED,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
private val imageServers = SuspendLazy(::fetchServers)
|
|
|
|
private val imageServers = SuspendLazy(::fetchServers)
|
|
|
|
|
|
|
|
private val splitTranslationsKey = ConfigKey.SplitByTranslations(true)
|
|
|
|
|
|
|
|
private val preferredServerKey = ConfigKey.PreferredImageServer(
|
|
|
|
|
|
|
|
presetValues = mapOf(
|
|
|
|
|
|
|
|
null to null,
|
|
|
|
|
|
|
|
SERVER_MAIN to "Первый",
|
|
|
|
|
|
|
|
SERVER_SECONDARY to "Второй",
|
|
|
|
|
|
|
|
SERVER_COMPRESS to "Сжатия",
|
|
|
|
|
|
|
|
SERVER_DOWNLOAD to "Загрузки",
|
|
|
|
|
|
|
|
SERVER_CROP to "Обрезки",
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
defaultValue = null,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun getListPage(page: Int, filter: MangaListFilter?): List<Manga> {
|
|
|
|
override suspend fun getListPage(page: Int, filter: MangaListFilter?): List<Manga> {
|
|
|
|
val urlBuilder = urlBuilder("api")
|
|
|
|
val urlBuilder = urlBuilder("api")
|
|
|
|
@ -75,7 +87,7 @@ internal abstract class LibSocialParser(
|
|
|
|
SortOrder.NEWEST -> "created_at"
|
|
|
|
SortOrder.NEWEST -> "created_at"
|
|
|
|
SortOrder.ALPHABETICAL,
|
|
|
|
SortOrder.ALPHABETICAL,
|
|
|
|
SortOrder.ALPHABETICAL_DESC,
|
|
|
|
SortOrder.ALPHABETICAL_DESC,
|
|
|
|
-> "rus_name"
|
|
|
|
-> "rus_name"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
urlBuilder.addQueryParameter(
|
|
|
|
urlBuilder.addQueryParameter(
|
|
|
|
@ -86,7 +98,7 @@ internal abstract class LibSocialParser(
|
|
|
|
SortOrder.RATING,
|
|
|
|
SortOrder.RATING,
|
|
|
|
SortOrder.NEWEST,
|
|
|
|
SortOrder.NEWEST,
|
|
|
|
SortOrder.ALPHABETICAL_DESC,
|
|
|
|
SortOrder.ALPHABETICAL_DESC,
|
|
|
|
-> "desc"
|
|
|
|
-> "desc"
|
|
|
|
|
|
|
|
|
|
|
|
SortOrder.ALPHABETICAL -> "asc"
|
|
|
|
SortOrder.ALPHABETICAL -> "asc"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -132,10 +144,7 @@ internal abstract class LibSocialParser(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val servers = imageServers.get()
|
|
|
|
val servers = imageServers.get()
|
|
|
|
val json = pages.await()
|
|
|
|
val json = pages.await()
|
|
|
|
val primaryServer =
|
|
|
|
val primaryServer = getPrimaryImageServer(servers)
|
|
|
|
checkNotNull(servers[SERVER_MAIN] ?: servers[SERVER_DOWNLOAD] ?: servers[SERVER_SECONDARY]) {
|
|
|
|
|
|
|
|
"No available images servers"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
json.getJSONArray("pages").mapJSON { jo ->
|
|
|
|
json.getJSONArray("pages").mapJSON { jo ->
|
|
|
|
val url = jo.getString("url")
|
|
|
|
val url = jo.getString("url")
|
|
|
|
MangaPage(
|
|
|
|
MangaPage(
|
|
|
|
@ -167,6 +176,12 @@ internal abstract class LibSocialParser(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) {
|
|
|
|
|
|
|
|
super.onCreateConfig(keys)
|
|
|
|
|
|
|
|
keys.add(splitTranslationsKey)
|
|
|
|
|
|
|
|
keys.add(preferredServerKey)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun parseManga(jo: JSONObject): Manga {
|
|
|
|
private fun parseManga(jo: JSONObject): Manga {
|
|
|
|
val cover = jo.getJSONObject("cover")
|
|
|
|
val cover = jo.getJSONObject("cover")
|
|
|
|
return Manga(
|
|
|
|
return Manga(
|
|
|
|
@ -187,6 +202,16 @@ internal abstract class LibSocialParser(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun getPrimaryImageServer(servers: ScatterMap<String, String>): String {
|
|
|
|
|
|
|
|
val preferred = config[preferredServerKey]
|
|
|
|
|
|
|
|
if (preferred != null) {
|
|
|
|
|
|
|
|
servers[preferred]?.let { return it }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return checkNotNull(servers[SERVER_MAIN] ?: servers[SERVER_DOWNLOAD] ?: servers[SERVER_SECONDARY]) {
|
|
|
|
|
|
|
|
"No available images servers"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private suspend fun fetchChapters(manga: Manga): List<MangaChapter> {
|
|
|
|
private suspend fun fetchChapters(manga: Manga): List<MangaChapter> {
|
|
|
|
val url = urlBuilder("api")
|
|
|
|
val url = urlBuilder("api")
|
|
|
|
.addPathSegment("api")
|
|
|
|
.addPathSegment("api")
|
|
|
|
@ -197,6 +222,7 @@ internal abstract class LibSocialParser(
|
|
|
|
val json = webClient.httpGet(url).parseJson().getJSONArray("data")
|
|
|
|
val json = webClient.httpGet(url).parseJson().getJSONArray("data")
|
|
|
|
val builder = ChaptersListBuilder(json.length())
|
|
|
|
val builder = ChaptersListBuilder(json.length())
|
|
|
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US)
|
|
|
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US)
|
|
|
|
|
|
|
|
val useBranching = config[splitTranslationsKey]
|
|
|
|
for (i in 0 until json.length()) {
|
|
|
|
for (i in 0 until json.length()) {
|
|
|
|
val jo = json.getJSONObject(i)
|
|
|
|
val jo = json.getJSONObject(i)
|
|
|
|
val volume = jo.getIntOrDefault("volume", 0)
|
|
|
|
val volume = jo.getIntOrDefault("volume", 0)
|
|
|
|
@ -219,7 +245,7 @@ internal abstract class LibSocialParser(
|
|
|
|
url = "${manga.url}/chapter?number=$numberString&volume=$volume",
|
|
|
|
url = "${manga.url}/chapter?number=$numberString&volume=$volume",
|
|
|
|
scanlator = team,
|
|
|
|
scanlator = team,
|
|
|
|
uploadDate = dateFormat.tryParse(bjo.getStringOrNull("created_at")),
|
|
|
|
uploadDate = dateFormat.tryParse(bjo.getStringOrNull("created_at")),
|
|
|
|
branch = team,
|
|
|
|
branch = if (useBranching) team else null,
|
|
|
|
source = source,
|
|
|
|
source = source,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|