Guya: parse description HTML and clean up code (#13419)
* Guya: parse description HTML and clean up code * revert header * revert import
This commit is contained in:
parent
237f4eb0fc
commit
ff0473835f
|
@ -21,6 +21,8 @@ import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import org.jsoup.Jsoup
|
||||||
|
import org.jsoup.select.Evaluator
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.schedulers.Schedulers
|
import rx.schedulers.Schedulers
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
@ -50,8 +52,6 @@ abstract class Guya(
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val scanlatorPreference = "SCANLATOR_PREFERENCE"
|
|
||||||
|
|
||||||
// Request builder for the "browse" page of the manga
|
// Request builder for the "browse" page of the manga
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
return GET("$baseUrl/api/get_all_series/", headers)
|
return GET("$baseUrl/api/get_all_series/", headers)
|
||||||
|
@ -250,15 +250,13 @@ abstract class Guya(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
val scanlatorKeys = scanlators.keys().toTypedArray()
|
||||||
|
|
||||||
val preference = ListPreference(screen.context).apply {
|
val preference = ListPreference(screen.context).apply {
|
||||||
key = "preferred_scanlator"
|
key = "preferred_scanlator"
|
||||||
title = "Preferred scanlator"
|
title = "Preferred scanlator"
|
||||||
entries = arrayOf<String>()
|
entries = Array(scanlatorKeys.size) { scanlators.getValueFromKey(scanlatorKeys[it]) }
|
||||||
entryValues = arrayOf<String>()
|
entryValues = scanlatorKeys
|
||||||
for (key in scanlators.keys()) {
|
|
||||||
entries += scanlators.getValueFromKey(key)
|
|
||||||
entryValues += key
|
|
||||||
}
|
|
||||||
summary = "Current: %s\n\n" +
|
summary = "Current: %s\n\n" +
|
||||||
"This setting sets the scanlation group to prioritize " +
|
"This setting sets the scanlation group to prioritize " +
|
||||||
"on chapter refresh/update. It will get the next available if " +
|
"on chapter refresh/update. It will get the next available if " +
|
||||||
|
@ -428,7 +426,13 @@ abstract class Guya(
|
||||||
manga.title = title.ifEmpty { json.getString("title") }
|
manga.title = title.ifEmpty { json.getString("title") }
|
||||||
manga.artist = json.optString("artist")
|
manga.artist = json.optString("artist")
|
||||||
manga.author = json.optString("author")
|
manga.author = json.optString("author")
|
||||||
manga.description = json.optString("description")
|
manga.description = json.optString("description").let {
|
||||||
|
if ('<' !in it) return@let it // no HTML
|
||||||
|
Jsoup.parseBodyFragment(it).body().run {
|
||||||
|
select(Evaluator.Tag("a")).remove()
|
||||||
|
text()
|
||||||
|
}
|
||||||
|
}
|
||||||
manga.url = if (slug.startsWith(PROXY_PREFIX)) slug else json.getString("slug")
|
manga.url = if (slug.startsWith(PROXY_PREFIX)) slug else json.getString("slug")
|
||||||
|
|
||||||
val cover = json.optString("cover")
|
val cover = json.optString("cover")
|
||||||
|
@ -581,5 +585,7 @@ abstract class Guya(
|
||||||
const val SLUG_PREFIX = "slug:"
|
const val SLUG_PREFIX = "slug:"
|
||||||
const val PROXY_PREFIX = "proxy:"
|
const val PROXY_PREFIX = "proxy:"
|
||||||
const val NESTED_PROXY_API_PREFIX = "/proxy/api/"
|
const val NESTED_PROXY_API_PREFIX = "/proxy/api/"
|
||||||
|
|
||||||
|
private const val scanlatorPreference = "SCANLATOR_PREFERENCE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,13 @@ class GuyaGenerator : ThemeSourceGenerator {
|
||||||
|
|
||||||
override val themeClass = "Guya"
|
override val themeClass = "Guya"
|
||||||
|
|
||||||
override val baseVersionCode = 3
|
override val baseVersionCode = 4
|
||||||
|
|
||||||
override val sources = listOf(
|
override val sources = listOf(
|
||||||
SingleLang("Guya", "https://guya.moe", "en", overrideVersionCode = 18),
|
SingleLang("Guya", "https://guya.moe", "en", overrideVersionCode = 18),
|
||||||
SingleLang("Danke fürs Lesen", "https://danke.moe", "en", className = "DankeFursLesen"),
|
SingleLang("Danke fürs Lesen", "https://danke.moe", "en", className = "DankeFursLesen"),
|
||||||
SingleLang("Hachirumi", "https://hachirumi.com", "en", isNsfw = true),
|
SingleLang("Hachirumi", "https://hachirumi.com", "en", isNsfw = true),
|
||||||
MultiLang(
|
MultiLang("Magical Translators", "https://mahoushoujobu.com", listOf("en", "es", "pl"), overrideVersionCode = 1),
|
||||||
"Magical Translators", "https://mahoushoujobu.com", listOf("en", "es", "pl"),
|
|
||||||
overrideVersionCode = 1
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
Loading…
Reference in New Issue