[Sora] fix .

This commit is contained in:
hexated 2022-12-10 03:54:40 +07:00
parent 978c5bc6ba
commit 2876dea2d1
4 changed files with 42 additions and 22 deletions

View file

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

View file

@ -10,7 +10,9 @@ import com.lagradost.nicehttp.Session
import com.google.gson.JsonParser
import com.lagradost.cloudstream3.extractors.XStreamCdn
import com.lagradost.cloudstream3.network.CloudflareKiller
import com.lagradost.nicehttp.RequestBodyTypes
import kotlinx.coroutines.delay
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody
val session = Session(Requests().baseClient)
@ -830,26 +832,25 @@ object SoraExtractor : SoraStream() {
)
}
json?.definitionList?.apmap { video ->
delay(1000)
app.get(
"${vipAPI}/media/previewInfo?category=${type}&contentId=${id}&episodeId=${json.id}&definition=${video.code}",
headers = headers
).parsedSafe<Video>()?.data.let { link ->
callback.invoke(
ExtractorLink(
"${this.name} (vip)",
"${this.name} (vip)",
link?.mediaUrl ?: return@let,
"",
getQualityFromName(video.description),
isM3u8 = true,
headers = headers
)
json?.definitionList?.map { video ->
val body = """[{"category":$type,"contentId":"$id","episodeId":${json.id},"definition":"${video.code}"}]""".toRequestBody(
RequestBodyTypes.JSON.toMediaTypeOrNull())
val response = app.post(
"${vipAPI}/media/bathGetplayInfo",
requestBody = body,
headers = headers,
).text.let { tryParseJson<PreviewResponse>(it)?.data?.firstOrNull() }
callback.invoke(
ExtractorLink(
this.name,
this.name,
response?.mediaUrl ?: return@map null,
"",
getSoraQuality(response.currentDefinition ?: ""),
isM3u8 = true,
)
}
)
}
}
suspend fun invokeXmovies(
@ -1653,4 +1654,13 @@ data class DriveBotLink(
data class DirectDl(
@JsonProperty("download_url") val download_url: String? = null,
)
data class PreviewResponse(
@JsonProperty("data") val data: ArrayList<PreviewVideos>? = arrayListOf(),
)
data class PreviewVideos(
@JsonProperty("mediaUrl") val mediaUrl: String? = null,
@JsonProperty("currentDefinition") val currentDefinition: String? = null,
)

View file

@ -425,9 +425,9 @@ open class SoraStream : TmdbProvider() {
{
if(!res.isAnime) invokeGMovies(res.title, res.year, res.season, res.episode, subtitleCallback, callback)
},
{
if(!res.isAnime) invokeFDMovies(res.title, res.season, res.episode, subtitleCallback, callback)
},
// {
// if(!res.isAnime) invokeFDMovies(res.title, res.season, res.episode, subtitleCallback, callback)
// },
{
invokeM4uhd(res.title, res.year, res.season, res.episode, subtitleCallback, callback)
}

View file

@ -303,6 +303,16 @@ fun getGMoviesQuality(str: String): Int {
}
}
fun getSoraQuality(quality: String): Int {
return when (quality) {
"GROOT_FD" -> Qualities.P360.value
"GROOT_LD" -> Qualities.P480.value
"GROOT_SD" -> Qualities.P720.value
"GROOT_HD" -> Qualities.P1080.value
else -> Qualities.Unknown.value
}
}
fun getBaseUrl(url: String): String {
return URI(url).let {
"${it.scheme}://${it.host}"