mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
sora: fix Crunchyroll
This commit is contained in:
parent
1677f754d0
commit
d9cec35f8a
3 changed files with 31 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 104
|
version = 105
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -1506,15 +1506,15 @@ object SoraExtractor : SoraStream() {
|
||||||
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(
|
||||||
title,
|
|
||||||
season,
|
season,
|
||||||
episode,
|
episode,
|
||||||
epsTitle
|
epsTitle
|
||||||
) ?: return
|
)
|
||||||
|
|
||||||
epsId.apmap {
|
epsId?.apmap {
|
||||||
|
delay(2000)
|
||||||
val json =
|
val json =
|
||||||
app.get("$consumetCrunchyrollAPI/watch/${it?.first ?: 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 ->
|
||||||
|
@ -1533,7 +1533,7 @@ object SoraExtractor : SoraStream() {
|
||||||
json?.subtitles?.map subtitle@{ sub ->
|
json?.subtitles?.map subtitle@{ sub ->
|
||||||
subtitleCallback.invoke(
|
subtitleCallback.invoke(
|
||||||
SubtitleFile(
|
SubtitleFile(
|
||||||
fixCrunchyrollLang(sub.lang ?: return@subtitle null) ?: sub.lang,
|
"${fixCrunchyrollLang(sub.lang ?: return@subtitle null) ?: sub.lang} [ass]",
|
||||||
sub.url ?: return@subtitle null
|
sub.url ?: return@subtitle null
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -2927,8 +2927,15 @@ data class ConsumetDetails(
|
||||||
@JsonProperty("episodes") val episodes: ArrayList<ConsumetEpisodes>? = arrayListOf(),
|
@JsonProperty("episodes") val episodes: ArrayList<ConsumetEpisodes>? = arrayListOf(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class CrunchyrollEpisodes(
|
||||||
|
@JsonProperty("id") val id: String? = null,
|
||||||
|
@JsonProperty("title") val title: String? = null,
|
||||||
|
@JsonProperty("episode_number") val episode_number: Int? = null,
|
||||||
|
@JsonProperty("season_number") val season_number: Int? = null,
|
||||||
|
)
|
||||||
|
|
||||||
data class CrunchyrollDetails(
|
data class CrunchyrollDetails(
|
||||||
@JsonProperty("episodes") val episodes: HashMap<String, List<HashMap<String, String>>>? = hashMapOf(),
|
@JsonProperty("episodes") val episodes: HashMap<String, List<CrunchyrollEpisodes>>? = hashMapOf(),
|
||||||
)
|
)
|
||||||
|
|
||||||
data class ConsumetResults(
|
data class ConsumetResults(
|
||||||
|
|
|
@ -38,7 +38,6 @@ import javax.crypto.Cipher
|
||||||
import javax.crypto.spec.IvParameterSpec
|
import javax.crypto.spec.IvParameterSpec
|
||||||
import javax.crypto.spec.SecretKeySpec
|
import javax.crypto.spec.SecretKeySpec
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.collections.HashMap
|
|
||||||
import kotlin.math.min
|
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 soraAPI = base64DecodeAPI("cA==YXA=cy8=Y20=di8=LnQ=b2s=a2w=bG8=aS4=YXA=ZS0=aWw=b2I=LW0=Z2E=Ly8=czo=dHA=aHQ=")
|
||||||
|
@ -742,25 +741,28 @@ suspend fun searchCrunchyrollAnimeId(title: String): String? {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CrunchyrollDetails.findCrunchyrollId(
|
fun CrunchyrollDetails.findCrunchyrollId(
|
||||||
title: String?,
|
|
||||||
season: Int?,
|
season: Int?,
|
||||||
episode: Int?,
|
episode: Int?,
|
||||||
epsTitle: String?
|
epsTitle: String?
|
||||||
): List<Pair<String?, String?>?> {
|
): List<Pair<CrunchyrollEpisodes?, String?>?> {
|
||||||
val sub = when (title) {
|
val sub = this.episodes?.filterKeys { it.contains("subbed") }.matchingEpisode(epsTitle, season, episode) to "Raw"
|
||||||
"One Piece" -> this.episodes?.get("subbed13")?.matchingEpisode(episode) to "Raw"
|
val dub = this.episodes?.filterKeys { it.contains("English Dub") }.matchingEpisode(epsTitle, season, episode) to "English Dub"
|
||||||
"Hunter x Hunter" -> this.episodes?.get("subbed5")?.matchingEpisode(episode) to "Raw"
|
|
||||||
else -> this.episodes?.get("subbed$season")?.matchingEpisode(episode) to "Raw"
|
|
||||||
}
|
|
||||||
val dub = this.episodes?.get("English Dub$season")?.matchingEpisode(episode) to "English Dub"
|
|
||||||
|
|
||||||
return listOf(sub, dub)
|
return listOf(sub, dub)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun List<HashMap<String, String>>?.matchingEpisode(episode: Int?): String? {
|
fun Map<String, List<CrunchyrollEpisodes>>?.matchingEpisode(
|
||||||
return this?.find {
|
epsTitle: String?,
|
||||||
it["episode_number"] == "$episode" || indexOf(it).plus(1) == episode
|
season: Int?,
|
||||||
}?.get("id")
|
episode: Int?
|
||||||
|
): CrunchyrollEpisodes? {
|
||||||
|
return this?.mapNotNull { eps ->
|
||||||
|
eps.value.find {
|
||||||
|
(it.episode_number == episode && it.season_number == season) || it.title.equals(
|
||||||
|
epsTitle,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
} ?: eps.value.find { it.episode_number == episode }
|
||||||
|
}?.firstOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEpisodeSlug(
|
fun getEpisodeSlug(
|
||||||
|
|
Loading…
Reference in a new issue