From 2eeb7572a92456a2d5acb9754a3906edb7532f1c Mon Sep 17 00:00:00 2001 From: SpecterNight Date: Sun, 15 Dec 2024 00:20:41 -0500 Subject: [PATCH 1/3] Refactor provider --- .../com/stormunblessed/PelisplusHDProvider.kt | 95 +++++++------------ 1 file changed, 34 insertions(+), 61 deletions(-) diff --git a/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt b/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt index 84ea3f8..d78f05b 100644 --- a/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt +++ b/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt @@ -1,15 +1,14 @@ package com.lagradost.cloudstream3.movieproviders -import android.webkit.URLUtil import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.getQualityFromName -import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor +import org.json.JSONObject import org.jsoup.nodes.Element +import com.lagradost.cloudstream3.extractors.helper.CryptoJS class PelisplusHDProvider:MainAPI() { - override var mainUrl = "https://ww1.pelisplushd.nu" + override var mainUrl = "https://pelisplushd.bz" override var name = "PelisplusHD" override var lang = "es" override val hasMainPage = true @@ -43,6 +42,7 @@ class PelisplusHDProvider:MainAPI() { val href = this.select("a").attr("href") val posterUrl = fixUrl(this.select(".Posters-img").attr("src")) val isMovie = href.contains("/pelicula/") + val isAnime = href.contains("/anime/") return if (isMovie) { MovieSearchResponse( title, @@ -52,7 +52,7 @@ class PelisplusHDProvider:MainAPI() { posterUrl, null ) - } else { + }else { TvSeriesSearchResponse( title, href, @@ -74,13 +74,14 @@ class PelisplusHDProvider:MainAPI() { val href = it.selectFirst("a")!!.attr("href") val image = it.selectFirst(".Posters-img")?.attr("src")?.let { it1 -> fixUrl(it1) } val isMovie = href.contains("/pelicula/") + val isAnime = href.contains("/anime/") if (isMovie) { MovieSearchResponse( title, href, this.name, - TvType.Movie, + TvType.Anime, image, null ) @@ -167,66 +168,38 @@ class PelisplusHDProvider:MainAPI() { subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ): Boolean { - app.get(data).document.select("div.player").map { script -> - fetchUrls( - script.data() - .replace("https://api.mycdn.moe/furl.php?id=", "https://www.fembed.com/v/") - .replace("https://api.mycdn.moe/sblink.php?id=", "https://streamsb.net/e/") - ) - .apmap { link -> - val regex = """(go_to_player|go_to_playerVast)\('(.*?)'""".toRegex() - regex.findAll(app.get(link).document.html()).toList().apmap { - val current = it?.groupValues?.get(2) ?: "" - var link: String? = null - if (URLUtil.isValidUrl(current)) { - link = fixUrl(current) - } else { - try { - link = - base64Decode( - it?.groupValues?.get(1) ?: "" - ) - } catch (e: Throwable) { - } - } + app.get(data).document.select("div.player").map{script -> + fetchUrls(script.data()).apmap { link -> + val doc = app.get(link).document + val isNewEmbed = doc.select(".ODDIV div").isEmpty() - if (!link.isNullOrBlank()) { - if (link.contains("https://api.mycdn.moe/video/") || link.contains( - "https://api.mycdn.moe/embed.php?customid" - ) - ) { - val doc = app.get(link).document - doc.select("div.ODDIV li").apmap { - val linkencoded = it.attr("data-r") - val linkdecoded = base64Decode(linkencoded) - .replace( - Regex("https://owodeuwu.xyz|https://sypl.xyz"), - "https://embedsito.com" - ) - .replace(Regex(".poster.*"), "") - val secondlink = - it.attr("onclick").substringAfter("go_to_player('") - .substringBefore("',") - loadExtractor(linkdecoded, link, subtitleCallback, callback) - val restwo = app.get( - "https://api.mycdn.moe/player/?id=$secondlink", - allowRedirects = false - ).document - val thirdlink = restwo.selectFirst("body > iframe")?.attr("src") - ?.replace( - Regex("https://owodeuwu.xyz|https://sypl.xyz"), - "https://embedsito.com" - ) - ?.replace(Regex(".poster.*"), "") - loadExtractor(thirdlink!!, link, subtitleCallback, callback) + if(!isNewEmbed){ + doc.select(".ODDIV div li").apmap { + val linkExtracted = it.attr("onclick").substringAfter("go_to_playerVast('") + .substringBefore("',") + loadExtractor(linkExtracted, subtitleCallback,callback) + } + }else{ + val scriptData = doc.select("script").lastOrNull().toString() + val regexKey = """CryptoJS\.AES\.decrypt\(.*?,\s*['"](.+?)['"]\)""".toRegex() + val aesKey = regexKey.find(scriptData)!!.value.substringAfter("CryptoJS.AES.decrypt(encryptedLink, '") + .substringBefore("')") + val jsonRegex = """const dataLink = (\[.*?\]);""".toRegex(RegexOption.DOT_MATCHES_ALL) + val jsonExtracted = jsonRegex.find(scriptData)!!.groupValues[1] + val dataLink = JSONObject("{\"dataLink\": $jsonExtracted}").getJSONArray("dataLink") - } - } else { - loadExtractor(link, data, subtitleCallback, callback) - } + for (i in 0 until dataLink.length()){ + val sortedEmbeds = dataLink.getJSONObject(i).getJSONArray("sortedEmbeds") + + for (j in 0 until sortedEmbeds.length()){ + val linkExtracted = sortedEmbeds.getJSONObject(j).getString("link") + val linkDecrypted = CryptoJS.decrypt(aesKey, linkExtracted) + loadExtractor(linkDecrypted, subtitleCallback, callback) } } + } + } } return true } From 4ad0e92c2fa5e92b2865e4ce9deba412eb758d72 Mon Sep 17 00:00:00 2001 From: SpecterNight Date: Sun, 15 Dec 2024 00:25:36 -0500 Subject: [PATCH 2/3] Delete unused variables --- .../main/kotlin/com/stormunblessed/PelisplusHDProvider.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt b/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt index d78f05b..9a3ea3e 100644 --- a/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt +++ b/PelisplusHDProvider/src/main/kotlin/com/stormunblessed/PelisplusHDProvider.kt @@ -57,7 +57,7 @@ class PelisplusHDProvider:MainAPI() { title, href, name, - TvType.Movie, + TvType.TvSeries, posterUrl, null, null @@ -74,14 +74,13 @@ class PelisplusHDProvider:MainAPI() { val href = it.selectFirst("a")!!.attr("href") val image = it.selectFirst(".Posters-img")?.attr("src")?.let { it1 -> fixUrl(it1) } val isMovie = href.contains("/pelicula/") - val isAnime = href.contains("/anime/") if (isMovie) { MovieSearchResponse( title, href, this.name, - TvType.Anime, + TvType.Movie, image, null ) From a56cb697ba9aad26a9f07459f718b67b101b4d4c Mon Sep 17 00:00:00 2001 From: Sebastian Pinta <36719078+SpecterNight@users.noreply.github.com> Date: Sun, 15 Dec 2024 01:06:02 -0500 Subject: [PATCH 3/3] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f97a86e..edda9b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,7 @@ on: - main paths-ignore: - '*.md' + workflow_dispatch: jobs: build: