From 271b925ff6b5264af21855a0ac84936e23a76c36 Mon Sep 17 00:00:00 2001 From: hexated Date: Sat, 18 Mar 2023 11:48:14 +0700 Subject: [PATCH] loklok: updated error handler again --- Loklok/build.gradle.kts | 2 +- Loklok/src/main/kotlin/com/hexated/Loklok.kt | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Loklok/build.gradle.kts b/Loklok/build.gradle.kts index c967dcce..b102c031 100644 --- a/Loklok/build.gradle.kts +++ b/Loklok/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 22 +version = 23 cloudstream { diff --git a/Loklok/src/main/kotlin/com/hexated/Loklok.kt b/Loklok/src/main/kotlin/com/hexated/Loklok.kt index b8645404..faf379c8 100644 --- a/Loklok/src/main/kotlin/com/hexated/Loklok.kt +++ b/Loklok/src/main/kotlin/com/hexated/Loklok.kt @@ -28,7 +28,7 @@ class Loklok : MainAPI() { // no license found // thanks to https://github.com/napthedev/filmhot for providing API companion object { - private const val geoblockError = "Loklok is Geoblock Mfs, use vpn near from Indonesia or give up" + private const val geoblockError = "Loklok is Geoblock Mfs, use vpn or give up" private val api = base64DecodeAPI("dg==LnQ=b2s=a2w=bG8=aS4=YXA=ZS0=aWw=b2I=LW0=Z2E=Ly8=czo=dHA=aHQ=") private val apiUrl = "$api/${base64Decode("Y21zL2FwcA==")}" private val searchApi = base64Decode("aHR0cHM6Ly9sb2tsb2suY29t") @@ -54,10 +54,10 @@ class Loklok : MainAPI() { for (i in 0..6) { // delay(500) app.get("$apiUrl/homePage/getHome?page=$i", headers = headers) - .parsedSafe()?.data?.recommendItems - ?.filterNot { it.homeSectionType == "BLOCK_GROUP" } - ?.filterNot { it.homeSectionType == "BANNER" } - ?.mapNotNull { res -> + .parsedSafe()?.data?.recommendItems.orEmpty().ifEmpty { throw ErrorLoadingException(geoblockError) } + .filterNot { it.homeSectionType == "BLOCK_GROUP" } + .filterNot { it.homeSectionType == "BANNER" } + .mapNotNull { res -> val header = res.homeSectionName ?: return@mapNotNull null val media = res.media?.mapNotNull { media -> media.toSearchResponse() } .orEmpty().ifEmpty { throw ErrorLoadingException(geoblockError) }