From 2ac17cff0e88011c49e346c1bd54cc69a1b39aad Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Sun, 20 Mar 2022 19:02:52 +0100 Subject: [PATCH] fixed this provider does not exist --- app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt | 9 +++++++++ .../lagradost/cloudstream3/ui/result/ResultViewModel.kt | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index b086d3ce..bc96f3bb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -116,6 +116,15 @@ object APIHolder { return null } + fun getApiFromUrlNull(url : String?) : MainAPI? { + if (url == null) return null + for (api in allProviders) { + if(url.startsWith(api.mainUrl)) + return api + } + return null + } + fun LoadResponse.getId(): Int { return url.replace(getApiFromName(apiName).mainUrl, "").replace("/", "").hashCode() } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt index 860da4a3..22e44bbd 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt @@ -7,6 +7,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull +import com.lagradost.cloudstream3.APIHolder.getApiFromUrlNull import com.lagradost.cloudstream3.APIHolder.getId import com.lagradost.cloudstream3.AcraApplication.Companion.setKey import com.lagradost.cloudstream3.mvvm.Resource @@ -279,7 +280,7 @@ class ResultViewModel : ViewModel() { _publicEpisodes.postValue(Resource.Loading()) _apiName.postValue(apiName) - val api = getApiFromNameNull(apiName) + val api = getApiFromNameNull(apiName) ?: getApiFromUrlNull(url) if (api == null) { _resultResponse.postValue( Resource.Failure(