From 5b6b80b1f014da825a79a68bf20dc6d877cfb3dc Mon Sep 17 00:00:00 2001 From: hexated Date: Mon, 17 Oct 2022 10:47:46 +0700 Subject: [PATCH] small sources fix SoraStream --- SoraStream/build.gradle.kts | 2 +- .../src/main/kotlin/com/hexated/SoraStream.kt | 60 +++++++++++-------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/SoraStream/build.gradle.kts b/SoraStream/build.gradle.kts index 14be02f9..45762f5f 100644 --- a/SoraStream/build.gradle.kts +++ b/SoraStream/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 2 +version = 3 cloudstream { diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt index 3a274b6b..53cfab6d 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt @@ -4,6 +4,7 @@ import android.util.Log import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.metaproviders.TmdbProvider +import com.lagradost.cloudstream3.mvvm.safeApiCall import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.AppUtils.toJson @@ -277,33 +278,40 @@ class SoraStream : TmdbProvider() { referer = referer ).parsedSafe() - if (json?.sources.isNullOrEmpty()) { -// invokeTwoEmbed(res.id, res.season, res.episode, subtitleCallback, callback) - invokeLocalSources(referer, subtitleCallback, callback) - } else { - json?.sources?.map { source -> - callback.invoke( - ExtractorLink( - this.name, - this.name, - source.url ?: return@map null, - "$mainServerAPI/", - source.quality?.toIntOrNull() ?: Qualities.Unknown.value, - isM3u8 = source.isM3U8, - headers = mapOf("Origin" to mainServerAPI) - ) - ) - } + argamap( + { + invokeTwoEmbed(res.id, res.season, res.episode, subtitleCallback, callback) + }, + { + if (json?.sources.isNullOrEmpty()) { + invokeLocalSources(referer, subtitleCallback, callback) + } else { + json?.sources?.map { source -> + callback.invoke( + ExtractorLink( + this.name, + this.name, + source.url ?: return@map null, + "$mainServerAPI/", + source.quality?.toIntOrNull() ?: Qualities.Unknown.value, + isM3u8 = source.isM3U8, + headers = mapOf("Origin" to mainServerAPI) + ) + ) + } + + json?.subtitles?.map { sub -> + subtitleCallback.invoke( + SubtitleFile( + sub.lang.toString(), + sub.url ?: return@map null + ) + ) + } + } + }) + - json?.subtitles?.map { sub -> - subtitleCallback.invoke( - SubtitleFile( - sub.lang.toString(), - sub.url ?: return@map null - ) - ) - } - } return true }