[Sora] fixed filmxy sub and moviezadd series

This commit is contained in:
hexated 2022-12-31 05:16:30 +07:00
parent 62f184b993
commit 3a9a9e36f4
4 changed files with 60 additions and 25 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 65 version = 66
cloudstream { cloudstream {

View file

@ -616,12 +616,13 @@ object SoraExtractor : SoraStream() {
val doc = request.document val doc = request.document
val script = doc.selectFirst("script:containsData(var isSingle)")?.data().toString() val script = doc.selectFirst("script:containsData(var isSingle)")?.data().toString()
val sourcesData = Regex("listSE\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1) val sourcesData = Regex("listSE\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1)
val sourcesDetail = val sourcesDetail = Regex("linkDetails\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1)
Regex("linkDetails\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1) val subSources = Regex("dSubtitles\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1)
//Gson is shit, but i don't care //Gson is shit, but i don't care
val sourcesJson = JsonParser().parse(sourcesData).asJsonObject val sourcesJson = JsonParser().parse(sourcesData).asJsonObject
val sourcesDetailJson = JsonParser().parse(sourcesDetail).asJsonObject val sourcesDetailJson = JsonParser().parse(sourcesDetail).asJsonObject
val subJson = JsonParser().parse(subSources).asJsonObject
val sources = if (season == null && episode == null) { val sources = if (season == null && episode == null) {
sourcesJson.getAsJsonObject("movie").getAsJsonArray("movie") sourcesJson.getAsJsonObject("movie").getAsJsonArray("movie")
@ -631,6 +632,14 @@ object SoraExtractor : SoraStream() {
sourcesJson.getAsJsonObject("s$sson").getAsJsonArray("e$eps") sourcesJson.getAsJsonObject("s$sson").getAsJsonArray("e$eps")
}.asJsonArray }.asJsonArray
val subSource = if (season == null && episode == null) {
subJson.getAsJsonObject("movie").getAsJsonObject("movie")
} else {
val eps = if (episode!! < 10) "0$episode" else episode
val sson = if (season!! < 10) "0$season" else season
subJson.getAsJsonObject("s$sson").getAsJsonObject("e$eps")
}.asJsonObject
val scriptUser = val scriptUser =
doc.select("script").find { it.data().contains("var userNonce") }?.data().toString() doc.select("script").find { it.data().contains("var userNonce") }?.data().toString()
val userNonce = val userNonce =
@ -682,6 +691,19 @@ object SoraExtractor : SoraStream() {
) )
} }
subSource.toString().removeSurrounding("{", "}").split(",").map {
val slug = Regex("\"(\\w+)\":\"(\\d+)\"").find(it)?.groupValues
slug?.getOrNull(1) to slug?.getOrNull(2)
}.map { (lang, id) ->
subtitleCallback.invoke(
SubtitleFile(
SubtitleHelper.fromTwoLettersToLanguage(lang ?: "") ?: "$lang",
"https://www.mysubs.org/get-subtitle/$id"
)
)
}
} }
suspend fun invokeKimcartoon( suspend fun invokeKimcartoon(
@ -1563,6 +1585,8 @@ object SoraExtractor : SoraStream() {
suspend fun invokeMoviezAdd( suspend fun invokeMoviezAdd(
title: String? = null, title: String? = null,
year: Int? = null, year: Int? = null,
season: Int? = null,
episode: Int? = null,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
@ -1575,44 +1599,54 @@ object SoraExtractor : SoraStream() {
it.second.contains(Regex("(?i)($fixTitle)|($title)")) && it.first.contains("$year") it.second.contains(Regex("(?i)($fixTitle)|($title)")) && it.first.contains("$year")
} }
val detailLink = val mediaLink = app.get(matchMedia?.first ?: return).document.selectFirst("a#jake1")?.attr("href")
app.get(matchMedia?.first ?: return).document.selectFirst("a#jake1")?.attr("href") val detailDoc = app.get(mediaLink ?: return).document
val media = detailDoc.selectFirst("div.entry-content pre span")?.text()
val iframeDoc = app.get(detailLink ?: return).document ?.split("|")
val media = iframeDoc.selectFirst("div.entry-content pre span")?.text()?.split("|")
?.map { it.trim() } ?.map { it.trim() }
media?.apmapIndexed { index, name -> val iframe = if (season == null) {
delay(1000) media?.mapIndexed { index, name ->
val link = iframeDoc.select("div.entry-content pre")[index.plus(1)].selectFirst("a") detailDoc.select("div.entry-content > pre")[index.plus(1)].selectFirst("a")
?.attr("href") ?: return@apmapIndexed null ?.attr("href") to name
val token = }
app.get(link).document.select("input[name=_csrf_token_645a83a41868941e4692aa31e7235f2]") } else {
.attr("value") media?.mapIndexed { index, name ->
val linkMedia =
detailDoc.select("div.entry-content > pre")[index.plus(1)].selectFirst("a")
?.attr("href")
app.get(
linkMedia ?: return@mapIndexed null
).document.selectFirst("div.entry-content strong:matches((?i)S0?${season}E0?${episode}) a")
?.attr("href") to name
}
}
iframe?.apmap {
val token = app.get(
it?.first ?: return@apmap null
).document.select("input[name=_csrf_token_645a83a41868941e4692aa31e7235f2]")
.attr("value")
val shortLink = app.post( val shortLink = app.post(
link, it.first ?: return@apmap null,
data = mapOf("_csrf_token_645a83a41868941e4692aa31e7235f2" to token) data = mapOf("_csrf_token_645a83a41868941e4692aa31e7235f2" to token)
).document.selectFirst("a[rel=nofollow]")?.attr("href") ).document.selectFirst("a[rel=nofollow]")?.attr("href")
// val videoUrl = extractRebrandly(shortLink ?: return@apmapIndexed null ) // val videoUrl = extractRebrandly(shortLink ?: return@apmapIndexed null )
val quality = val quality = Regex("([0-9]{3,4})p").find(it.second)?.groupValues?.getOrNull(1)?.toIntOrNull()
Regex("([0-9]{3,4})p").find(name)?.groupValues?.getOrNull(1)?.toIntOrNull() val qualityName = it.second.replace("${quality}p", "").trim()
val qualityName = name.replace("${quality}p", "").trim()
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
"MoviezAdd $qualityName", "MoviezAdd $qualityName",
"MoviezAdd $qualityName", "MoviezAdd $qualityName",
shortLink ?: return@apmapIndexed null, shortLink ?: return@apmap null,
"", "",
quality ?: Qualities.Unknown.value quality ?: Qualities.Unknown.value
) )
) )
} }
} }
} }

View file

@ -483,9 +483,11 @@ open class SoraStream : TmdbProvider() {
) )
}, },
{ {
if (res.season == null) invokeMoviezAdd( if (!res.isAnime) invokeMoviezAdd(
res.title, res.title,
res.year, res.year,
res.season,
res.episode,
subtitleCallback, subtitleCallback,
callback callback
) )

View file

@ -4,7 +4,6 @@ import com.hexated.TimefourTvExtractor.getLink
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper
import com.lagradost.cloudstream3.utils.Qualities
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Element import org.jsoup.nodes.Element