From 57693fef7bc7222e9bdcb47bab503fdc40308e7b Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Tue, 30 Mar 2021 21:48:05 +0430 Subject: [PATCH] clean up --- .../extension/api/ExtensionGithubApi.kt | 38 ++++++++----------- .../extension/api/ExtensionGithubService.kt | 1 - 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt index 5e6ff9b..561a170 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt @@ -7,42 +7,37 @@ package eu.kanade.tachiyomi.extension.api * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -// import android.content.Context -// import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.util.ExtensionLoader import ir.armor.tachidesk.model.dataclass.ExtensionDataClass -// import kotlinx.coroutines.Dispatchers -// import kotlinx.coroutines.withContext import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.int import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive - object ExtensionGithubApi { const val BASE_URL = "https://raw.githubusercontent.com" const val REPO_URL_PREFIX = "$BASE_URL/tachiyomiorg/tachiyomi-extensions/repo" private fun parseResponse(json: JsonArray): List { return json - .filter { element -> - val versionName = element.jsonObject["version"]!!.jsonPrimitive.content - val libVersion = versionName.substringBeforeLast('.').toDouble() - libVersion >= ExtensionLoader.LIB_VERSION_MIN && libVersion <= ExtensionLoader.LIB_VERSION_MAX - } - .map { element -> - val name = element.jsonObject["name"]!!.jsonPrimitive.content.substringAfter("Tachiyomi: ") - val pkgName = element.jsonObject["pkg"]!!.jsonPrimitive.content - val apkName = element.jsonObject["apk"]!!.jsonPrimitive.content - val versionName = element.jsonObject["version"]!!.jsonPrimitive.content - val versionCode = element.jsonObject["code"]!!.jsonPrimitive.int - val lang = element.jsonObject["lang"]!!.jsonPrimitive.content - val nsfw = element.jsonObject["nsfw"]!!.jsonPrimitive.int == 1 - val icon = "$REPO_URL_PREFIX/icon/${apkName.replace(".apk", ".png")}" + .filter { element -> + val versionName = element.jsonObject["version"]!!.jsonPrimitive.content + val libVersion = versionName.substringBeforeLast('.').toDouble() + libVersion >= ExtensionLoader.LIB_VERSION_MIN && libVersion <= ExtensionLoader.LIB_VERSION_MAX + } + .map { element -> + val name = element.jsonObject["name"]!!.jsonPrimitive.content.substringAfter("Tachiyomi: ") + val pkgName = element.jsonObject["pkg"]!!.jsonPrimitive.content + val apkName = element.jsonObject["apk"]!!.jsonPrimitive.content + val versionName = element.jsonObject["version"]!!.jsonPrimitive.content + val versionCode = element.jsonObject["code"]!!.jsonPrimitive.int + val lang = element.jsonObject["lang"]!!.jsonPrimitive.content + val nsfw = element.jsonObject["nsfw"]!!.jsonPrimitive.int == 1 + val icon = "$REPO_URL_PREFIX/icon/${apkName.replace(".apk", ".png")}" - Extension.Available(name, pkgName, versionName, versionCode, lang, nsfw, apkName, icon) - } + Extension.Available(name, pkgName, versionName, versionCode, lang, nsfw, apkName, icon) + } } fun findExtensions(): List { @@ -55,5 +50,4 @@ object ExtensionGithubApi { fun getApkUrl(extension: ExtensionDataClass): String { return "$REPO_URL_PREFIX/apk/${extension.apkName}" } - } diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt index c1169d4..7aedeb6 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubService.kt @@ -10,7 +10,6 @@ import retrofit2.Retrofit import retrofit2.http.GET import uy.kohesive.injekt.injectLazy - /** * Used to get the extension repo listing from GitHub. */