From 7e356b61b8b10586d9f5f6128ed2c027228b2edc Mon Sep 17 00:00:00 2001 From: hexated Date: Sun, 2 Apr 2023 04:01:43 +0700 Subject: [PATCH] stremiox: fix id --- StremioX/src/main/kotlin/com/hexated/Stremio.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/StremioX/src/main/kotlin/com/hexated/Stremio.kt b/StremioX/src/main/kotlin/com/hexated/Stremio.kt index 91bbd216..efd9fabc 100644 --- a/StremioX/src/main/kotlin/com/hexated/Stremio.kt +++ b/StremioX/src/main/kotlin/com/hexated/Stremio.kt @@ -18,6 +18,7 @@ class Stremio : MainAPI() { override val supportedTypes = setOf(TvType.Others) override val hasMainPage = true private var fixedUrl = mainUrl + private val cinemataUrl = "https://v3-cinemeta.strem.io" override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse? { fixedUrl = mainUrl.fixSourceUrl() @@ -46,6 +47,7 @@ class Stremio : MainAPI() { override suspend fun load(url: String): LoadResponse? { val res = parseJson(url) + fixedUrl = if((res.type == "movie" || res.type == "series") && isImdborTmdb(res.id)) cinemataUrl else mainUrl.fixSourceUrl() val json = app.get("${fixedUrl}/meta/${res.type}/${res.id}.json") .parsedSafe()?.meta ?: throw RuntimeException(url) return json.toLoadResponse(this) @@ -65,6 +67,11 @@ class Stremio : MainAPI() { return true } + // check if id is imdb/tmdb cause stremio addons like torrentio works base on imdbId + private fun isImdborTmdb(url: String?): Boolean { + return imdbUrlToIdNullable(url) != null || url?.startsWith("tmdb:") == true + } + private data class Manifest(val catalogs: List) private data class Catalog( var name: String?,