diff --git a/src/en/kickassanime/build.gradle b/src/en/kickassanime/build.gradle index 1ef54a7da6..937b38ab0f 100644 --- a/src/en/kickassanime/build.gradle +++ b/src/en/kickassanime/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'KickAssAnime' extClass = '.KickAssAnime' - extVersionCode = 37 + extVersionCode = 38 } apply from: "$rootDir/common.gradle" diff --git a/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/KickAssAnime.kt b/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/KickAssAnime.kt index f4116b3496..ad9e8559f4 100644 --- a/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/KickAssAnime.kt +++ b/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/KickAssAnime.kt @@ -37,6 +37,7 @@ import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import uy.kohesive.injekt.injectLazy import java.util.Locale class KickAssAnime : ConfigurableAnimeSource, AnimeHttpSource() { @@ -53,11 +54,10 @@ class KickAssAnime : ConfigurableAnimeSource, AnimeHttpSource() { private val preferences: SharedPreferences by lazy { Injekt.get().getSharedPreferences("source_$id", 0x0000) + .clearBaseUrl() } - private val json = Json { - ignoreUnknownKeys = true - } + private val json: Json by injectLazy() // ============================== Popular =============================== override fun popularAnimeRequest(page: Int) = GET("$apiUrl/popular?page=$page") @@ -290,6 +290,17 @@ class KickAssAnime : ConfigurableAnimeSource, AnimeHttpSource() { ).reversed() } + private fun SharedPreferences.clearBaseUrl(): SharedPreferences { + if (getString(PREF_DOMAIN_KEY, "")!! in PREF_DOMAIN_ENTRY_VALUES) { + return this + } + edit() + .remove(PREF_DOMAIN_KEY) + .putString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT) + .apply() + return this + } + companion object { private val SERVERS = arrayOf("DuckStream", "BirdStream", "VidStreaming") @@ -323,9 +334,9 @@ class KickAssAnime : ConfigurableAnimeSource, AnimeHttpSource() { private const val PREF_DOMAIN_KEY = "preferred_domain" private const val PREF_DOMAIN_TITLE = "Preferred domain (requires app restart)" - private const val PREF_DOMAIN_DEFAULT = "https://kickassanime.am" - private val PREF_DOMAIN_ENTRIES = arrayOf("kickassanime.am", "kaas.to", "kaas.ro") - private val PREF_DOMAIN_ENTRY_VALUES = arrayOf("https://kickassanime.am", "https://kaas.to", "https://kaas.ro") + private const val PREF_DOMAIN_DEFAULT = "https://kaas.to" + private val PREF_DOMAIN_ENTRIES = arrayOf("kaas.to", "kaas.ro", "kickassanimes.io", "www1.kickassanime.mx") + private val PREF_DOMAIN_ENTRY_VALUES = PREF_DOMAIN_ENTRIES.map { "https://$it" }.toTypedArray() private const val PREF_HOSTER_KEY = "hoster_selection" private const val PREF_HOSTER_TITLE = "Enable/Disable Hosts" diff --git a/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/extractors/KickAssAnimeExtractor.kt b/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/extractors/KickAssAnimeExtractor.kt index 9b55932e94..0fc5d08cdb 100644 --- a/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/extractors/KickAssAnimeExtractor.kt +++ b/src/en/kickassanime/src/eu/kanade/tachiyomi/animeextension/en/kickassanime/extractors/KickAssAnimeExtractor.kt @@ -7,9 +7,7 @@ import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES.decodeHex import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.util.parseAs import kotlinx.serialization.json.Json -import okhttp3.CacheControl import okhttp3.Headers import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.OkHttpClient @@ -20,27 +18,6 @@ class KickAssAnimeExtractor( private val json: Json, private val headers: Headers, ) { - // Stolen from AniWatch - // Prevent (automatic) caching the .JS file for different episodes, because it - // changes everytime, and a cached old .js will have a invalid AES password, - // invalidating the decryption algorithm. - // We cache it manually when initializing the class. - private val cacheControl = CacheControl.Builder().noStore().build() - private val newClient = client.newBuilder() - .cache(null) - .build() - - private val keyMaps by lazy { - buildMap { - put("bird", newClient.newCall(GET("https://raw.githubusercontent.com/enimax-anime/kaas/bird/key.txt", cache = cacheControl)).execute().body.string().toByteArray()) - put("duck", newClient.newCall(GET("https://raw.githubusercontent.com/enimax-anime/kaas/duck/key.txt", cache = cacheControl)).execute().body.string().toByteArray()) - } - } - - private val signaturesMap by lazy { - newClient.newCall(GET("https://raw.githubusercontent.com/enimax-anime/gogo/main/KAA.json", cache = cacheControl)).execute().parseAs>>() - } - fun videosFromUrl(url: String, name: String): List