sora: fix source

This commit is contained in:
hexated 2023-06-28 18:11:42 +07:00
parent dab8a0d0bc
commit ce0369bad6
3 changed files with 48 additions and 35 deletions

View file

@ -2760,7 +2760,7 @@ object SoraExtractor : SoraStream() {
"$nineTvAPI/tv/$tmdbId-$season-$episode" "$nineTvAPI/tv/$tmdbId-$season-$episode"
} }
val iframe = app.get(url).document.selectFirst("iframe")?.attr("src") ?: return val iframe = app.get(url, referer = "https://pressplay.top/").document.selectFirst("iframe")?.attr("src") ?: return
loadExtractor(iframe, "$nineTvAPI/", subtitleCallback, callback) loadExtractor(iframe, "$nineTvAPI/", subtitleCallback, callback)
} }

View file

@ -466,10 +466,6 @@ data class DumpQuickSearchData(
@JsonProperty("searchResults") val searchResults: ArrayList<DumpMedia>? = arrayListOf(), @JsonProperty("searchResults") val searchResults: ArrayList<DumpMedia>? = arrayListOf(),
) )
data class DumpQuickSearchRes(
@JsonProperty("data") val data: DumpQuickSearchData? = DumpQuickSearchData(),
)
data class SubtitlingList( data class SubtitlingList(
@JsonProperty("languageAbbr") val languageAbbr: String? = null, @JsonProperty("languageAbbr") val languageAbbr: String? = null,
@JsonProperty("language") val language: String? = null, @JsonProperty("language") val language: String? = null,
@ -491,7 +487,3 @@ data class EpisodeVo(
data class DumpMediaDetail( data class DumpMediaDetail(
@JsonProperty("episodeVo") val episodeVo: ArrayList<EpisodeVo>? = arrayListOf(), @JsonProperty("episodeVo") val episodeVo: ArrayList<EpisodeVo>? = arrayListOf(),
) )
data class DumpLoad(
@JsonProperty("data") val data: DumpMediaDetail? = null,
)

View file

@ -3,6 +3,7 @@ package com.hexated
import android.util.Base64 import android.util.Base64
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.hexated.DumpUtils.createHeaders import com.hexated.DumpUtils.createHeaders
import com.hexated.DumpUtils.queryApi
import com.hexated.SoraStream.Companion.anilistAPI import com.hexated.SoraStream.Companion.anilistAPI
import com.hexated.SoraStream.Companion.base64DecodeAPI import com.hexated.SoraStream.Companion.base64DecodeAPI
import com.hexated.SoraStream.Companion.baymoviesAPI import com.hexated.SoraStream.Companion.baymoviesAPI
@ -600,17 +601,16 @@ suspend fun invokeSmashyRip(
} }
suspend fun getDumpIdAndType(title: String?, year: Int?, season: Int?): Pair<String?, Int?> { suspend fun getDumpIdAndType(title: String?, year: Int?, season: Int?): Pair<String?, Int?> {
val body = mapOf( val res = tryParseJson<DumpQuickSearchData>(
"searchKeyWord" to "$title", queryApi(
"size" to "50", "POST",
"sort" to "", "${BuildConfig.DUMP_API}/search/searchWithKeyWord",
"searchType" to "", mapOf(
) "searchKeyWord" to "$title",
val res = app.post( "size" to "50",
"${BuildConfig.DUMP_API}/search/searchWithKeyWord", )
requestBody = body.toJson().toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull()), )
headers = createHeaders(body) )?.searchResults
).parsedSafe<DumpQuickSearchRes>()?.data?.searchResults
val media = if (res?.size == 1) { val media = if (res?.size == 1) {
res.firstOrNull() res.firstOrNull()
@ -641,15 +641,16 @@ suspend fun getDumpIdAndType(title: String?, year: Int?, season: Int?): Pair<Str
} }
suspend fun fetchDumpEpisodes(id: String, type: String, episode: Int?): EpisodeVo? { suspend fun fetchDumpEpisodes(id: String, type: String, episode: Int?): EpisodeVo? {
val params = mapOf( return tryParseJson<DumpMediaDetail>(
"category" to type, queryApi(
"id" to id, "GET",
) "${BuildConfig.DUMP_API}/movieDrama/get",
return app.get( mapOf(
"${BuildConfig.DUMP_API}/movieDrama/get", "category" to type,
params = params, "id" to id,
headers = createHeaders(params) )
).parsedSafe<DumpLoad>()?.data?.episodeVo?.find { )
)?.episodeVo?.find {
it.seriesNo == (episode ?: 0) it.seriesNo == (episode ?: 0)
} }
} }
@ -2056,15 +2057,32 @@ object RabbitStream {
object DumpUtils { object DumpUtils {
private val deviceId = getDeviceId() private val deviceId = getDeviceId()
fun createHeaders(
suspend fun queryApi(method: String, url: String, params: Map<String, String>): String {
return app.custom(
method,
url,
requestBody = if(method == "POST") params.toJson().toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull()) else null,
params = if(method == "GET") params else emptyMap(),
headers = createHeaders(params)
).parsedSafe<HashMap<String, String>>()?.get("data").let {
cryptoHandler(
it.toString(),
deviceId,
false
)
}
}
private fun createHeaders(
params: Map<String, String>, params: Map<String, String>,
currentTime: String = System.currentTimeMillis().toString(), currentTime: String = System.currentTimeMillis().toString(),
): Map<String, String> { ): Map<String, String> {
return mapOf( return mapOf(
"lang" to "en", "lang" to "en",
"currentTime" to currentTime, "currentTime" to currentTime,
"sign" to getSign(currentTime, params, deviceId).toString(), "sign" to getSign(currentTime, params).toString(),
"aesKey" to getAesKey(deviceId).toString(), "aesKey" to getAesKey().toString(),
) )
} }
@ -2084,13 +2102,16 @@ object DumpUtils {
} }
} }
private fun getAesKey(deviceId: String): String? { private fun getAesKey(): String? {
val publicKey = RSAEncryptionHelper.getPublicKeyFromString(BuildConfig.DUMP_KEY) ?: return null val publicKey = RSAEncryptionHelper.getPublicKeyFromString(BuildConfig.DUMP_KEY) ?: return null
return RSAEncryptionHelper.encryptText(deviceId, publicKey) return RSAEncryptionHelper.encryptText(deviceId, publicKey)
} }
private fun getSign(currentTime: String, params: Map<String, String>, deviceId: String): String? { private fun getSign(currentTime: String, params: Map<String, String>): String? {
val chipper = listOf(currentTime, params.map { it.value }.joinToString("")).joinToString("") val chipper = listOf(
currentTime,
params.map { it.value }.reversed().joinToString("")
.let { base64Encode(it.toByteArray()) }).joinToString("")
val enc = cryptoHandler(chipper, deviceId) val enc = cryptoHandler(chipper, deviceId)
return md5(enc) return md5(enc)
} }