sora: fix build again

This commit is contained in:
hexated 2023-03-17 21:54:02 +07:00
parent 18690c1cd9
commit 27134f1c10

View file

@ -46,7 +46,13 @@ object SoraExtractor : SoraStream() {
).parsedSafe<EmbedJson>()?.let { source -> ).parsedSafe<EmbedJson>()?.let { source ->
val link = source.link ?: return@let val link = source.link ?: return@let
if (link.contains("rabbitstream")) { if (link.contains("rabbitstream")) {
extractRabbitStream(link, subtitleCallback, callback, false, decryptKey = RabbitStream.getKey()) { it } extractRabbitStream(
link,
subtitleCallback,
callback,
false,
decryptKey = RabbitStream.getKey()
) { it }
} else { } else {
loadExtractor( loadExtractor(
link, twoEmbedAPI, subtitleCallback, callback link, twoEmbedAPI, subtitleCallback, callback
@ -518,7 +524,8 @@ object SoraExtractor : SoraStream() {
val doc = session.get(url, cookies = cookiesDoc).document val doc = session.get(url, cookies = cookiesDoc).document
val script = doc.selectFirst("script:containsData(var isSingle)")?.data() ?: return val script = doc.selectFirst("script:containsData(var isSingle)")?.data() ?: return
val sourcesData = Regex("listSE\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1).let { val sourcesData =
Regex("listSE\\s*=\\s?(.*?),[\\n|\\s]").find(script)?.groupValues?.get(1).let {
tryParseJson<HashMap<String, HashMap<String, List<String>>>>(it) tryParseJson<HashMap<String, HashMap<String, List<String>>>>(it)
} }
val sourcesDetail = val sourcesDetail =
@ -762,7 +769,10 @@ object SoraExtractor : SoraStream() {
"$fixTitle", true "$fixTitle", true
) == true && it.releaseDate?.equals("$year") == true && it.type == "Movie" ) == true && it.releaseDate?.equals("$year") == true && it.type == "Movie"
} else { } else {
it.title?.equals("$fixTitle", true) == true && it.type == "TV Series" && it.seasons == lastSeason it.title?.equals(
"$fixTitle",
true
) == true && it.type == "TV Series" && it.seasons == lastSeason
} }
}?.id ?: return }?.id ?: return
@ -940,7 +950,9 @@ object SoraExtractor : SoraStream() {
.parsedSafe<BiliBiliSourcesResponse>() .parsedSafe<BiliBiliSourcesResponse>()
sources?.sources?.apmap { source -> sources?.sources?.apmap { source ->
val quality = app.get(source.file ?: return@apmap null).document.selectFirst("Representation")?.attr("height") val quality =
app.get(source.file ?: return@apmap null).document.selectFirst("Representation")
?.attr("height")
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
"BiliBili", "BiliBili",
@ -1167,7 +1179,9 @@ object SoraExtractor : SoraStream() {
it.text() to it.nextElementSibling()?.select("a")?.attr("href") it.text() to it.nextElementSibling()?.select("a")?.attr("href")
} else { } else {
it.text() to it.nextElementSibling() it.text() to it.nextElementSibling()
?.select("a")?.find { child -> child.select("span").text().equals("Episode $episode", true) } ?.select("a")?.find { child ->
child.select("span").text().equals("Episode $episode", true)
}
?.attr("href") ?.attr("href")
} }
}.filter { it.second?.contains(Regex("(https:)|(http:)")) == true } }.filter { it.second?.contains(Regex("(https:)|(http:)")) == true }
@ -1525,7 +1539,8 @@ object SoraExtractor : SoraStream() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
val id = searchCrunchyrollAnimeId(title ?: return) ?: return val id = searchCrunchyrollAnimeId(title ?: return) ?: return
val detail = app.get("$consumetCrunchyrollAPI/info/$id?fetchAllSeasons=true", timeout = 600L).text val detail =
app.get("$consumetCrunchyrollAPI/info/$id?fetchAllSeasons=true", timeout = 600L).text
val epsId = tryParseJson<CrunchyrollDetails>(detail)?.findCrunchyrollId( val epsId = tryParseJson<CrunchyrollDetails>(detail)?.findCrunchyrollId(
season, season,
episode, episode,
@ -1535,7 +1550,10 @@ object SoraExtractor : SoraStream() {
epsId?.apmap { epsId?.apmap {
delay(2000) delay(2000)
val json = val json =
app.get("$consumetCrunchyrollAPI/watch/${it?.first?.id ?: return@apmap null}", timeout = 600L) app.get(
"$consumetCrunchyrollAPI/watch/${it?.first?.id ?: return@apmap null}",
timeout = 600L
)
.parsedSafe<ConsumetSourcesResponse>() .parsedSafe<ConsumetSourcesResponse>()
json?.sources?.map source@{ source -> json?.sources?.map source@{ source ->
@ -1590,7 +1608,11 @@ object SoraExtractor : SoraStream() {
} ?: return } ?: return
val seasonData = val seasonData =
app.get("$kickassanimeAPI/api/season/$animeId").text.let { tryParseJson<List<KaaSeason>>(it) }?.find { app.get("$kickassanimeAPI/api/season/$animeId").text.let {
tryParseJson<List<KaaSeason>>(
it
)
}?.find {
val seasonNumber = when (title) { val seasonNumber = when (title) {
"One Piece" -> 13 "One Piece" -> 13
"Hunter x Hunter" -> 5 "Hunter x Hunter" -> 5
@ -1607,10 +1629,14 @@ object SoraExtractor : SoraStream() {
val episodeSlug = val episodeSlug =
app.get("$kickassanimeAPI/api/episodes/${seasonData.id}?lh=$lang&page=1") app.get("$kickassanimeAPI/api/episodes/${seasonData.id}?lh=$lang&page=1")
.parsedSafe<KaaEpisodeResults>()?.result?.find { eps -> .parsedSafe<KaaEpisodeResults>()?.result?.find { eps ->
eps.episodeNumber == episode || eps.slug?.contains("${epsTitle.createSlug()}", true) == true eps.episodeNumber == episode || eps.slug?.contains(
"${epsTitle.createSlug()}",
true
) == true
}?.slug ?: return@apmap }?.slug ?: return@apmap
val server = app.get("$kickassanimeAPI/api/watch/$episodeSlug").parsedSafe<KaaServers>()?.servers?.find { val server = app.get("$kickassanimeAPI/api/watch/$episodeSlug")
.parsedSafe<KaaServers>()?.servers?.find {
it.contains("/sapphire-duck/") it.contains("/sapphire-duck/")
} ?: return@apmap } ?: return@apmap
@ -1633,7 +1659,8 @@ object SoraExtractor : SoraStream() {
val media = json?.find { it.first() == "${title.createSlug()}-$year" } val media = json?.find { it.first() == "${title.createSlug()}-$year" }
media?.filter { it.startsWith("https://drive.google.com") || it.startsWith("https://cdn.moviesbay.live") }?.apmap { media?.filter { it.startsWith("https://drive.google.com") || it.startsWith("https://cdn.moviesbay.live") }
?.apmap {
val index = media.indexOf(it) val index = media.indexOf(it)
val size = media[index.minus(1)] val size = media[index.minus(1)]
val quality = media[index.minus(2)] val quality = media[index.minus(2)]
@ -1928,7 +1955,10 @@ object SoraExtractor : SoraStream() {
"$smashyStreamAPI/playere.php?imdb=$imdbId&season=$season&episode=$episode" "$smashyStreamAPI/playere.php?imdb=$imdbId&season=$season&episode=$episode"
} }
app.get(url, referer = "https://smashystream.com/").document.select("div#_default-servers a.server").map { app.get(
url,
referer = "https://smashystream.com/"
).document.select("div#_default-servers a.server").map {
it.attr("data-id") to it.text() it.attr("data-id") to it.text()
}.apmap { }.apmap {
when { when {
@ -2340,7 +2370,8 @@ object SoraExtractor : SoraStream() {
// removed due to rate limit // removed due to rate limit
// if (!app.get(path).isSuccessful) return@apmap null // if (!app.get(path).isSuccessful) return@apmap null
val size = "%.2f GB".format(bytesToGigaBytes(file.size?.toDouble() ?: return@apmap null)) val size =
"%.2f GB".format(bytesToGigaBytes(file.size?.toDouble() ?: return@apmap null))
val quality = getIndexQuality(file.name) val quality = getIndexQuality(file.name)
val tags = getIndexQualityTags(file.name) val tags = getIndexQualityTags(file.name)
@ -2668,8 +2699,7 @@ object SoraExtractor : SoraStream() {
"$watchOnlineAPI/api/v1/security/episode-access?id=$episodeId" "$watchOnlineAPI/api/v1/security/episode-access?id=$episodeId"
} }
val json = app.get(videoUrl, referer = url) val json = app.get(videoUrl, referer = url).parsedSafe<WatchOnlineResponse>()
.parsedSafe<WatchOnlineResponse>()
json?.streams?.mapKeys { source -> json?.streams?.mapKeys { source ->
callback.invoke( callback.invoke(
@ -2689,12 +2719,56 @@ object SoraExtractor : SoraStream() {
subtitles.map { sub -> subtitles.map { sub ->
subtitleCallback.invoke( subtitleCallback.invoke(
SubtitleFile( SubtitleFile(
sub["language"] ?: return@map, sub["language"] ?: return@map, fixUrl(sub["url"] ?: return@map, watchOnlineAPI)
fixUrl(sub["url"] ?: return@map, watchOnlineAPI)
) )
) )
} }
invokeCoatomotate(
res.url.substringAfterLast("/"), episodeId, season, callback
)
}
suspend fun invokeCoatomotate(
urlSlug: String? = null,
episodeId: String? = null,
season: Int? = null,
callback: (ExtractorLink) -> Unit,
) {
val coaMainUrl = "https://coatomotate.monster"
val playSlug = if (season == null) {
"movies/play/$urlSlug"
} else {
"shows/play/$urlSlug"
}
val sid = "9k9iupt5sebbnfajrc6ti3ht7l"
val sec = "1974bc4a902c4d69fcbab261dcec69094a9b8164"
val url = "$coaMainUrl/$playSlug?mid=1&sid=$sid&sec=$sec&t=${System.currentTimeMillis()}"
val res = app.get(url).document
val script = res.selectFirst("script:containsData(window['show_storage'])")?.data()
val hash = Regex("hash:\\s*['\"](\\S+)['\"],").find(script ?: return)?.groupValues?.get(1)
val expires = Regex("expires:\\s*(\\d+),").find(script ?: return)?.groupValues?.get(1)
val videoUrl = if (season == null) {
"$coaMainUrl/api/v1/security/movie-access?id_movie=$episodeId&hash=$hash&expires=$expires"
} else {
"$coaMainUrl/api/v1/security/episode-access?id_episode=$episodeId&hash=$hash&expires=$expires"
}
app.get(videoUrl, referer = url)
.parsedSafe<WatchOnlineResponse>()?.streams?.mapKeys { source ->
callback.invoke(
ExtractorLink(
"WatchOnline",
"WatchOnline",
source.value,
"$coaMainUrl/",
getQualityFromName(source.key),
true
)
)
}
} }
@ -3093,6 +3167,7 @@ data class WatchOnlineItems(
data class WatchOnlineSearch( data class WatchOnlineSearch(
@JsonProperty("items") val items: ArrayList<WatchOnlineItems>? = arrayListOf(), @JsonProperty("items") val items: ArrayList<WatchOnlineItems>? = arrayListOf(),
) )
data class WatchOnlineResponse( data class WatchOnlineResponse(
@JsonProperty("streams") val streams: HashMap<String, String>? = null, @JsonProperty("streams") val streams: HashMap<String, String>? = null,
@JsonProperty("subtitles") val subtitles: Any? = null, @JsonProperty("subtitles") val subtitles: Any? = null,