[Grouple] Back to the old chapters parsing behavior with option

master
Koitharu 2 years ago
parent b7613606c0
commit 813c5236b3
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -25,4 +25,8 @@ sealed class ConfigKey<T>(
class UserAgent( class UserAgent(
override val defaultValue: String, override val defaultValue: String,
) : ConfigKey<String>("user_agent") ) : ConfigKey<String>("user_agent")
class SplitByTranslations(
override val defaultValue: Boolean,
) : ConfigKey<Boolean>("split_translations")
} }

@ -45,6 +45,7 @@ internal abstract class GroupleParser(
private val userAgentKey = ConfigKey.UserAgent( private val userAgentKey = ConfigKey.UserAgent(
"Mozilla/5.0 (X11; U; UNICOS lcLinux; en-US) Gecko/20140730 (KHTML, like Gecko, Safari/419.3) Arora/0.8.0", "Mozilla/5.0 (X11; U; UNICOS lcLinux; en-US) Gecko/20140730 (KHTML, like Gecko, Safari/419.3) Arora/0.8.0",
) )
private val splitTranslationsKey = ConfigKey.SplitByTranslations(false)
override val headers: Headers = Headers.Builder().add("User-Agent", config[userAgentKey]).build() override val headers: Headers = Headers.Builder().add("User-Agent", config[userAgentKey]).build()
@ -115,11 +116,15 @@ internal abstract class GroupleParser(
val root = doc.body().requireElementById("mangaBox").selectFirstOrThrow("div.leftContent") val root = doc.body().requireElementById("mangaBox").selectFirstOrThrow("div.leftContent")
val dateFormat = SimpleDateFormat("dd.MM.yy", Locale.US) val dateFormat = SimpleDateFormat("dd.MM.yy", Locale.US)
val coverImg = root.selectFirst("div.subject-cover")?.selectFirst("img") val coverImg = root.selectFirst("div.subject-cover")?.selectFirst("img")
val translations = root.selectFirst("div.translator-selection") val translations = if (config[splitTranslationsKey]) {
?.select(".translator-selection-item") root.selectFirst("div.translator-selection")
?.associate { ?.select(".translator-selection-item")
it.id().removePrefix("tr-").toLong() to it.selectFirst(".translator-selection-name")?.textOrNull() ?.associate {
} it.id().removePrefix("tr-").toLong() to it.selectFirst(".translator-selection-name")?.textOrNull()
}
} else {
null
}
return manga.copy( return manga.copy(
description = root.selectFirst("div.manga-description")?.html(), description = root.selectFirst("div.manga-description")?.html(),
largeCoverUrl = coverImg?.attr("data-full"), largeCoverUrl = coverImg?.attr("data-full"),
@ -277,6 +282,7 @@ internal abstract class GroupleParser(
override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) { override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) {
super.onCreateConfig(keys) super.onCreateConfig(keys)
keys.add(userAgentKey) keys.add(userAgentKey)
keys.add(splitTranslationsKey)
} }
override suspend fun getRelatedManga(seed: Manga): List<Manga> { override suspend fun getRelatedManga(seed: Manga): List<Manga> {

Loading…
Cancel
Save