From 78f29cc6af9ab42e66fb03ed21fa6a32e5414112 Mon Sep 17 00:00:00 2001 From: phisher98 Date: Sat, 4 May 2024 20:29:20 +0530 Subject: [PATCH] Fixed and Cache is working checked --- .../cloudstream3/extractors/Chillx.kt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Chillx.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/Chillx.kt index 1ada4d61..26567c7a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/Chillx.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/Chillx.kt @@ -27,6 +27,20 @@ open class Chillx : ExtractorApi() { override val mainUrl = "https://chillx.top" override val requiresReferer = true + companion object { + private var key: String? = null + + suspend fun fetchKey(): String { + return if (key != null) { + key!! + } else { + val fetch = app.get("https://raw.githubusercontent.com/rushi-chavan/multi-keys/keys/keys.json").parsedSafe()?.key?.get(0) ?: throw ErrorLoadingException("Unable to get key") + key = fetch + key!! + } + } + } + @Suppress("NAME_SHADOWING") override suspend fun getUrl( url: String, @@ -40,7 +54,8 @@ open class Chillx : ExtractorApi() { referer = url, ).text )?.groupValues?.get(1) - val decrypt = cryptoAESHandler(master ?: "",fetchKey().toByteArray(), false)?.replace("\\", "") ?: throw ErrorLoadingException("failed to decrypt") + val key = fetchKey() + val decrypt = cryptoAESHandler(master ?: "", key.toByteArray(), false)?.replace("\\", "") ?: throw ErrorLoadingException("failed to decrypt") val source = Regex(""""?file"?:\s*"([^"]+)""").find(decrypt)?.groupValues?.get(1) val subtitles = Regex("""subtitle"?:\s*"([^"]+)""").find(decrypt)?.groupValues?.get(1) val subtitlePattern = """\[(.*?)](https?://[^\s,]+)""".toRegex() @@ -83,9 +98,7 @@ open class Chillx : ExtractorApi() { } } - private suspend fun fetchKey(): String { - return app.get("https://raw.githubusercontent.com/rushi-chavan/multi-keys/keys/keys.json").parsedSafe()?.key?.get(0) ?: throw ErrorLoadingException("Unable to get key") - } + data class Keys( @JsonProperty("chillx") val key: List