From d604f0681143b32f41a169d2d9d1c086d6632711 Mon Sep 17 00:00:00 2001 From: funkyhippo <52957110+funkyhippo@users.noreply.github.com> Date: Sun, 28 Mar 2021 13:20:51 -0700 Subject: [PATCH] Migrate Guya proxy to Cubari, QoL updates to Cubari. (#6324) * Remove Guya proxy intents. * Cubari sourceFactory for easier discoverability, search improvements. --- src/all/cubari/build.gradle | 4 +-- .../tachiyomi/extension/all/cubari/Cubari.kt | 9 +++--- .../extension/all/cubari/CubariFactory.kt | 12 +++++++ src/en/guya/AndroidManifest.xml | 14 -------- src/en/guya/build.gradle | 2 +- .../extension/en/guya/GuyaUrlActivity.kt | 32 ++++--------------- 6 files changed, 26 insertions(+), 47 deletions(-) create mode 100644 src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/CubariFactory.kt diff --git a/src/all/cubari/build.gradle b/src/all/cubari/build.gradle index afc7c9fd6..87ea99701 100644 --- a/src/all/cubari/build.gradle +++ b/src/all/cubari/build.gradle @@ -4,8 +4,8 @@ apply plugin: 'kotlin-android' ext { extName = 'Cubari' pkgNameSuffix = "all.cubari" - extClass = '.Cubari' - extVersionCode = 1 + extClass = '.CubariFactory' + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt index d8e0c4f03..b918bd30f 100644 --- a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt +++ b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt @@ -17,12 +17,11 @@ import org.json.JSONArray import org.json.JSONObject import rx.Observable -open class Cubari : HttpSource() { +open class Cubari(override val lang: String) : HttpSource() { final override val name = "Cubari" final override val baseUrl = "https://cubari.moe" final override val supportsLatest = true - final override val lang = "all" override fun headersBuilder() = Headers.Builder().apply { add( @@ -218,7 +217,7 @@ open class Cubari : HttpSource() { searchMangaParse(response, trimmedQuery) } } - else -> Observable.just(MangasPage(ArrayList(), false)) + else -> throw Exception(SEARCH_FALLBACK_MSG) } } @@ -230,7 +229,7 @@ open class Cubari : HttpSource() { return GET("$baseUrl/read/api/$source/series/$slug/", headers) } catch (e: Exception) { - throw Exception("Unable to parse. Is your query in the format of ${Cubari.PROXY_PREFIX}/?") + throw Exception(SEARCH_FALLBACK_MSG) } } @@ -345,6 +344,8 @@ open class Cubari : HttpSource() { const val ARTIST_FALLBACK = "Unknown" const val DESCRIPTION_FALLBACK = "No description." + const val SEARCH_FALLBACK_MSG = "Unable to parse. Is your query in the format of $PROXY_PREFIX/?" + enum class SortType { PINNED, UNPINNED diff --git a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/CubariFactory.kt b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/CubariFactory.kt new file mode 100644 index 000000000..00f589e50 --- /dev/null +++ b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/CubariFactory.kt @@ -0,0 +1,12 @@ +package eu.kanade.tachiyomi.extension.all.cubari + +import eu.kanade.tachiyomi.source.Source +import eu.kanade.tachiyomi.source.SourceFactory + +class CubariFactory : SourceFactory { + override fun createSources(): List = listOf( + Cubari("en"), + Cubari("all"), + Cubari("other") + ) +} diff --git a/src/en/guya/AndroidManifest.xml b/src/en/guya/AndroidManifest.xml index ba161dbbe..bea13c5a9 100644 --- a/src/en/guya/AndroidManifest.xml +++ b/src/en/guya/AndroidManifest.xml @@ -17,20 +17,6 @@ android:host="guya.moe" android:pathPattern="/read/manga/..*" android:scheme="https" /> - - - - - diff --git a/src/en/guya/build.gradle b/src/en/guya/build.gradle index 5fcdbc596..2c407b4e8 100644 --- a/src/en/guya/build.gradle +++ b/src/en/guya/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Guya' pkgNameSuffix = "en.guya" extClass = '.Guya' - extVersionCode = 17 + extVersionCode = 18 libVersion = '1.2' } diff --git a/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/GuyaUrlActivity.kt b/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/GuyaUrlActivity.kt index 78d7f969e..23d71c3b5 100644 --- a/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/GuyaUrlActivity.kt +++ b/src/en/guya/src/eu/kanade/tachiyomi/extension/en/guya/GuyaUrlActivity.kt @@ -21,10 +21,7 @@ class GuyaUrlActivity : Activity() { val pathSegments = intent?.data?.pathSegments if (host != null && pathSegments != null) { - val query = when (host) { - "m.imgur.com", "imgur.com" -> fromImgur(pathSegments) - else -> fromGuya(pathSegments) - } + val query = fromGuya(pathSegments) if (query == null) { Log.e("GuyaUrlActivity", "Unable to parse URI from intent $intent") @@ -49,29 +46,12 @@ class GuyaUrlActivity : Activity() { exitProcess(0) } - private fun fromImgur(pathSegments: List): String? { - if (pathSegments.size >= 2) { - val id = pathSegments[1] - - return "${Guya.PROXY_PREFIX}imgur/$id" - } - return null - } - private fun fromGuya(pathSegments: MutableList): String? { - if (pathSegments.size >= 3) { - return when (pathSegments[0]) { - "proxy" -> { - val source = pathSegments[1] - val id = pathSegments[2] - "${Guya.PROXY_PREFIX}$source/$id" - } - else -> { - val slug = pathSegments[2] - "${Guya.SLUG_PREFIX}$slug" - } - } + return if (pathSegments.size >= 3) { + val slug = pathSegments[2] + "${Guya.SLUG_PREFIX}$slug" + } else { + null } - return null } }