[Sora] fixed Sorastream subtitle

This commit is contained in:
hexated 2023-01-04 06:01:24 +07:00
parent f6aa675ff4
commit c6c247e238
3 changed files with 37 additions and 19 deletions

View file

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

View file

@ -625,8 +625,10 @@ 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 = Regex("linkDetails\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1) val sourcesDetail =
val subSources = Regex("dSubtitles\\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
@ -824,7 +826,8 @@ object SoraExtractor : SoraStream() {
json?.subtitlingList?.map { sub -> json?.subtitlingList?.map { sub ->
subtitleCallback.invoke( subtitleCallback.invoke(
SubtitleFile( SubtitleFile(
sub.language ?: "", sub.subtitlingUrl ?: return@map getVipLanguage(sub.languageAbbr ?: return@map),
sub.subtitlingUrl ?: return@map
) )
) )
} }
@ -864,18 +867,19 @@ object SoraExtractor : SoraStream() {
val url = if (season == null) { val url = if (season == null) {
val tempUrl = "$xMovieAPI/movies/$fixTitle/watch" val tempUrl = "$xMovieAPI/movies/$fixTitle/watch"
val newUrl = app.get(tempUrl).url val newUrl = app.get(tempUrl).url
if(newUrl == "$xMovieAPI/") "$xMovieAPI/movies/$fixTitle-$year/watch" else tempUrl if (newUrl == "$xMovieAPI/") "$xMovieAPI/movies/$fixTitle-$year/watch" else tempUrl
} else { } else {
"$xMovieAPI/series/$fixTitle-season-$season-episode-$episode/watch" "$xMovieAPI/series/$fixTitle-season-$season-episode-$episode/watch"
} }
val doc = app.get(url).document val doc = app.get(url).document
val script = doc.selectFirst("script:containsData(const player =)")?.data() ?: return val script = doc.selectFirst("script:containsData(const player =)")?.data() ?: return
val link = Regex("[\"|']file[\"|']:\\s?[\"|'](http.*?.(mp4|m3u8))[\"|'],").find(script)?.groupValues?.getOrNull( val link =
Regex("[\"|']file[\"|']:\\s?[\"|'](http.*?.(mp4|m3u8))[\"|'],").find(script)?.groupValues?.getOrNull(
1 1
) ?: return ) ?: return
if(link.contains(".m3u8")) { if (link.contains(".m3u8")) {
M3u8Helper.generateM3u8( M3u8Helper.generateM3u8(
"Xmovie", "Xmovie",
link, link,
@ -893,7 +897,8 @@ object SoraExtractor : SoraStream() {
) )
} }
Regex(""""file":\s+?"(\S+\.(vtt|srt))""").find(script)?.groupValues?.getOrNull(1)?.let { sub -> Regex(""""file":\s+?"(\S+\.(vtt|srt))""").find(script)?.groupValues?.getOrNull(1)
?.let { sub ->
subtitleCallback.invoke( subtitleCallback.invoke(
SubtitleFile( SubtitleFile(
"English", "English",
@ -1617,14 +1622,15 @@ object SoraExtractor : SoraStream() {
val matchMedia = doc.select("article.mh-loop-item").map { val matchMedia = doc.select("article.mh-loop-item").map {
it.select("a").attr("href") to it.select("a").text() it.select("a").attr("href") to it.select("a").text()
}.find { }.find {
if(season == null) { if (season == null) {
it.second.contains(Regex("(?i)($fixTitle)|($title)")) && it.first.contains("$year") it.second.contains(Regex("(?i)($fixTitle)|($title)")) && it.first.contains("$year")
} else { } else {
it.second.contains(Regex("(?i)($fixTitle)|($title)")) && it.second.contains(Regex("(?i)(Season\\s?$season)|(S0?$season)")) it.second.contains(Regex("(?i)($fixTitle)|($title)")) && it.second.contains(Regex("(?i)(Season\\s?$season)|(S0?$season)"))
} }
} }
val mediaLink = app.get(matchMedia?.first ?: return).document.selectFirst("a#jake1")?.attr("href") val mediaLink =
app.get(matchMedia?.first ?: return).document.selectFirst("a#jake1")?.attr("href")
val detailDoc = app.get(mediaLink ?: return).document val detailDoc = app.get(mediaLink ?: return).document
val media = detailDoc.selectFirst("div.entry-content pre span")?.text() val media = detailDoc.selectFirst("div.entry-content pre span")?.text()
?.split("|") ?.split("|")
@ -1658,7 +1664,8 @@ object SoraExtractor : SoraStream() {
).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 = Regex("([0-9]{3,4})p").find(it.second)?.groupValues?.getOrNull(1)?.toIntOrNull() val quality =
Regex("([0-9]{3,4})p").find(it.second)?.groupValues?.getOrNull(1)?.toIntOrNull()
val qualityName = it.second.replace("${quality}p", "").trim() val qualityName = it.second.replace("${quality}p", "").trim()
callback.invoke( callback.invoke(

View file

@ -10,6 +10,7 @@ import com.lagradost.cloudstream3.network.WebViewResolver
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.SubtitleHelper
import com.lagradost.cloudstream3.utils.getQualityFromName import com.lagradost.cloudstream3.utils.getQualityFromName
import com.lagradost.nicehttp.RequestBodyTypes import com.lagradost.nicehttp.RequestBodyTypes
import com.lagradost.nicehttp.requestCreator import com.lagradost.nicehttp.requestCreator
@ -273,8 +274,8 @@ suspend fun bypassFdAds(url: String?): String? {
verify = false verify = false
).document ).document
val json = lastDoc.select("form#landing input[name=newwpsafelink]").attr("value").let { base64Decode(it) } val json = lastDoc.select("form#landing input[name=newwpsafelink]").attr("value").let { base64Decode(it) }
val finaJson = tryParseJson<FDAds>(json)?.linkr?.substringAfter("redirect=")?.let { base64Decode(it) } val finalJson = tryParseJson<FDAds>(json)?.linkr?.substringAfter("redirect=")?.let { base64Decode(it) }
return tryParseJson<Safelink>(finaJson)?.safelink return tryParseJson<Safelink>(finalJson)?.safelink
} }
suspend fun bypassHrefli(url: String): String? { suspend fun bypassHrefli(url: String): String? {
@ -449,6 +450,16 @@ fun getFDoviesQuality(str: String): String {
} }
} }
fun getVipLanguage(str: String): String {
return when (str) {
"in_ID" -> "Indonesian"
"pt" -> "Portuguese"
else -> str.split("_").first().let {
SubtitleHelper.fromTwoLettersToLanguage(it).toString()
}
}
}
fun getBaseUrl(url: String): String { fun getBaseUrl(url: String): String {
return URI(url).let { return URI(url).let {
"${it.scheme}://${it.host}" "${it.scheme}://${it.host}"