From f3d2fbeddd06dea1f700910d31fe068d78beab9f Mon Sep 17 00:00:00 2001 From: hexated Date: Sun, 27 Nov 2022 18:06:44 +0700 Subject: [PATCH] fixed Yomovies --- Movierulzhd/build.gradle.kts | 2 +- .../kotlin/com/hexated/YomoviesProvider.kt | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Movierulzhd/build.gradle.kts b/Movierulzhd/build.gradle.kts index c0afdc50..9de5fdfb 100644 --- a/Movierulzhd/build.gradle.kts +++ b/Movierulzhd/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 21 +version = 22 cloudstream { diff --git a/YomoviesProvider/src/main/kotlin/com/hexated/YomoviesProvider.kt b/YomoviesProvider/src/main/kotlin/com/hexated/YomoviesProvider.kt index 38b379b5..56742adc 100644 --- a/YomoviesProvider/src/main/kotlin/com/hexated/YomoviesProvider.kt +++ b/YomoviesProvider/src/main/kotlin/com/hexated/YomoviesProvider.kt @@ -7,9 +7,10 @@ import com.lagradost.cloudstream3.mvvm.safeApiCall import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor import org.jsoup.nodes.Element +import java.net.URI class YomoviesProvider : MainAPI() { - override var mainUrl = "https://yomovies.fyi" + override var mainUrl = "https://yomovies.icu" override var name = "Yomovies" override val hasMainPage = true override var lang = "hi" @@ -126,6 +127,12 @@ class YomoviesProvider : MainAPI() { } } + private fun getBaseUrl(url: String): String { + return URI(url).let { + "${it.scheme}://${it.host}" + } + } + override suspend fun loadLinks( data: String, isCasting: Boolean, @@ -134,23 +141,25 @@ class YomoviesProvider : MainAPI() { ): Boolean { if (data.startsWith(mainUrl)) { - app.get(data).document.select("div.movieplay iframe").map { fixUrl(it.attr("src")) } + val req = app.get(data) + val ref = getBaseUrl(req.url) + req.document.select("div.movieplay iframe").map { fixUrl(it.attr("src")) } .apmap { source -> safeApiCall { when { source.startsWith("https://membed.net") -> app.get( source, - referer = "$mainUrl/" + referer = "$ref/" ).document.select("ul.list-server-items li") .apmap { loadExtractor( it.attr("data-video").substringBefore("=https://msubload"), - "$mainUrl/", + "$ref/", subtitleCallback, callback ) } - else -> loadExtractor(source, "$mainUrl/", subtitleCallback, callback) + else -> loadExtractor(source, "$ref/", subtitleCallback, callback) } } }