From 4c60142a5b37057704fc18d14735d24e315e9c4f Mon Sep 17 00:00:00 2001 From: funkyhippo <52957110+funkyhippo@users.noreply.github.com> Date: Sun, 18 Aug 2019 09:40:25 -0700 Subject: [PATCH] Changed endpoint for scanlator cache, and fixed caching issue with chapter pageLists. (#1401) --- src/en/guya/build.gradle | 2 +- .../tachiyomi/extension/en/guya/Guya.kt | 23 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/en/guya/build.gradle b/src/en/guya/build.gradle index bc13708fa..80a05ac0f 100644 --- a/src/en/guya/build.gradle +++ b/src/en/guya/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Guya' pkgNameSuffix = "en.guya" extClass = '.Guya' - extVersionCode = 3 + extVersionCode = 4 libVersion = '1.2' } diff --git a/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/Guya.kt b/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/Guya.kt index 979f01711..6d84b1531 100644 --- a/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/Guya.kt +++ b/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/Guya.kt @@ -28,6 +28,8 @@ open class Guya() : ConfigurableSource, HttpSource() { override val supportsLatest = false override val lang = "en" + private val scanlatorCacheUrl = "https://raw.githubusercontent.com/appu1232/guyamoe/master/api/data_cache/all_groups.json" + override fun headersBuilder() = Headers.Builder().apply { add("User-Agent","(Android ${Build.VERSION.RELEASE}; " + "${Build.MANUFACTURER} ${Build.MODEL}) " + @@ -164,27 +166,22 @@ open class Guya() : ConfigurableSource, HttpSource() { val preference = ListPreference(screen.context).apply { key = "preferred_scanlator" title = "Preferred scanlator" - var scanlators = arrayOf() - var scanlatorsIndex = arrayOf() + entries = arrayOf() + entryValues = arrayOf() for (key in Scanlators.keys()) { - scanlators += Scanlators.getValueFromKey(key) - scanlatorsIndex += key + entries += Scanlators.getValueFromKey(key) + entryValues += key } - entries = scanlators - entryValues = scanlatorsIndex summary = "Current: %s\n\n" + "This setting sets the scanlation group to prioritize " + "on chapter refresh/update. It will get the next available if " + - "your preferred scanlator isn't an option (yet)." + - "\nNOTE: If you've already downloaded a chapter and the pages aren't updating, " + - "clear your chapter cache under Settings > Advanced > Clear chapter cache." + "your preferred scanlator isn't an option (yet)." this.setDefaultValue(1) setOnPreferenceChangeListener{_, newValue -> val selected = newValue.toString() - val index = (this.findIndexOfValue(selected) + 1).toString() - preferences.edit().putString(SCANLATOR_PREFERENCE, index).commit() + preferences.edit().putString(SCANLATOR_PREFERENCE, selected).commit() } } @@ -246,7 +243,7 @@ open class Guya() : ConfigurableSource, HttpSource() { chapter.scanlator = Scanlators.getValueFromKey(firstGroupId) chapter.name = num + " - " + json.getString("title") chapter.chapter_number = num.toFloat() - chapter.url = "$slug/$num/1" + chapter.url = "$slug/$num/$firstGroupId" return chapter } @@ -318,7 +315,7 @@ open class Guya() : ConfigurableSource, HttpSource() { private fun update() { if (scanlatorMap.isEmpty() && !polling) { polling = true - clientBuilder().newCall(GET("$baseUrl/api/get_all_groups/", headers)).enqueue( + clientBuilder().newCall(GET(scanlatorCacheUrl, headers)).enqueue( object: Callback { override fun onResponse(call: Call, response: Response) { val json = JSONObject(response.body()!!.string())