From 6158bac1ca040bbbeeb9531b6f653590209f57ed Mon Sep 17 00:00:00 2001 From: b4byhuey <60543438+b4byhuey@users.noreply.github.com> Date: Thu, 15 Aug 2024 23:20:27 +0800 Subject: [PATCH] Update StreamWishExtractor (#1264) --- .../extractors/StreamWishExtractor.kt | 176 +++++++++++++++--- .../cloudstream3/utils/ExtractorApi.kt | 40 ++++ 2 files changed, 188 insertions(+), 28 deletions(-) diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt index 551d1ef67..500b43855 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt @@ -1,28 +1,137 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.cloudstream3.SubtitleFile +import com.lagradost.cloudstream3.USER_AGENT import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.getQualityFromName +import com.lagradost.cloudstream3.utils.M3u8Helper +import com.lagradost.cloudstream3.utils.getAndUnpack +import com.lagradost.cloudstream3.utils.getPacked +class Mwish : StreamWishExtractor() { + override val name = "Mwish" + override val mainUrl = "https://mwish.pro" +} + +class Dwish : StreamWishExtractor() { + override val name = "Dwish" + override val mainUrl = "https://dwish.pro" +} + +class Ewish : StreamWishExtractor() { + override val name = "Embedwish" + override val mainUrl = "https://embedwish.com" +} class WishembedPro : StreamWishExtractor() { + override val name = "Wishembed" override val mainUrl = "https://wishembed.pro" } -class CdnwishCom : StreamWishExtractor() { - override val mainUrl = "https://cdnwish.com" + +class Kswplayer : StreamWishExtractor() { + override val name = "Kswplayer" + override val mainUrl = "https://kswplayer.info" } -class FlaswishCom : StreamWishExtractor() { - override val mainUrl = "https://flaswish.com" + +class Wishfast: StreamWishExtractor() { + override val name = "Wishfast" + override val mainUrl = "https://wishfast.top" } + +class Streamwish2 : StreamWishExtractor() { + override val mainUrl = "https://streamwish.site" +} + class SfastwishCom : StreamWishExtractor() { + override val name = "Sfastwish" override val mainUrl = "https://sfastwish.com" } + +class Strwish : StreamWishExtractor() { + override val name = "Strwish" + override val mainUrl = "https://strwish.xyz" +} + +class Strwish2 : StreamWishExtractor() { + override val name = "Strwish" + override val mainUrl = "https://strwish.com" +} + +class FlaswishCom : StreamWishExtractor() { + override val name = "Flaswish" + override val mainUrl = "https://flaswish.com" +} + +class Awish : StreamWishExtractor() { + override val name = "Awish" + override val mainUrl = "https://awish.pro" +} + +class Obeywish : StreamWishExtractor() { + override val name = "Obeywish" + override val mainUrl = "https://obeywish.com" +} + +class Jodwish : StreamWishExtractor() { + override val name = "Jodwish" + override val mainUrl = "https://jodwish.com" +} + +class Swhoi : StreamWishExtractor() { + override val name = "Swhoi" + override val mainUrl = "https://swhoi.com" +} + +class Multimovies : StreamWishExtractor() { + override val name = "Multimovies" + override val mainUrl = "https://multimovies.cloud" +} + +class UqloadsXyz : StreamWishExtractor() { + override val name = "Uqloads" + override val mainUrl = "https://uqloads.xyz" +} + +class Doodporn : StreamWishExtractor() { + override val name = "Doodporn" + override val mainUrl = "https://doodporn.xyz" +} + +class CdnwishCom : StreamWishExtractor() { + override val name = "Cdnwish" + override val mainUrl = "https://cdnwish.com" +} + +class Asnwish : StreamWishExtractor() { + override val name = "Asnwish" + override val mainUrl = "https://asnwish.com" +} + +class Nekowish : StreamWishExtractor() { + override val name = "Nekowish" + override val mainUrl = "https://nekowish.my.id" +} + +class Nekostream : StreamWishExtractor() { + override val name = "Nekostream" + override val mainUrl = "https://neko-stream.click" +} + +class Swdyu : StreamWishExtractor() { + override val name = "Swdyu" + override val mainUrl = "https://swdyu.com" +} + +class Wishonly : StreamWishExtractor() { + override val name = "Wishonly" + override val mainUrl = "https://wishonly.site" +} + open class StreamWishExtractor : ExtractorApi() { - override var name = "StreamWish" + override val name = "Streamwish" override val mainUrl = "https://streamwish.to" - override val requiresReferer = false + override val requiresReferer = true override suspend fun getUrl( url: String, @@ -30,27 +139,38 @@ open class StreamWishExtractor : ExtractorApi() { subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ) { - val doc = app.get( - url, - referer = referer, - allowRedirects = false - ).document - var script = doc.select("script").find { - it.html().contains("jwplayer(\"vplayer\").setup(") + val headers = mapOf( + "Accept" to "*/*", + "Connection" to "keep-alive", + "Sec-Fetch-Dest" to "empty", + "Sec-Fetch-Mode" to "cors", + "Sec-Fetch-Site" to "cross-site", + "Origin" to "$mainUrl/", + "User-Agent" to USER_AGENT + ) + val response = app.get(getEmbedUrl(url), referer = referer) + val script = if (!getPacked(response.text).isNullOrEmpty()) { + getAndUnpack(response.text) + } else { + response.document.selectFirst("script:containsData(sources:)")?.data() } - var scriptContent = script?.html() - val extractedurl = Regex("""sources: \[\{file:"(.*?)"""").find(scriptContent ?: "")?.groupValues?.get(1) - if (!extractedurl.isNullOrBlank()) { - callback( - ExtractorLink( - this.name, - this.name, - extractedurl, - referer ?: "$mainUrl/", - getQualityFromName(""), - extractedurl.contains("m3u8") - ) - ) + val m3u8 = + Regex("file:\\s*\"(.*?m3u8.*?)\"").find(script ?: return)?.groupValues?.getOrNull(1) + M3u8Helper.generateM3u8( + name, + m3u8 ?: return, + mainUrl, + headers = headers + ).forEach(callback) + } + + private fun getEmbedUrl(url: String): String { + return if (url.contains("/f/")) { + val videoId = url.substringAfter("/f/") + "$mainUrl/$videoId" + } else { + url } } -} \ No newline at end of file + +} diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt index 0df73a0ed..5664ef3b3 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt @@ -237,6 +237,26 @@ import com.lagradost.cloudstream3.extractors.FlaswishCom import com.lagradost.cloudstream3.extractors.SfastwishCom import com.lagradost.cloudstream3.extractors.Vtbe import com.lagradost.cloudstream3.extractors.WishembedPro +import com.lagradost.cloudstream3.extractors.Mwish +import com.lagradost.cloudstream3.extractors.Dwish +import com.lagradost.cloudstream3.extractors.Ewish +import com.lagradost.cloudstream3.extractors.Kswplayer +import com.lagradost.cloudstream3.extractors.Wishfast +import com.lagradost.cloudstream3.extractors.Streamwish2 +import com.lagradost.cloudstream3.extractors.Strwish +import com.lagradost.cloudstream3.extractors.Strwish2 +import com.lagradost.cloudstream3.extractors.Awish +import com.lagradost.cloudstream3.extractors.Obeywish +import com.lagradost.cloudstream3.extractors.Jodwish +import com.lagradost.cloudstream3.extractors.Swhoi +import com.lagradost.cloudstream3.extractors.Multimovies +import com.lagradost.cloudstream3.extractors.UqloadsXyz +import com.lagradost.cloudstream3.extractors.Doodporn +import com.lagradost.cloudstream3.extractors.Asnwish +import com.lagradost.cloudstream3.extractors.Nekowish +import com.lagradost.cloudstream3.extractors.Nekostream +import com.lagradost.cloudstream3.extractors.Swdyu +import com.lagradost.cloudstream3.extractors.Wishonly import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import kotlinx.coroutines.delay @@ -915,6 +935,26 @@ val extractorApis: MutableList = arrayListOf( Yipsu(), MetaGnathTuggers(), Geodailymotion(), + Mwish(), + Dwish(), + Ewish(), + Kswplayer(), + Wishfast(), + Streamwish2(), + Strwish(), + Strwish2(), + Awish(), + Obeywish(), + Jodwish(), + Swhoi(), + Multimovies(), + UqloadsXyz(), + Doodporn(), + Asnwish(), + Nekowish(), + Nekostream(), + Swdyu(), + Wishonly(), )