fix build

This commit is contained in:
hexated 2023-05-03 02:45:23 +07:00
parent 51556f94b6
commit 34aae5c115
10 changed files with 335 additions and 71 deletions

View file

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

View file

@ -0,0 +1,166 @@
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.base64Decode
import com.lagradost.cloudstream3.base64DecodeArray
import com.lagradost.cloudstream3.base64Encode
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import com.lagradost.cloudstream3.utils.getQualityFromName
import org.jsoup.nodes.Document
import java.net.URI
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
object GogoExtractor {
/**
* @param id base64Decode(show_id) + IV
* @return the encryption key
* */
private fun getKey(id: String): String? {
return normalSafeApiCall {
id.map {
it.code.toString(16)
}.joinToString("").substring(0, 32)
}
}
// https://github.com/saikou-app/saikou/blob/3e756bd8e876ad7a9318b17110526880525a5cd3/app/src/main/java/ani/saikou/anime/source/extractors/GogoCDN.kt#L60
// No Licence on the function
private fun cryptoHandler(
string: String,
iv: String,
secretKeyString: String,
encrypt: Boolean = true
): String {
//println("IV: $iv, Key: $secretKeyString, encrypt: $encrypt, Message: $string")
val ivParameterSpec = IvParameterSpec(iv.toByteArray())
val secretKey = SecretKeySpec(secretKeyString.toByteArray(), "AES")
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
return if (!encrypt) {
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec)
String(cipher.doFinal(base64DecodeArray(string)))
} else {
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParameterSpec)
base64Encode(cipher.doFinal(string.toByteArray()))
}
}
/**
* @param iframeUrl something like https://gogoplay4.com/streaming.php?id=XXXXXX
* @param mainApiName used for ExtractorLink names and source
* @param iv secret iv from site, required non-null if isUsingAdaptiveKeys is off
* @param secretKey secret key for decryption from site, required non-null if isUsingAdaptiveKeys is off
* @param secretDecryptKey secret key to decrypt the response json, required non-null if isUsingAdaptiveKeys is off
* @param isUsingAdaptiveKeys generates keys from IV and ID, see getKey()
* @param isUsingAdaptiveData generate encrypt-ajax data based on $("script[data-name='episode']")[0].dataset.value
* */
suspend fun extractVidstream(
iframeUrl: String,
mainApiName: String,
callback: (ExtractorLink) -> Unit,
iv: String?,
secretKey: String?,
secretDecryptKey: String?,
// This could be removed, but i prefer it verbose
isUsingAdaptiveKeys: Boolean,
isUsingAdaptiveData: Boolean,
// If you don't want to re-fetch the document
iframeDocument: Document? = null
) = safeApiCall {
// https://github.com/saikou-app/saikou/blob/3e756bd8e876ad7a9318b17110526880525a5cd3/app/src/main/java/ani/saikou/anime/source/extractors/GogoCDN.kt
// No Licence on the following code
// Also modified of https://github.com/jmir1/aniyomi-extensions/blob/master/src/en/gogoanime/src/eu/kanade/tachiyomi/animeextension/en/gogoanime/extractors/GogoCdnExtractor.kt
// License on the code above https://github.com/jmir1/aniyomi-extensions/blob/master/LICENSE
if ((iv == null || secretKey == null || secretDecryptKey == null) && !isUsingAdaptiveKeys)
return@safeApiCall
val id = Regex("id=([^&]+)").find(iframeUrl)!!.value.removePrefix("id=")
var document: Document? = iframeDocument
val foundIv =
iv ?: (document ?: app.get(iframeUrl).document.also { document = it })
.select("""div.wrapper[class*=container]""")
.attr("class").split("-").lastOrNull() ?: return@safeApiCall
val foundKey = secretKey ?: getKey(base64Decode(id) + foundIv) ?: return@safeApiCall
val foundDecryptKey = secretDecryptKey ?: foundKey
val uri = URI(iframeUrl)
val mainUrl = "https://" + uri.host
val encryptedId = cryptoHandler(id, foundIv, foundKey)
val encryptRequestData = if (isUsingAdaptiveData) {
// Only fetch the document if necessary
val realDocument = document ?: app.get(iframeUrl).document
val dataEncrypted =
realDocument.select("script[data-name='episode']").attr("data-value")
val headers = cryptoHandler(dataEncrypted, foundIv, foundKey, false)
"id=$encryptedId&alias=$id&" + headers.substringAfter("&")
} else {
"id=$encryptedId&alias=$id"
}
val jsonResponse =
app.get(
"$mainUrl/encrypt-ajax.php?$encryptRequestData",
headers = mapOf("X-Requested-With" to "XMLHttpRequest")
)
val dataencrypted =
jsonResponse.text.substringAfter("{\"data\":\"").substringBefore("\"}")
val datadecrypted = cryptoHandler(dataencrypted, foundIv, foundDecryptKey, false)
val sources = AppUtils.parseJson<GogoSources>(datadecrypted)
suspend fun invokeGogoSource(
source: GogoSource,
sourceCallback: (ExtractorLink) -> Unit
) {
if (source.file.contains(".m3u8")) {
M3u8Helper.generateM3u8(
mainApiName,
source.file,
mainUrl,
headers = mapOf("Origin" to "https://plyr.link")
).forEach(sourceCallback)
} else {
sourceCallback.invoke(
ExtractorLink(
mainApiName,
mainApiName,
source.file,
mainUrl,
getQualityFromName(source.label),
)
)
}
}
sources.source?.forEach {
invokeGogoSource(it, callback)
}
sources.sourceBk?.forEach {
invokeGogoSource(it, callback)
}
}
data class GogoSources(
@JsonProperty("source") val source: List<GogoSource>?,
@JsonProperty("sourceBk") val sourceBk: List<GogoSource>?,
//val track: List<Any?>,
//val advertising: List<Any?>,
//val linkiframe: String
)
data class GogoSource(
@JsonProperty("file") val file: String,
@JsonProperty("label") val label: String?,
@JsonProperty("type") val type: String?,
@JsonProperty("default") val default: String? = null
)
}

View file

@ -3,6 +3,7 @@ package com.hexated
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.httpsify
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.nodes.Element
@ -96,18 +97,6 @@ class Kissasian : MainAPI() {
}
}
private suspend fun invokeDembedSource(
url: String,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val document = app.get(url).document
document.select("ul.list-server-items li").map {
val iframe = it.attr("data-video").substringBefore("=http")
loadExtractor(iframe, "$mainUrl/", subtitleCallback, callback)
}
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
@ -116,21 +105,34 @@ class Kissasian : MainAPI() {
): Boolean {
val document = app.get(data).document
val server = document.selectFirst("select#selectServer option")?.attr("value")
val iframe = app.get(httpsify(server ?: return false))
val iframeDoc = iframe.document
document.select("select#selectServer option").apmap {
safeApiCall {
val iframe = fixUrl(it.attr("value"))
when {
iframe.startsWith("https://dembed2.com") -> invokeDembedSource(
iframe,
subtitleCallback,
callback
)
else -> loadExtractor(iframe, "$mainUrl/", subtitleCallback, callback)
argamap({
iframeDoc.select(".list-server-items > .linkserver")
.forEach { element ->
val status = element.attr("data-status") ?: return@forEach
if (status != "1") return@forEach
val extractorData = element.attr("data-video") ?: return@forEach
loadExtractor(extractorData, iframe.url, subtitleCallback, callback)
}
}
}
}, {
val iv = "9262859232435825"
val secretKey = "93422192433952489752342908585752"
val secretDecryptKey = secretKey
GogoExtractor.extractVidstream(
iframe.url,
this.name,
callback,
iv,
secretKey,
secretDecryptKey,
isUsingAdaptiveKeys = false,
isUsingAdaptiveData = true,
iframeDocument = iframeDoc
)
})
return true
}

View file

@ -15,6 +15,21 @@ import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.PBEKeySpec
import javax.crypto.spec.SecretKeySpec
class Sbasian : StreamSB() {
override var mainUrl = "https://sbasian.pro"
override var name = "Sbasian"
}
class Fembed9hd : XStreamCdn() {
override var mainUrl = "https://fembed9hd.com"
override var name = "Fembed9hd"
}
class Moviesm4u : Filesim() {
override val mainUrl = "https://moviesm4u.com"
override val name = "Moviesm4u"
}
class Sbnet : StreamSB() {
override var name = "Sbnet"
override var mainUrl = "https://sbnet.one"

View file

@ -865,6 +865,7 @@ object SoraExtractor : SoraStream() {
suspend fun invokeAnimes(
id: Int? = null,
title: String? = null,
jpTitle: String? = null,
epsTitle: String? = null,
year: Int? = null,
season: Int? = null,
@ -894,48 +895,60 @@ object SoraExtractor : SoraStream() {
invokeBiliBili(aniId, episode, subtitleCallback, callback)
},
{
if (season != null) invokeAllanime(aniId, episode, callback)
if (season != null) invokeAllanime(aniId, title, jpTitle, episode, callback)
}
)
}
private suspend fun invokeAllanime(
aniId: String? = null,
title: String? = null,
jpTitle: String? = null,
episode: Int? = null,
callback: (ExtractorLink) -> Unit
) {
val searchHash = "b645a686b1988327795e1203867ed24f27c6338b41e5e3412fc1478a8ab6774e"
val serverHash = "0ac09728ee9d556967c1a60bbcf55a9f58b4112006d09a258356aeafe1c33889"
val aniDetail = app.get("$consumetAnilistAPI/info/$aniId").parsedSafe<ConsumetDetails>()
val searchQuaery =
"""$allanimeAPI/allanimeapi?variables={"search":{"query":"${aniDetail?.title?.romaji ?: return}","allowAdult":false,"allowUnknown":false},"limit":26,"page":1,"translationType":"sub","countryOrigin":"ALL"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"$searchHash"}}"""
val id = app.get(searchQuaery)
.parsedSafe<AllanimeResponses>()?.data?.shows?.edges?.find {
it.thumbnail == aniDetail.cover || it.thumbnail == aniDetail.image || ((it.name?.equals(
aniDetail.title.romaji,
true
) == true || it.englishName?.equals(
aniDetail.title.romaji,
true
) == true) && it.airedStart?.year == aniDetail.releaseDate)
}?._id
val aniDetail = app.get("$consumetAnilistAPI/info/$aniId").parsedSafe<ConsumetDetails>() ?: return
val edges = app.get(allanimeQueries("""{"search":{"query":"$title","allowAdult":false,"allowUnknown":false},"limit":26,"page":1,"translationType":"sub","countryOrigin":"ALL"}""", allanimeSearchQuery))
.parsedSafe<AllanimeResponses>()?.data?.shows?.edges
val id = edges?.let { edge ->
if (edges.size == 1) {
edge.firstOrNull()
} else {
edge.find {
(it.thumbnail == aniDetail.cover || it.thumbnail == aniDetail.image) || (
(it.name.equals(
aniDetail.title?.romaji,
true
) || it.name.equals(
jpTitle,
true
) || it.englishName.equals(aniDetail.title?.english, true))
&& it.airedStart?.year == aniDetail.releaseDate)
} ?: edge.find {
it.name.equals(
aniDetail.title?.romaji,
true
) || it.name.equals(
jpTitle,
true
) || it.englishName.equals(aniDetail.title?.english, true) || it.englishName.equals(title, true)
}
}
}?._id ?: return
listOf(
"sub",
"dub"
).apmap { tl ->
val serverQuery =
"""$allanimeAPI/allanimeapi?variables={"showId":"${id ?: return@apmap}","translationType":"$tl","episodeString":"$episode"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"$serverHash"}}"""
val server = app.get(serverQuery)
val server = app.get(allanimeQueries("""{"showId":"$id","translationType":"$tl","episodeString":"$episode"}""", allanimeServerQuery))
.parsedSafe<AllanimeResponses>()?.data?.episode?.sourceUrls?.find { it.sourceName == "Ac" }
val serverUrl = fixUrl(
server?.sourceUrl?.replace("/clock", "/clock.json") ?: return@apmap,
"https://blog.allanime.pro"
)
app.get(serverUrl)
.parsedSafe<AllanimeLinks>()?.links?.filter { it.resolutionStr == "RAW" && it.hls == true }?.forEach { source ->
.parsedSafe<AllanimeLinks>()?.links?.filter { it.resolutionStr == "RAW" && it.hls == true }
?.forEach { source ->
val translation = if (tl == "sub") "Raw" else "English Dub"
M3u8Helper.generateM3u8(
"Vrv [$translation]",
@ -1470,7 +1483,7 @@ object SoraExtractor : SoraStream() {
val doc = request.document
val token = doc.selectFirst("meta[name=csrf-token]")?.attr("content")
val m4uData = if (season == null) {
doc.select("div.le-server span#fem").attr("data")
doc.select("div.le-server span").map { it.attr("data") }
} else {
val episodeData =
doc.selectFirst("div.col-lg-9.col-xl-9 p:matches((?i)S0?$season-E0?$episode$)")
@ -1493,26 +1506,28 @@ object SoraExtractor : SoraStream() {
session =
cookiesSet.find { it.second.contains("laravel_session") }?.second?.substringAfter("laravel_session=")
?.substringBefore(";")
requestEmbed.document.select("span#fem").attr("data")
requestEmbed.document.select("div.le-server span").map { it.attr("data") }
}
val iframe = app.post(
"$m4uhdAPI/ajax",
data = mapOf(
"m4u" to m4uData, "_token" to "$token"
),
referer = link,
headers = mapOf(
"Accept" to "*/*",
"X-Requested-With" to "XMLHttpRequest",
),
cookies = mapOf(
"laravel_session" to "$session",
"XSRF-TOKEN" to "$xsrf",
),
).document.select("iframe").attr("src")
m4uData.apmap { data ->
val iframe = app.post(
"$m4uhdAPI/ajax",
data = mapOf(
"m4u" to data, "_token" to "$token"
),
referer = link,
headers = mapOf(
"Accept" to "*/*",
"X-Requested-With" to "XMLHttpRequest",
),
cookies = mapOf(
"laravel_session" to "$session",
"XSRF-TOKEN" to "$xsrf",
),
).document.select("iframe").attr("src")
loadExtractor(iframe, m4uhdAPI, subtitleCallback, callback)
loadExtractor(iframe, m4uhdAPI, subtitleCallback, callback)
}
}

View file

@ -243,10 +243,11 @@ open class SoraStream : TmdbProvider() {
override suspend fun load(url: String): LoadResponse? {
val data = parseJson<Data>(url)
val type = getType(data.type)
val append = "alternative_titles,credits,external_ids,keywords,videos,recommendations"
val resUrl = if (type == TvType.Movie) {
"$tmdbAPI/movie/${data.id}?api_key=$apiKey&append_to_response=keywords,credits,external_ids,videos,recommendations"
"$tmdbAPI/movie/${data.id}?api_key=$apiKey&append_to_response=$append"
} else {
"$tmdbAPI/tv/${data.id}?api_key=$apiKey&append_to_response=keywords,credits,external_ids,videos,recommendations"
"$tmdbAPI/tv/${data.id}?api_key=$apiKey&append_to_response=$append"
}
val res = app.get(resUrl).parsedSafe<MediaDetail>()
?: throw ErrorLoadingException("Invalid Json Response")
@ -297,6 +298,7 @@ open class SoraStream : TmdbProvider() {
airedYear = year,
lastSeason = lastSeason,
epsTitle = eps.name,
jpTitle = res.alternative_titles?.results?.find { it.iso_3166_1 == "JP" }?.title
).toJson(),
name = eps.name,
season = eps.seasonNumber,
@ -339,6 +341,7 @@ open class SoraStream : TmdbProvider() {
year = year,
orgTitle = orgTitle,
isAnime = isAnime,
jpTitle = res.alternative_titles?.results?.find { it.iso_3166_1 == "JP" }?.title
).toJson(),
) {
this.posterUrl = poster
@ -405,6 +408,7 @@ open class SoraStream : TmdbProvider() {
if (res.isAnime) invokeAnimes(
res.id,
res.title,
res.jpTitle,
res.epsTitle,
res.airedYear ?: res.year,
res.season,
@ -875,6 +879,7 @@ open class SoraStream : TmdbProvider() {
val airedYear: Int? = null,
val lastSeason: Int? = null,
val epsTitle: String? = null,
val jpTitle: String? = null,
)
data class Data(
@ -951,6 +956,16 @@ open class SoraStream : TmdbProvider() {
@JsonProperty("results") val results: ArrayList<Trailers>? = arrayListOf(),
)
data class AltTitles(
@JsonProperty("iso_3166_1") val iso_3166_1: String? = null,
@JsonProperty("title") val title: String? = null,
@JsonProperty("type") val type: String? = null,
)
data class ResultsAltTitles(
@JsonProperty("results") val results: ArrayList<AltTitles>? = arrayListOf(),
)
data class ExternalIds(
@JsonProperty("imdb_id") val imdb_id: String? = null,
@JsonProperty("tvdb_id") val tvdb_id: String? = null,
@ -993,6 +1008,7 @@ open class SoraStream : TmdbProvider() {
@JsonProperty("external_ids") val external_ids: ExternalIds? = null,
@JsonProperty("credits") val credits: Credits? = null,
@JsonProperty("recommendations") val recommendations: ResultsRecommendations? = null,
@JsonProperty("alternative_titles") val alternative_titles: ResultsAltTitles? = null,
)
data class EmbedJson(

View file

@ -108,6 +108,7 @@ class SoraStreamLite : SoraStream() {
if (res.isAnime) invokeAnimes(
res.id,
res.title,
res.jpTitle,
res.epsTitle,
res.airedYear ?: res.year,
res.season,

View file

@ -20,5 +20,8 @@ class SoraStreamPlugin: Plugin() {
registerExtractorAPI(Watchx())
registerExtractorAPI(StreamhideCom())
registerExtractorAPI(Movhide())
registerExtractorAPI(Moviesm4u())
registerExtractorAPI(Fembed9hd())
registerExtractorAPI(Sbasian())
}
}

View file

@ -2,6 +2,7 @@ package com.hexated
import android.util.Base64
import com.fasterxml.jackson.annotation.JsonProperty
import com.hexated.SoraStream.Companion.allanimeAPI
import com.hexated.SoraStream.Companion.base64DecodeAPI
import com.hexated.SoraStream.Companion.baymoviesAPI
import com.hexated.SoraStream.Companion.consumetCrunchyrollAPI
@ -44,14 +45,55 @@ import kotlin.math.min
val soraAPI = base64DecodeAPI("cA==YXA=cy8=Y20=di8=LnQ=b2s=a2w=bG8=aS4=YXA=ZS0=aWw=b2I=LW0=Z2E=Ly8=czo=dHA=aHQ=")
val bflixChipperKey = base64DecodeAPI("Yjc=ejM=TzA=YTk=WHE=WnU=bXU=RFo=")
val bflixKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
val soraHeaders = mapOf(
"lang" to "en",
"versioncode" to "33",
"clienttype" to "android_Official",
"deviceid" to getDeviceId(),
)
val allanimeSearchQuery = """
query(
${'$'}search: SearchInput
${'$'}limit: Int
${'$'}page: Int
${'$'}translationType: VaildTranslationTypeEnumType
${'$'}countryOrigin: VaildCountryOriginEnumType
) {
shows(
search: ${'$'}search
limit: ${'$'}limit
page: ${'$'}page
translationType: ${'$'}translationType
countryOrigin: ${'$'}countryOrigin
) {
pageInfo {
total
}
edges {
_id
name
thumbnail
englishName
nativeName
}
}
}
""".trimIndent().trim()
val allanimeServerQuery = """
query(
${'$'}showId: String!,
${'$'}translationType: VaildTranslationTypeEnumType!,
${'$'}episodeString: String!
) {
episode(
showId: ${'$'}showId
translationType: ${'$'}translationType
episodeString: ${'$'}episodeString
) {
sourceUrls
}
}
""".trimIndent().trim()
val encodedIndex = arrayOf(
"GamMovies",
"JSMovies",
@ -1044,6 +1086,10 @@ fun String.decryptGomoviesJson(key: String = "123"): String {
return sb.toString()
}
fun allanimeQueries(variables: String, query: String) : String {
return "${allanimeAPI}/allanimeapi?variables=$variables&query=$query"
}
fun Headers.getGomoviesCookies(cookieKey: String = "set-cookie"): Map<String, String> {
val cookieList =
this.filter { it.first.equals(cookieKey, ignoreCase = true) }.mapNotNull {

View file

@ -10,7 +10,7 @@ import org.jsoup.nodes.Element
import java.net.URI
class YomoviesProvider : MainAPI() {
override var mainUrl = "https://yomovies.rest"
override var mainUrl = "https://yomovies.hair"
private var directUrl = mainUrl
override var name = "Yomovies"
override val hasMainPage = true