From b31a4c92e41ddbd1c5fff54be4afbde24d4518f3 Mon Sep 17 00:00:00 2001 From: hexated Date: Wed, 8 Feb 2023 11:50:33 +0700 Subject: [PATCH] sora: fixed UHDMovies --- SoraStream/build.gradle.kts | 2 +- .../main/kotlin/com/hexated/SoraExtractor.kt | 37 +++++++++---------- .../src/main/kotlin/com/hexated/SoraStream.kt | 3 +- .../src/main/kotlin/com/hexated/SoraUtils.kt | 16 ++++---- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/SoraStream/build.gradle.kts b/SoraStream/build.gradle.kts index 239303ee..6bddc4bd 100644 --- a/SoraStream/build.gradle.kts +++ b/SoraStream/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 86 +version = 87 cloudstream { diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt index aa8eaf65..a31a4376 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt @@ -1189,34 +1189,33 @@ object SoraExtractor : SoraStream() { season: Int? = null, lastSeason: Int? = null, episode: Int? = null, + epsTitle: String? = null, callback: (ExtractorLink) -> Unit ) { - val url = if (season == null) { - "$uhdmoviesAPI/download-${title.createSlug()}-$year" - } else { - val url = "$uhdmoviesAPI/?s=$title" - var doc = app.get(url).document - if (doc.select("title").text() == "Just a moment...") { - doc = app.get(url, interceptor = CloudflareKiller()).document - } - val scriptData = doc.select("div.row.gridlove-posts article").map { - it.selectFirst("a")?.attr("href") to it.selectFirst("h1")?.text() - } - (if (scriptData.size == 1) { - scriptData.first() - } else { - scriptData.find { it.second?.filterMedia(title, year, lastSeason) == true } - })?.first + val slug = title.createSlug()?.replace("-", " ") + val url = "$uhdmoviesAPI/?s=$slug" + var doc = app.get(url).document + if (doc.select("title").text() == "Just a moment...") { + doc = app.get(url, interceptor = CloudflareKiller()).document + } + val scriptData = doc.select("div.row.gridlove-posts article").map { + it.selectFirst("a")?.attr("href") to it.selectFirst("h1")?.text() } - val detailDoc = app.get(url ?: return).document + val detailUrl = (if (scriptData.size == 1) { + scriptData.first() + } else { + scriptData.find { it.second?.filterMedia(title, year, lastSeason) == true } + })?.first + + val detailDoc = app.get(detailUrl ?: return).document val iframeList = detailDoc.select("div.entry-content p").map { it } - .filter { it.text().filterIframe(season, lastSeason, year) }.mapNotNull { + .filter { it.text().filterIframe(season, lastSeason, year, title) }.mapNotNull { if (season == null) { it.text() to it.nextElementSibling()?.select("a")?.attr("href") } else { - it.text() to it.nextElementSibling()?.select("a:contains(Episode $episode)") + it.text() to it.nextElementSibling()?.select("a:matches((Episode $episode)|($epsTitle))") ?.attr("href") } }.filter { it.second?.contains(Regex("(https:)|(http:)")) == true } diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt index c416240b..82b3635c 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt @@ -96,7 +96,7 @@ open class SoraStream : TmdbProvider() { const val consumetCrunchyrollAPI = "https://api.consumet.org/anime/crunchyroll" const val kissKhAPI = "https://kisskh.me" const val lingAPI = "https://ling-online.net" - const val uhdmoviesAPI = "https://uhdmovies.org.in" + const val uhdmoviesAPI = "https://uhdmovies.world" const val fwatayakoAPI = "https://5100.svetacdn.in" const val gMoviesAPI = "https://gdrivemovies.xyz" const val fdMoviesAPI = "https://freedrivemovie.lol" @@ -480,6 +480,7 @@ open class SoraStream : TmdbProvider() { res.season, res.lastSeason, res.episode, + res.epsTitle, callback ) }, diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt b/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt index 30a12de2..39a7ec2f 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt @@ -38,7 +38,10 @@ data class FilmxyCookies( val wSec: String? = null, ) -fun String.filterIframe(seasonNum: Int?, lastSeason: Int?, year: Int?): Boolean { +fun String.filterIframe(seasonNum: Int?, lastSeason: Int?, year: Int?, title: String?): Boolean { + val slug = title.createSlug() + val dotSlug = slug?.replace("-", ".") + val spaceSlug = slug?.replace("-", " ") return if (seasonNum != null) { if (lastSeason == 1) { this.contains(Regex("(?i)(S0?$seasonNum)|(Season\\s0?$seasonNum)|(\\d{3,4}p)")) && !this.contains( @@ -52,24 +55,23 @@ fun String.filterIframe(seasonNum: Int?, lastSeason: Int?, year: Int?): Boolean ) } } else { - this.contains("$year", true) && !this.contains("Download", true) + this.contains(Regex("(?i)($year)|($dotSlug)|($spaceSlug)")) && !this.contains("Download", true) } } fun String.filterMedia(title: String?, yearNum: Int?, seasonNum: Int?): Boolean { + val fixTitle = title.createSlug()?.replace("-", " ") return if (seasonNum != null) { when { seasonNum > 1 -> this.contains(Regex("(?i)(Season\\s0?1-0?$seasonNum)|(S0?1-S?0?$seasonNum)")) && this.contains( - "$title", - true + Regex("(?i)($fixTitle)|($title)") ) else -> this.contains(Regex("(?i)(Season\\s0?1)|(S0?1)")) && this.contains( - "$title", - true + Regex("(?i)($fixTitle)|($title)") ) && this.contains("$yearNum") } } else { - this.contains("$title", true) && this.contains("$yearNum") + this.contains(Regex("(?i)($fixTitle)|($title)")) && this.contains("$yearNum") } }